Drawing Textures on Polygons


Drawing Textures on Polygons

Often we wish to represent a class of objects as a single polygon so that they are easily seen. However, sometimes we want to place a texture on our polygon to create a sense of realism. In this section we will describe how to place a texture on a polygon and discuss some of the basic settings that determine how the texture will be drawn.

Adding Textures

To add textures to your polygons, all you need to do is include one or more texture data commands in the data file. The texture data command takes as arguments the image file name and texture number you want to assign that image to (as well as many options which are discussed in the command listing). Then, along with the datavar and texturevar commands, the textures are drawn on the specified polygon. For example, your data file might look like this:

datavar 0 txnum
texturevar txnum
texture 30 image1.sgi
texture 31 image2.sgi
0 0 0 30
1 1 1 31
-1 -1 -1 31
0 0 2 30
where we have defined data variable zero as the column to hold our texture information as specified by texturevar. As a warning though, there appears to be a bug in the software in that it doesn't always load the correct texture or it will load two textures and display them under various luminosity conditions. This may be due to the ordering of texture numbers in the data. A possible solution would involve insuring the data are ordered by texture number, but no thorough investigation has occurred on this bug.

Turning textures on and off

The easiest way to turn the textures on and off is to use the Texture toggle button. However, the texture Control Command will also toggle the textures on and off. This is accomplished by issuing

texture

in the Command Line or within a config file. You may append the on or off commands to texture as well. Note that the command in the previous paragraph to assign a texture number to an image file is the Data Command and would require an add preface if used at the Command Line.

Scaling Textures

Textures can be scaled to fit their polygon, appear small, or appear large, overflowing the polygon edge. The command to change the texture scaling is txscale. The default value is 0.5, which is a perfect fit (the image is fitted to the polygon) if the number of polygon sides is 4. Using a texture scale smaller than this will stretch the image so that it overflows the polygon size and is truncated at the polygon's edge. Using a scale larger than 0.5 shrinks the texture on the polygon. Typically, there is no need to change this value from the default 0.5.

© 2002-2005 American Museum of Natural History
Last Modified: 2006-04-28 by Brian Abbott