### Applying a texture mapping to an object ( Tut07.rt )

You can apply a bitmap to an object. If you use a box as a background you can use a bitmap as background. But , if you want, you can apply a texture mapping to any object.

Before you need a bitmap. It must be a .bmp file, in Windows 3.0 bitmap file format and only at 24bit format ( 16 million of colors ). If , for example, its name is "bitm.bmp" you must put it in the same directory where is the file or in the default texture directory. Put the bitmap in the same directory with your .rt file if it is the only file will use that bitmap, while put it in the common directory if more files use it.

You can preload in memory the bitmap with a new section:

{ texture name bitm; }

After in any object section you can use the attribute texture to apply the bitmap: the colors of bitmap will override the Od parameter.

You must write like this:

{ object

name ...;

texture bitm;

....

}

You have not finished. You have told what texture to apply, not how to apply. In fact you must add a new common attribute "mapping".

A mapping associate every point in a 3d system (in this case in the object 3d system ) with a point of the bitmap, and then with a color.

There are many types of mapping, one of this is the planar.

This is an example of the definition of a planar mapping:

mapping { mapping

model { planar

center ( 0 , 0 , 0 );

assx ( 0 , 1 , 0 );

assy ( 0 , 0 , -1 );

moltx 0.130;

molty 0.130;

}

mapping is a common attribute of an object section. The value is a subsection of mapping type. The mapping section follows the same rule of the already seen sections: a common part for all mapping types ( null in this case ), a model attribute, always present and always the last in the section. For now the allowed values are: planar, spherical and cylinder.

In this case is planar.

The planar model put the bitmapped texture on a plane in the space, fill all the plane with periodic replies of the same and then it projects the points in the plane in all the space; in this way planar mapping associates every point in the space with a color. Obvious, this will affect only the object in which the mapping is declared.

center, assx, assy defines the plane and the position of the bitmap. The plane contains the center point and it is parallel to vector assx and assy. Also they defines a reference system on the plane: center is the origin and assx and assy the axes. The primary bitmap will lies in the space defined by disequations : 0 <= x <= 1 and 0 <= y <= 1.

You can modify the dimension of the image with moltiplicative factor moltx and molty, which enlarge the image in horizontal and vertical.