Main Page   Namespace List   Class Hierarchy   Compound List   Namespace Members   Compound Members   Related Pages  

VrmlRenderContext Class Reference

Information needed during a render traversal. More...

List of all members.


Public Methods

 VrmlRenderContext ()
 Constructs an empty render context.

 VrmlRenderContext (BVolume::Intersection cull_flag, VrmlMatrix &modelview)
 Constructs and initializes a render context.

BVolume::Intersection getCullFlag () const
 Returns the cull flag.

void setCullFlag (BVolume::Intersection intersection)
 Sets the cull flag.

const VrmlMatrixgetMatrix () const
 Returns a reference to the modelview matrix.

void setMatrix (VrmlMatrix &modelview)
 Sets the modelview matrix.

void setDrawBSpheres (bool f)
 Sets the bounding volume debug flag.

bool getDrawBSpheres () const
 Returns the bounding volume debug flag.


Private Attributes

BVolume::Intersection cull_flag
VrmlMatrixmodelview
bool draw_bspheres

Detailed Description

Information needed during a render traversal.

The members could be arguments to the Node::render method, but there may be many arguments, and adding an argument requires changing nearly every file in the core.

WARNING: This is a concrete base class that is passed by value, not by reference. The idea is to pass everything exactly as if it were a normal argument to the render function. This has some consequences...

First off, the members should be primitives or pointers. There shouldn't be anything that requires a lot of work to copy. Calling render() should be cheap. Secondly, while adding a new member to this class is less work than adding a new argument to every render() call, it still requires a recompile of nearly the whole core. That's because pass-by-value needs to know the exact size of what's being passed. Thirdly, you can't subclass this class. It's concrete. If you pass a subclass it will just get truncated. There are some C++ tricks to prohibit inheriting from a class, but let's assume we're all responsbile adults here.

Why do it this way? Because it makes writing the render() method easier. We don't have to maintain a stack of states, we just use the call stack instead. That means no heap allocation and deallocation, which is very cool. Also, we don't have to pop the stack at the end of the method. Alternatively, I could have used the "initialization is resource acquisition" pattern, but I felt this was cleaner.

Author:
Christopher K. St. John
See also:
Node::render

Browser::render


Constructor & Destructor Documentation

VrmlRenderContext  
 

Constructs an empty render context.

An empty context should not be passed to VrmlNode::render. This constructor is useful only for debugging and experimentation.

VrmlRenderContext BVolume::Intersection    cull_flag,
VrmlMatrix   modelview
 

Constructs and initializes a render context.

Parameters:
cull_flag The cull flag argument will normally be BVolume::partial.
modelview The modelview matrix. The transform can be affine, but the rendering code may take advantage of an orthogonal transform if one is passed in.
See also:
setCullFlag

Member Function Documentation

BVolume::Intersection getCullFlag   const
 

Returns the cull flag.

Returns:
the cull flag

bool getDrawBSpheres   const
 

Returns the bounding volume debug flag.

Returns:
the bounding volume debug flag.

const VrmlMatrix & getMatrix   const
 

Returns a reference to the modelview matrix.

Returns:
the modelview matrix.

void setCullFlag BVolume::Intersection    intersection
 

Sets the cull flag.

Setting to BVolume::inside means that all the last tested bounding volume was completely inside the view volume, so all the contained bounding volumes must also be inside and we can skip further testing. BVolume::partial means that the last test indicated that the bounding volume intersected the view volume, so some of the children may be visible and we must continue testing. BVolume::outside means the last test indicated the bounding volume was completely outside the view volume. However, there's normally no reason to call set with BVolume::outside, since the render method returns immediatly. But who knows, it might be useful some day, so it's an allowed value.

Setting the cull flag to BVolume::inside in the Browser at the top of the traversal has the effect of disabling the culling tests. The behavior is undefined if the flag is not one of the allowed values.

Parameters:
intersection an Intersection enumerant
See also:
Browser

BVolume

void setDrawBSpheres bool    f
 

Sets the bounding volume debug flag.

If true, then the renderer may draw the bounding volumes for each primitive. Or maybe not, so you shouldn't depend on this behavior. It does look kinda cool though.

Parameters:
f bounding volume debug flag.
See also:
Viewer::drawBVolume

void setMatrix VrmlMatrix   modelview
 

Sets the modelview matrix.

VrmlRenderContext retains a pointer to the passed matrix; it does not make a copy. All memory management is up to the caller. In practice, the passed-in array will generally be a local variable in the Node::render method.

Parameters:
modelview the modelview matrix. Must be at least affine, although the render code may optimize for orthogonal transforms.

Member Data Documentation

BVolume::Intersection cull_flag [private]
 

Track the results of intersecting node bounds with the view volume.

See also:
BVolume

bool draw_bspheres [private]
 

Draw the bounding volumes or not.

VrmlMatrix * modelview [private]
 

The current modelview matrix.