#include <sglScene.hpp>
Inheritance diagram for sglScene::
Public Methods | |
sglScene () | |
virtual | ~sglScene () |
void | preDraw () |
void | preDraw (const sglTimespec &frame_time, unsigned int frame_count) |
virtual void | preDraw (const PreDrawStruct &trav) |
unsigned int | getFrameCount () const |
const sglTimespec& | getFrameTime () const |
void | cull (sglCullf &trav_state, float fov_x, float fov_y, unsigned int viewport_x, unsigned int viewport_y, const sglFrustumf &orig_frustum, const sglMat4f &view_matrix, const deque< const sglStatelet *> &override_statelets, unsigned int discriminator_mask=0, unsigned int state_mask=0) const |
void | cull (sglCullf &trav_state, unsigned int viewport_x, unsigned int viewport_y, const sglViewPlatform &view_platform, const deque< const sglStatelet *> &override_statelets, unsigned int discriminator_mask=0, unsigned int state_mask=0) const |
void | drawCulled (float fov_x, float fov_y, unsigned int viewport_x, unsigned int viewport_y, const sglFrustumf &orig_frustum, const sglMat4f &view_matrix, const deque< const sglStatelet *> &override_statelets, unsigned int discriminator_mask=0, unsigned int state_mask=0) const |
void | cull (sglCulld &trav_state, float fov_x, float fov_y, unsigned int viewport_x, unsigned int viewport_y, const sglFrustumd &orig_frustum, const sglMat4d &view_matrix, const deque< const sglStatelet *> &override_statelets, unsigned int discriminator_mask=0, unsigned int state_mask=0) const |
void | cull (sglCulld &trav_state, unsigned int viewport_x, unsigned int viewport_y, const sglViewPlatform &view_platform, const deque< const sglStatelet *> &override_statelets, unsigned int discriminator_mask=0, unsigned int state_mask=0) const |
void | drawCulled (float fov_x, float fov_y, unsigned int viewport_x, unsigned int viewport_y, const sglFrustumd &orig_frustum, const sglMat4d &view_matrix, const deque< const sglStatelet *> &override_statelets, unsigned int discriminator_mask=0, unsigned int state_mask=0) const |
virtual sglNode* | clone (unsigned int mode) const |
virtual void | printInfo (ostream &ostrm, const char *indent_string) const |
Static Public Methods | |
float | computeLODScale (float fov_x, float fov_y, unsigned int viewport_x, unsigned int viewport_y) |
void | createDefaultStatelets (vector< const sglStatelet *> &def) |
Protected Methods | |
virtual void | cull (sglCull< float > &trav_state, unsigned int cull_flags) const |
virtual void | cull (sglCull< double > &trav_state, unsigned int cull_flags) const |
void | copyTo (sglScene *dst, unsigned int mode) const |
The computeLODScale helper function determines a scale to be applied to the level-of-detail (sglLOD) range calculations. It is a function of the size of the window in pixels and the field of view (FOV). This function does not need to be called if you call the cull entry points in this class. See sglLOD for an explanation for this function.
The createDefaultStatelets helper function fills the provided vector with dynamically allocated statelets set to their default values. The is used internally with the cull traversal, but has been exposed for SGL users as well.
Example:
// Must come before sglScene and sglCull classes are constructed sgl::initialize(); // Add all geometry below this node. sglScene *root = new sglScene; : : // Reuse the same traversal state node from frame to frame for better // performance. sglCullf trav_state; while (!quit_flag) { // Do application specific work doAppStuff(); // Adjust internal data-structures (display lists, bounding volumes, // etc...) for the parts of the scene graph that may have changed // since last frame. root->preDraw(); // Collect the geometry intersecting the given frustum & view_matrix. root->cull(trav_state, fov_x, fov_y, win_x, win_y, frustum, view_matrix, override_statelets, disc_mask, state_mask); // Render the visible geometry. trav_state.draw(); }
Example using the sglViewPlatform:
// Must come before sglScene and sglCull classes are constructed sgl::initialize(); // Add all geometry below this node. sglScene *root = new sglScene; // used to move the camera around sglTransformf view_trans = new sglTransformf; root->addChild(view_trans); // set up the view platform and camera sglPerspectiveCamera *view_camera = new sglPerspectiveCamera; view_camera->setFOV(M_PI*0.25, (double)win_x/(double)win_y, 1.0, 200.0); sglViewPlatform *view_platform = new sglViewPlatform(*view_camera); view_platform->setEnableZUp(true); view_trans->addChild(view_platform); : : // Reuse the same traversal state node from frame to frame for better // performance. sglCullf trav_state; while (!quit_flag) { // Do application specific work doAppStuff(); // Adjust internal data-structures (display lists, bounding volumes, // etc...) for the parts of the scene graph that may have changed // since last frame. root->preDraw(); // Collect the geometry intersecting the given frustum & view_matrix. root->cull(trav_state, win_x, win_y, *view_platform, override_statelets, disc_mask, state_mask); // setup OpenGL projection matrix (view_platform->getCamera()).applyProjection(); // Render the visible geometry. trav_state.draw(); }
Definition at line 148 of file sglScene.hpp.
|
Default constructor. Must be called only after sgl::initialize().
|
|
virtual destructor.
|
|
Helper function to compute an LOD scale value based on the current field of view, and window size. This is used to select higher detail children of sglLOD nodes in larger windows and/or smaller fields of view.
|
|
Helper function to fill a vector with all of the default statelet nodes in the correct order (used by the state sorting mechanism).
|
|
This functions must be called with a valid OpenGL graphics context current. Must be called once before each "frame" to increment the frame count and frame time. If necessary it will also traverse the scene graph and "clean" it (clear the dirty bits) by creating any needed display lists, binding any textures(?), recomputing any bounding boxes, and reconfiguring animation nodes. |
|
An alternative to the preDraw() function in which the user may specify the current frame time and frame count. This functions must be called with a valid OpenGL graphics context current. Must be called once before each "frame" to increment the frame count and frame time. If necessary it will also traverse the scene graph and "clean" it (clear the dirty bits) by creating any needed display lists, binding any textures(?), recomputing any bounding boxes, and reconfiguring animation nodes.
|
|
To prevent ambiguity on SGI's MIPSPro 7.3.x compilers. See sglNode.
Reimplemented from sglGroup. Definition at line 202 of file sglScene.hpp. |
|
Get the current frame count (used in sglKeyFrameAnimation nodes).
Definition at line 207 of file sglScene.hpp. |
|
Get the current frame time (used in sglTimedAnimation nodes).
Definition at line 212 of file sglScene.hpp. |
|
An entry point for the single precision cull traversal to perform view frustum culling (before rendering occurs).
|
|
An second entry point for the single precision cull traversal to perform view frustum culling (before rendering occurs) using an sglViewPlatform.
|
|
A deprecated entry point for the single precision cull traversal to perform view frustum culling AND rendering. This function provides its own sglCull object for culling and drawing and destructs it before returning.
|
|
An entry point for the double precision cull traversal to perform view frustum culling (before rendering occurs). See single precision version for an explanation of the parameters. |
|
An entry point for the double precision cull traversal to perform view frustum culling (before rendering occurs). See single precision version for an explanation of the parameters. |
|
A deprecated entry point for the double precision cull traversal to perform view frustum culling (before rendering occurs). See single precision version for an explanation of the parameters. |
|
Make a copy of the scenegraph rooted at this node.
Reimplemented from sglGroup. |
|
Output the state of this node to the specified ostream.
Reimplemented from sglGroup. |
|
The single precision cull traversal function that culls out subgraphs that do not lie in the view frustum (stored in the sglCull parameter). Subclasses must implement this function. The entry point for user-friendly culling is in the sglScene class.
Reimplemented from sglGroup. Definition at line 356 of file sglScene.hpp. |
|
The double precision cull traversal function that culls out subgraphs that do not lie in the view frustum (stored in the sglCull parameter). Subclasses must implement this function. The entry point for user-friendly culling is in the sglScene class.
Reimplemented from sglGroup. Definition at line 363 of file sglScene.hpp. |