Home | Download | Screen shots | Discussion | Documentation | Links |
---|
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 VrmlMatrix & | getMatrix () 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 |
VrmlMatrix * | modelview |
bool | draw_bspheres |
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.
|
Constructs an empty render context. An empty context should not be passed to VrmlNode::render. This constructor is useful only for debugging and experimentation. |
|
Constructs and initializes a render context.
|
|
Returns the cull flag.
|
|
Returns the bounding volume debug flag.
|
|
Returns a reference to the modelview matrix.
|
|
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.
|
|
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.
|
|
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.
|
|
Track the results of intersecting node bounds with the view volume.
|
|
Draw the bounding volumes or not. |
|
The current modelview matrix. |