OpenGL Volumizer 2.7 Reference Pages


NAME
vzTMRenderAction - Texture-mapping render action.

INHERITS FROM
vzRenderAction

HEADER FILE
#include <Volumizer2/TMRenderAction.h>

PUBLIC METHOD SUMMARY
vzTMRenderAction ( int maxThreads);
virtual ~vzTMRenderAction (  );
void setSamplingRate ( const float samplingRate[3]);
virtual void manage ( vzShape* shape);
virtual void unmanage ( vzShape* shape);
virtual void draw ( vzShape* shape);
virtual void beginDraw ( unsigned int rendererFlags);
virtual void endDraw (  );

CLASS DESCRIPTION
The Texture Mapping Render Action implements the volume rendering pipeline using 3D texture mapping. For each shape drawn, the renderer clips the geometry to texture boundaries, tessellates the geometry into tetrahedra, sorts the tetrahedra, and then rasterizes each tetrahedron in back-to-front order. Rasterization proceeds by slicing each tetrahedron into polygons (polygonization) and texture mapping each slice with a 3-D texture. The computed polygons are then passed to the shader which employs the appropriate OpenGL state and rendering passes to generate the desired visual effect.

The Texture Mapping render action provides resource management for the texture data, which is provided as parameters to the shape's appearance. It is legal to draw shapes whose volume textures do not fit within texture memory. The render action divides the texture into bricks that fit in texture memory and renders them appropriately.

NOTES
The following are some important issues to keep in mind while using the Texture Mapping render action.


SHADERS
The following built-in volume shaders work with the TMRenderAction class: vzTMSimpleShader, vzTMLUTShader, vzTMTangentSpaceShader, vzTMGradientShader, vzTMTagShader.

EXAMPLES
The following code represents a sample use of the vzTMRenderAction class:
vzTMRenderAction renderer(0);    // create a render action 

renderer.manage (shape1);        // manage two shapes. this
renderer.manage (shape2);        // allocates texture objects.

renderer.beginDraw(userFlags);   // begin draw
 
renderer.draw (shape1);          // draw shape 1
renderer.draw (shape2);          // draw shape 2
1
renderer.endDraw();              // end draw

NOTES

METHOD DESCRIPTIONS

   vzTMRenderAction()
vzTMRenderAction ( int maxThreads);

Constructor for the vzTMRenderAction class. Constructor for the vzTMRenderAction class. The only parameter, maxThreads, specifies how many additional threads the render action is allowed to create, at maximum. This parameter is ignored right now and the render action runs in single-threaded mode.

   ~vzTMRenderAction()
virtual ~vzTMRenderAction (  );

Destructor for vzTMRenderAction.

   beginDraw()
virtual void beginDraw ( unsigned int rendererFlags);

This method is used to tell the render action that the application is now ready to issue draw commands on the shapes. Following this, all the methods invoked on the render action must be draw() methods until the invocation of the next endDraw().

On the invocation of beginDraw(), the render action will perform all the texture management necessary for the currently managed shapes. Thus, the beginDraw() marks the end of the texture management phase and the beginning of a new draw phase.

The rendererFlags can be used to pass hints to the render action by setting bit flags. e.g. If the flag VZ_RESTORE_GL_STATE_BIT is set, then at the end of the endDraw(), the render action restores the GL state to the one prior to calling beginDraw().

   draw()
virtual void draw ( vzShape* shape);

This method performs the actual volume-rendering for a shape. The volumetric geometry for the shape is sliced using viewport aligned planes and rendered in a back-to-front order. If the volume geometry has slice planes, then the slice planes are simply rendered in the appropriate order.

The draw method sets the OpenGL state necessary for the using the volume textures contained in the shape. The remaining state settings are done by the specific shaders. The application needs to set the blending related OpenGL state before calling draw() or beginDraw(). For example, the blending function for the common back-to-front blending using the over operator would be glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA).

Note: The shape must have been managed previously by calling manage(). In addition, the draw() method must be called within a beginDraw() / endDraw() pair.

   endDraw()
virtual void endDraw (  );

This method tells the render action that the application is finished executing draw() commands. Following this, any calls to draw() are not legal until a new beginDraw() command is issued.

   manage()
virtual void manage ( vzShape* shape);

Forces the vzShape shape to be kept resident in texture memory, if possible. The effects of this command are not immediate, but rather are delayed until the next beginDraw() command is issued.

Given multiple calls to manage and unmanage, the texture manager attempts to optimize the state changes from one frame to the next.

Note: It is illegal to call this method inside of a beginDraw()/endDraw() pair.

   setSamplingRate()
void setSamplingRate ( const float samplingRate[3]);

Set a sampling rate for volume rendering, defined in texture space. The default sampling rate of (1.0, 1.0, 1.0) would sample once per voxel in each texture dimension.

   unmanage()
virtual void unmanage ( vzShape* shape);

Removes the specified shape from the list of currently-managed shapes. Un-managing a shape frees up its resources to be used for drawing other shapes.

Note: It is illegal to call this method inside of a beginDraw()/endDraw() pair.

SEE ALSO
vzRenderAction, vzTMGradientShader, vzTMLUTShader, vzTMRenderAction, vzTMSimpleShader, vzTMTagShader, vzTMTangentSpaceShader

Back to Index