When an actor with an associated texture map is rendered the renderer specific property will first check to see if the texture has been loaded into the rendering hardware (defined > 0). If it hasn't been loaded into the hardware then it sends the texture object a defined=1 message. This message forces the texture to assign itself a unique positive integer value as its value for defined. The renderer specific property can then load the texture map into hardware with the associated integer id.
Textures can be read in using the read! command or texture readers can be written to read in other formats of texture maps. A conversin program called rgbtolymb exists in /home/moose/u2/martink/lymb/util. This program will convert a SGI rgb file to a lymb compatable texture file. Some sample texture files exist in /home/moose/u2/martink/lymb/scripts/textures.
In order for texture mapping to work correctly the modeller must generate texture coordinates. Currently the cylinder_modeller, plane_modeller and line_modeller all generate texture coordinates. In the future filters will be written to generate texture coordinates for modellers who use the display_data object.
It is also important to note that the texture is modulated on top of the original objets color. If the original color is black the resulting image will still be black. If the original color is white the the resulting image will be the actual RGB values of the texture map (assuming that the alpha value is 1.0).
Transparency, 3= Just Color, 4= Color and Transparency.
file the name of a file to read in the texture map from. This file must be a standard texture map file. The standard format is <int_xsize> <int_ysize> <unsigned_long_xsize_by_ysize_array>. The new format for version -1 is <int_version> <int_bytes_per_pixel> <int_xsize> <int_ysize> <unsigned char xsize_by_ysize array of bytes_per_pixel bytes>
smooth_size The size of the gaussian array used to smooth the edges of a texture map when a smooth_edges! message is sent.
version The version number of the file the texture map was read from. Positive numbers mean version zero. All other versions start with -1 and work down.
xsize the x axis size of the 2d texture map.
ysize the y axis size of the 2d texture map.
defined has this texture map been loaded into the rendering hardware. If so what number is it.
bytes_per_pixel? Return the number of bytes used per pixel to store the texture map.
data=value Set the pointer to the array of unsigned long ABGR values. Generally only used by developers.
data? Return a pointer to the array of unsigned long ABGR values. Generally only used by developers.
defined=value Set the value of the defined instance variable. This should only be done by renderer specific property objects.
defined? Get the value of the defined instance variable.
file=filename Set the name of the file to be used for this texture map.
file? Get the name of the file associated with this texture object.
linear_interpolate_off! Tells the rendering hardware not to use bilinear interpolation to determin subpixel texture map colors.
linear_interpolate_on! Tells the rendering hardware to use bilinear interpolation to determin subpixel texture map colors. This will yield the best looking texture maps but requires more rendering time. This should not be used with texture maps that have transparent sections due to some polygon ordering problems.
read! Read in the texture map file specified by the instance variable file
smooth_edges! Runs a gaussian filter over the left, right, top, and bottom edges of a texture map. This will make the texture map more suitable for repeating over a surface since the edges of the texture map will not be as noticable.
repeat_off! Tells the rendering hardware to clamp texture coordinates to the range 0.0 through 1.0.
repeat_on! Tells the rendering hardware to use the fractional coordinates of the texture coordinates. This is the default.
smooth_size=value Set the size of the gaussian window used to smooth the edges of the texture map. Used with the smooth_edges! message.
smooth_size? Return the current setting for the gaussian window size used to smooth the edges of a texture map.
version=value Sets the version number of a texture map. Texture maps with no header will have positive version numbers. Texture maps with headers will have negative version numbers starting with -1 and working down. The version number is set by the read! message.
version? Returns the version number of a texture map.
xsize=value Set the x axis size of a texture map. Typically reserved for use by developers.
xsize? Get the x axis size of a texture map.
ysize=value Set the y axis size of a texture map. Typically reserved for use by developers.
ysize? Get the y axis size of a texture map.
! defining camera 1 camera new:c1 position=(5,0,0) focal_point=(0,0,0) on! ; ! defining light 1 light new:l1 position=(4,4,4) focal_point=(0,0,0) on! ;
cylinder_modeller new: can_model resolution=30 ;
! define texture
! read texture file fromm $LYMB_ROOT/textures directory....you ! may have to edit this script to set the path properly!
texture new: wood file=`/home/lishakill/projects/lymb_dev/lymb/textures/sgi/wood2.lymb.texture' read! ;
actor new: can modeller=can_model color=(0.8,0.4,0.2) /* a cherry red color */ texture=`wood' ;
environment new: "env" variable="LYMB_RENDERER";
string new:rendname =[env value?];
collection new: allactors members=[actor instances?]
;
object # rendname new: aren actors=[actor instances?] lights=l1 cameras= c1 ;
aren render!;
loop new:loop1 duration=1 resolution=90 tick_actions="allactors rotate_x: +4; aren render!;" do_loop!;