viewTexture derived from ygNode Example Source Header

Description: replaces the texture on objects below it with that of a rendered view

notes:
Category: Attributes
Author: Alex Hill
05/10/02
Revision: 01/15/03 Alex Hill - added save option

    Messages
file node load file to establish texture size and format
scene node set node name of the source scene if not the entire scene
view two floats set field of view in degrees (horizontal, vertical)
save file save current view into an RGB image file
    Comments

method caveChannelNum

constructor viewTexture

1 allocated channel data to share texture file
2 create a performer scene node
3 for each pipe do
3.1 get a handle to the pipe
3.2 get a handle to the associated pipe window
3.3 get a handle to the associated cave channel
3.4 create a new channel for this view
3.5 set the channel data for the view
3.6 pass the channel data for the view
3.7 set the scene for the view
3.8 set the earth sky model to that of the cave channel
3.9 insert view channel as the first channel rendered
3.10 add view channel to the list of view channels
4 distribute the name of the scene node
5 distribute the camera field of view
6 distribute the name of the node affected
7 distribute the name of file to save

destructor ~viewTexture

method reset

1 clear the filename string
2 clear the scenename string
3 set the scene to be the entire visible scene
4 clear the savename string
5 set the field of view to 45.0 horizontal and 45.0 vertical

method message

1 load file to establish texture size and format
2 set node name of the source scene if not the entire scene
3 set field of view in degrees (horizontal, vertical)
4 save current view into an RGB image file

method viewCullChannel

1 invoke Performer cull-processing for this frame

method viewDrawChannel

1 cast channel data
2 make sure the back left buffer is used
3 erase framebuffer and draw Earth-Sky model
4 invoke Performer draw-processing for this frame
5 subload frame buffer into the texture

method setTexture

1 create a new pfTexture
2 if the texture file can be loaded then
2.1 set the filename net key string
2.2 get image size
2.3 set the texture to allow subloading
2.4 initialize the origin of both the source and the destination texture
2.5 set the size of the texture to be loaded
2.6 set the load mode to extract from the frame buffer
2.7 set up texture filtering
2.8 for each view channel, update the passed data

method saveTexture

1 for each view channel, update the passed data

method setScene

1 remove any previous node from under the scene node
2 find the desired node for the scene
3 if the node is found then
3.1 update the scenename net key string
3.2 add the associated performer node as a child to the scene

method setFOV

1 update the field of view net key vector
2 for each view channel, set the field of view

method setChildrenTextures

1 if node type is pfGeode then set geoset textures
1.1 for each geode, call setGeosetTexture
2 else, if node type is pfGroup
2.1 call setChildrenTextures recursively on all children

method setGeosetTexture

1 find and set geostate texture to texture with view

method updateChannels

1 get node transformation matrix
2 for each view channel
2.1 get a handle to the pipe
2.2 get a handle to the pipe window
2.3 get a handle to associated cave channel
2.4 set the view channel view matrix to the node transformation matrix
2.5 get the cave channel near and far
2.6 set the view channel near and far
2.7 get the cave channel size
2.8 get the cave channel viewport
2.9 calculate the required viewport for given view texture size
2.10 set the view channel viewport

method app

1 if texture has been loaded then
1.1 if geometry changed then find textures and replace with view texture
1.2 update channel viewports