### A simple scene ( Tut01.RT )

Look at file TUT01.RT.

Tut01.rt is the simplest scene you can render. All sections are needed.

This scene is a sphere with a light source ( lamp ) .

Here a short description of the sections used:

vcr

view coordinate reference, it describes the 3d view of the scene.

lamp

is a light source.

material

describes the physical characteristics of an object, if it is red or white, if it is opaque or transparent.

object

is an object of the scene.

They can be declared in any order, except in the case of materials which must precede objects, because, the object sections reference to the material section.

For lamps, materials, and objects vary types of model exist. For example an object can be a sphere ( like in this case ) or a box or other. All the objects have some attributes that are common to all objects, ( the part before model ) while others that are specific to the particular type of object. The common attributes in the section object that must always be declared are name and material.

Give a look to the section object. The common attribute can be:

name

is the name of the object. All objects in the scene must have an unique name; if not the new object will override the old.

material

is the name of the material which describes the physical characteristics of an object. It must exist a material section which declares a material which name will be used in a object section.

For some type of object, called metaobjects, you must not include the attribute material, but these are not real object. They are explained later.

model

its value is a subsection which name is the type of the object: in this case sphere. It must be the last attribute in the section.

The sphere is the most simple object. It has only two attributes: center and radius.

center

is the center of the sphere. It is described in the point format "( x , y , z )".

radius

is a real, the radius of the sphere.

For material section , it is the same. There is a common part, but you can use only the common attribute name. Now is available only a type of material: phong, so you must always use phong. It will be used by one or more object section ( a material never used is not an error ). The name must be unique, if not it will delete old definition.

We can divide its attribute into three groups: the group which start with letter K ( coefficient ) , which start with O ( colors ) , the others.

The K attributes are:

Ka

is the ambient-reflection coefficient.

Kd

is the diffusive-reflection coefficient.

Ks

is the specular-reflection coefficient.

Kt

the transmission coefficient.

They determinates the object color and the direction of the ray when it intersects an object with this characteristics.

Ka allows to show object without a lamp, using a special ambient lamp, but you don' t get good results with Ka attribute.

Some examples:

Ka=0, Kd=0.7, Ks=0, Kt=0 an opaque object

Ka=0, Kd=0.6, Ks=0.1, Kt=0 a reflexive object

Ka=0, Kd=0.1, Ks=0.7, Kt=0 a mirror

Ka=0, Kd=0.3, Ks=0, Kt=0.8 a transparent object

The O attributes are:

Od

is the diffuse color. If you want change the color of an object change this, it is what you intend for color of an object.

Os

is the specular color. If you want to change the color of the highlight, change Os.

They are specificated in color format "( r , g , b )" where r, g, b are the red, green, blue component, which must be real numbers between 0 and 1 and 1 means all color , 0 no color.

The other parameters are:

n

the specular-reflection exponent. Defines how large must be the reflex of light sources on object.

ni

the index of refraction. Determinates the deviation of the ray when it crosses a transparent object.

The same is true for lamp. The common attribute is only the name (must be unique ).

A model is pointlamp, which can transmit the same energy at any distance. It is all in a point. pointlamp has attributes pos and color.

pos

the position of the lamp. The lamp is all in a point. It is in the point format "( x , y , z )".

color

color of the lamp. A rgb color in the format "( r , g , b )".

Remember that sometimes you can' t see the object because there are not light sources.

A complex thing is to put the view in a way that you can observe the object you want.

The view described is more complex, but you can make some images without understanding it. If you want to learn it go to paragraph "Understanding the 3D view". If you don' t want for now, you can use an empirical way, but for a simple use. You can copy every time the vcr section of the file tut01.rt which we will call the standard view ( for program RT ).

It is sufficient you follow a simple rule : your object must have all its points with x coordinates > 0 and the distance from x axis * 2 < x coordinate.

For example:

point ( -3 , 0 , 2 ) is out the view

because x < 0 , for the first condition

point ( 7 , 3 , 10 ) is out the view

because sqrt(3*3+10*10) * 2 = 20.8 < 7, for the second condition

point ( 17 , 3 , 3 ) is ok

You must not calculate it for all the points of an object: you can compute only for the center or another point so you will see that part. Then , if you want, you can move it empirically to see it better.