An ImageTexture maps the image onto the surface of the object in line with two axes. You define an axis to map the horizontal axis of the image to and an axis to map the vertical axis of the image to.
The command for defining an ImageTexture is as follows:
ImageTexture(int precedence, GenericPixmap * image_file, axis image_horizontal, double left, double right, axis image_vertical, double top, double bottom, texture_tiling do_tile, texture_method apply_method, int do_filter, int spec_0,int trans_0);
All textures have a precedence. If an object has just one texture applied to it then just set this to zero. However if there are several textures, higher precedence textures are applied first. A negative precedence overrides all other textures.
This must be a pgm, ppm or pbm file.
The next 6 parameters specify how the image is mapped onto the object. The object must be positioned so the image can be squarely aligned with two axis. The axis image_horizontal is parallel to the horizontal axis of the image. Left and right give the position on the image_horizontal axis of the left and right edges of the image. The axis image_vertical is parallel to the vertical axis of the image. Top and bottom give the position on the axis image_vertical of the top and bottom edges of the image.
The tile options are SINGLE or TILED. If the SINGLE option is selected then a single image is placed at the coordinates difined above. But if the TILED option is selected the coordinates above specify the position of one tile of the image. The image is repeated to cover the whole object.
The apply method options are TEXMETHOD_OPAQUE or TEXMETHOD_TRANSPARENT. An TEXMETHOD_OPAQUE image overrides the diffuse colour of the material and a transparent image alters the colour of the material by multiplying the diffuse colour of the image by the colour of the picture. See note at bottom of page about TEXMETHOD_TRANSPARENT_PINK.
This turns bilinear filtering on/off (TRUE is on; FALSE is off). If bilinear filtering is off it will ray trace faster which is good for draft copies but the texture may appear pixelated in close up views.
When this is on it sets reflectivity of the object to zero where image is applied. This is useful if you have a reflective object with a non reflective image on it such as a paper label on a mirror surface.
If this is on it sets the transperancy of the object to zero where the image is applied. Example: A paper label on a glass surface.
Figure 12 shows an image texture as it is applied to the two objects below.
Figure 12: ImageTexture
//Square Image 1 object the_object3 = bind(stretch(3,1,1, shift(1,0,0,new_cube()))); the_object3->material = yellow; the_object3->texture = new ImageTexture(0, "y.pgm", X, 0.5, 5.5, Z, 0.5,-0.5, SINGLE, TEXMETHOD_TRANSPARENT, TRUE, FALSE, FALSE); LINK(the_scene, PLUS, bind(the_object3)); //Square Image 2 object the_object4 = bind(shift(1,1,1,new_cube())); the_object4->material = new DSTmaterial(0.5, 0.9, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 40.0, 1.0); the_object4->texture = new ImageTexture(0, "y.pgm", X, 0.001, 1.999, Z, 1.999,0.001, SINGLE, TEXMETHOD_TRANSPARENT, TRUE, FALSE, FALSE); LINK(the_scene, PLUS, shear(Z,X,0.6,bind(the_object4)));New texture options
Since version 220.127.116.11 a new option TEXMETHOD_TRANSPARENT_PINK has been added, which is the same as TEXMETHOD_OPAQUE execpt texture values of [255, 0, 255] (Magic Pink) become transparent.
Note: This only works for colour images.
Note: When drawing pink onto your image, be sure not to use an anti-aliased brush.
Note: If thin pink edges occur in your output, then turn off the bi-linear filtering.