OSG::RenderAction Class Reference

RenderAction class. More...

#include <OSGRenderAction.h>

Inheritance diagram for OSG::RenderAction:

OSG::DrawActionBase OSG::Action OSG::ActionBase List of all members.

Public Types

typedef std::map< Material *,
DrawTreeNode * > 
MaterialMap
typedef std::pair< LightChunk *,
Matrixr
LightStore
typedef std::pair< SClipPlaneChunk *,
Matrix
ClipPlaneStore
typedef boost::function< ResultE(NodeCorePtrConstArg, Action *)> Functor
typedef ActionBase::ResultE(NodeCore::*) Callback (Action *)
enum  ResultE { Continue, Skip, Quit }

Public Member Functions

virtual ~RenderAction (void)
 Destructor.
virtual Action::ResultE start (void)
virtual Action::ResultE stop (ResultE res)
void push_matrix (const Matrixr &matrix)
void pop_matrix (void)
const Matrixrtop_matrix (void)
void dropGeometry (MaterialDrawable *pGeo)
void dropFunctor (Material::DrawFunctor &func, Material *mat)
void dropLight (Light *pLight)
void undropLight (Light *pLight)
void dropLightEnv (LightEnv *pLightEnv)
void undropLightEnv (LightEnv *pLightEnv)
void dropClipPlane (ClipPlane *pClipPlane)
void undropClipPlane (ClipPlane *pClipPlane)
void setStateSorting (bool s)
bool getStateSorting (void)
std::vector< Light * > getActiveLights (void)
UInt32 getActiveLightsMask (void)
UInt32 getActiveLightsCount (void)
const std::vector< UInt32 > & getLightEnvsLightsState (void)
StategetCurrentState (void)
void setSortTrans (bool bVal)
bool getSortTrans (void) const
void setZWriteTrans (bool bVal)
bool getZWriteTrans (void) const
void setLocalLights (bool bVal)
bool getLocalLights (void) const
void setCorrectTwoSidedLighting (bool bVal)
bool getCorrectTwoSidedLighting (void) const
void setOcclusionCulling (bool bVal)
bool getOcclusionCulling (void) const
void setOcclusionCullingMode (Int32 mode)
Int32 getOcclusionCullingMode (void) const
void setOcclusionCullingPixels (UInt32 pixels)
UInt32 getOcclusionCullingPixels (void) const
void setOcclusionCullingThreshold (UInt32 threshold)
UInt32 getOcclusionCullingThreshold (void) const
void setSmallFeatureCulling (bool bVal)
bool getSmallFeatureCulling (void) const
void setSmallFeaturePixels (Real32 pixels)
Real32 getSmallFeaturePixels (void) const
void setSmallFeatureThreshold (UInt32 threshold)
UInt32 getSmallFeatureThreshold (void) const
void setUseGLFinish (bool s)
bool getUseGLFinish (void) const
bool isSmallFeature (const NodePtr &node)
bool isOccluded (DrawTreeNode *pRoot)
void deleteOcclusionQueriesPool (void)
GLuint getOcclusionQuery (void)
GLuint getOcclusionQuery (NodePtr node)
void setOcclusionQuery (NodePtr node, GLuint occlusionQuery)
void resetOcclusionQueryIndex (void)
void setOcclusionMask (NodePtr node, UInt8 mask)
bool hasGeometryChild (NodePtr node)
void drawOcclusionBB (const Pnt3r &bbmin, const Pnt3r &bbmax)
void drawMultiFrameOcclusionBB (DrawTreeNode *pRoot)
void drawHierarchicalMultiFrameOcclusionBB (const Matrixr &view, NodePtr node)
bool isVisible (Node *node)
bool pushVisibility (void)
 enter a new level for visibility Return false if node is not visible, true
void popVisibility (void)
 void (OSG_APIENTRY *_glGenQueriesARB)(GLsizei
GLuintvoid (OSG_APIENTRY *_glDeleteQueriesARB)(GLsizei
GLuint *GLuintvoid (OSG_APIENTRY *_glBeginQueryARB)(GLenum
 void (OSG_APIENTRY *_glEndQueryARB)(GLenum)
 void (OSG_APIENTRY *_glGetQueryObjectuivARB)(GLuint
ViewportgetViewport (void) const
void setViewport (Viewport *viewport)
CameragetCamera (void) const
void setCamera (Camera *cam)
const MatrixrgetCameraToWorld (void)
BackgroundgetBackground (void) const
void setBackground (Background *background)
WindowgetWindow (void) const
void setWindow (Window *window)
StatCollectorgetStatCollector (void)
void setStatCollector (StatCollector *stat)
bool getFrustumCulling (void) const
void setFrustumCulling (bool val=true)
bool getVolumeDrawing (void) const
void setVolumeDrawing (bool val=false)
bool getAutoFrustum (void) const
void setAutoFrustum (bool val=true)
const FrustumVolumegetFrustum (void) const
void setFrustum (FrustumVolume &frust)
DrawEnvgetDrawEnv (void) const
UInt32 selectVisibles (void)
MaterialgetMaterial (void) const
NodePtr getMaterialNode (void) const
void setMaterial (Material *pMaterial, NodePtr node)
void registerEnterFunction (const FieldContainerType &type, const Functor &func)
void registerLeaveFunction (const FieldContainerType &type, const Functor &func)
virtual ResultE apply (std::vector< NodePtr >::iterator begin, std::vector< NodePtr >::iterator end)
virtual ResultE apply (NodePtrConstArg node)
NodePtr getActNode (void)
void setActNode (NodePtrConstArg node)
UInt32 getNNodes (void) const
NodePtr getNode (int index)
void addNode (NodePtrConstArg node)
void useNodeList (void)
UInt32 getTravMask (void) const
void setTravMask (UInt32 val)
bool operator< (const Action &other)
 assignment
bool operator== (const Action &other)
bool operator!= (const Action &other)
 unequal

Static Public Member Functions

static RenderActioncreate (void)
 create a new DrawAction by cloning the prototype
static void setPrototype (RenderAction *pPrototype)
 prototype access after setting the prototype all new DrawActions are clones of it
static RenderActiongetPrototype (void)
static void registerEnterDefault (const FieldContainerType &type, const Action::Functor &func)
 Default registration. static, so it can be called during static init.
static void registerLeaveDefault (const FieldContainerType &type, const Action::Functor &func)
static void setPrototype (Action *proto)

Public Attributes

GLuint *GLuintGLuint
 GLenum

Static Public Attributes

static StatElemDesc< StatTimeElemstatDrawTime
static StatElemDesc< StatIntElemstatNMaterials
static StatElemDesc< StatIntElemstatNMatrices
static StatElemDesc< StatIntElemstatNGeometries
static StatElemDesc< StatIntElemstatNTransGeometries
static StatElemDesc< StatStringElemstatNOcclusionMode
static StatElemDesc< StatIntElemstatNOcclusionTests
static StatElemDesc< StatIntElemstatNOcclusionCulled
static const Int32 OcclusionStopAndWait = 1
static const Int32 OcclusionMultiFrame = 2
static const Int32 OcclusionHierarchicalMultiFrame = 6
static StatElemDesc< StatTimeElemstatTravTime
static StatElemDesc< StatIntElemstatCullTestedNodes
static StatElemDesc< StatIntElemstatCulledNodes

Protected Types

typedef DrawActionBase Inherited
typedef std::map< Int32, DrawTreeNode * > SortKeyMap
typedef std::map< Real, DrawTreeNode * > TransSortMap
typedef std::map< Int32, TransSortMapTransSortKeyMap
typedef std::map< Real, DrawTreeNode * > OCMap

Protected Member Functions

 RenderAction (void)
 Constructor.
 RenderAction (const RenderAction &source)
 Copy-Constructor.
void operator= (const RenderAction &source)
virtual std::vector< Functor > * getDefaultEnterFunctors (void)
 assignment
virtual std::vector< Functor > * getDefaultLeaveFunctors (void)
void dump (DrawTreeNode *pRoot, UInt32 uiIndent)
void updateShader (State *state)
virtual void draw (DrawTreeNode *pRoot)
void updateTopMatrix (void)
 Constructor Destructor.
void activateLocalLights (DrawTreeNode *pRoot)
void activateLocalClipPlanes (DrawTreeNode *pRoot)
void getMaterialStates (Material *mat, std::vector< State * > &states)
ResultE callEnter (NodeCorePtrConstArg core)
ResultE callLeave (NodeCorePtrConstArg core)
ResultE recurse (NodePtrConstArg node)
ResultE callNewList (void)

Static Protected Member Functions

static bool terminateEnter (void)
static bool terminateLeave (void)
static ResultE _defaultEnterFunction (NodeCorePtrConstArg node, Action *action)
static ResultE _defaultLeaveFunction (NodeCorePtrConstArg node, Action *action)

Protected Attributes

DrawTreeNodeFactory_pNodeFactory
UInt32 _uiMatrixId
MatrixStore _currMatrix
Matrixr _camInverse
std::vector< MatrixStore_vMatrixStack
MaterialMap _mMatMap
SortKeyMap _pMatRoots
TransSortKeyMap _pTransMatRoots
DrawTreeNode_pNoStateSortRoot
DrawTreeNode_pNoStateSortTransRoot
OCMap _ocRoot
UInt32 _uiActiveMatrix
State_pActiveState
UInt32 _uiNumMaterialChanges
UInt32 _uiNumMatrixChanges
UInt32 _uiNumGeometries
UInt32 _uiNumTransGeometries
UInt32 _uiNumOcclusionTests
UInt32 _uiNumOcclusionCulled
bool _bSortTrans
bool _bZWriteTrans
bool _bLocalLights
bool _bCorrectTwoSidedLighting
bool _bOcclusionCulling
Int32 _occlusionCullingMode
UInt32 _occlusionCullingPixels
UInt32 _occlusionCullingThreshold
UInt32 _currentOcclusionQueryIndex
std::vector< NodePtr > _occluded_nodes
std::set< UInt32 > _hier_occlusions
UInt32 _occ_bb_dl
bool _bSmallFeatureCulling
Real32 _smallFeaturesPixels
UInt32 _smallFeaturesThreshold
Matrixr _worldToScreenMatrix
bool _useGLFinish
std::vector< LightStore_vLights
std::vector< Light * > _lightsMap
UInt32 _lightsState
UInt32 _activeLightsState
UInt32 _activeLightsCount
UInt32 _activeLightsMask
std::vector< std::vector<
UInt32 > > 
_lightsTable
std::vector< UInt32 > _lightsPath
std::vector< UInt32 > _lightEnvsLightsState
std::vector< ClipPlaneStore_vClipPlanes
std::vector< ClipPlane * > _clipPlanesMap
UInt32 _clipPlanesState
UInt32 _activeClipPlanesState
UInt32 _activeClipPlanesCount
UInt32 _activeClipPlanesMask
std::vector< std::vector<
UInt32 > > 
_clipPlanesTable
std::vector< UInt32 > _clipPlanesPath
bool _stateSorting
std::vector< FrustumVolume::PlaneSet_visibilityStack
GLuint _occlusionQuery
std::vector< GLuint_occlusionQueriesPool
std::map< UInt32, GLuint_occlusionQueries
Int32 _cgChunkId
Int32 _cgfxChunkId
Int32 _shlChunkId
Camera_camera
Background_background
Window_window
Viewport_viewport
StatCollector_statistics
bool _frustumCulling
bool _volumeDrawing
bool _autoFrustum
FrustumVolume _frustum
Material_pMaterial
NodePtr _pMaterialNode
Matrixr _mCameraToWorld
DrawEnv_pDrawEnv
std::vector< Functor_enterFunctors
std::vector< Functor_leaveFunctors
NodePtr _actNode
std::vector< NodePtr > * _actList
bool _useNewList
std::vector< NodePtr > _newList
UInt32 _travMask

Static Protected Attributes

static RenderAction_pPrototype = NULL
 the prototype which is copied to create new actions
static std::vector< Functor > * _vDefaultEnterFunctors = NULL
 Default functors for instantiation.
static std::vector< Functor > * _vDefaultLeaveFunctors = NULL
static UInt32 _arbOcclusionQuery
static UInt32 _funcGenQueriesARB = Window::invalidFunctionID
static UInt32 _funcDeleteQueriesARB = Window::invalidFunctionID
static UInt32 _funcBeginQueryARB = Window::invalidFunctionID
static UInt32 _funcEndQueryARB = Window::invalidFunctionID
static UInt32 _funcGetQueryObjectuivARB = Window::invalidFunctionID

Friends

class ShadowViewport

Classes

struct  MatrixStore

Detailed Description

The render action class.

Definition at line 90 of file OSGRenderAction.h.


Member Typedef Documentation

Definition at line 102 of file OSGRenderAction.h.

Definition at line 103 of file OSGRenderAction.h.

typedef std::pair<SClipPlaneChunk *, Matrix > OSG::RenderAction::ClipPlaneStore

Definition at line 104 of file OSGRenderAction.h.

Reimplemented from OSG::DrawActionBase.

Definition at line 250 of file OSGRenderAction.h.

typedef std::map<Int32, DrawTreeNode *> OSG::RenderAction::SortKeyMap [protected]

Definition at line 296 of file OSGRenderAction.h.

typedef std::map<Real, DrawTreeNode *> OSG::RenderAction::TransSortMap [protected]

Definition at line 299 of file OSGRenderAction.h.

typedef std::map<Int32, TransSortMap > OSG::RenderAction::TransSortKeyMap [protected]

Definition at line 300 of file OSGRenderAction.h.

typedef std::map<Real, DrawTreeNode *> OSG::RenderAction::OCMap [protected]

Definition at line 306 of file OSGRenderAction.h.

typedef boost::function<ResultE (NodeCorePtrConstArg, Action *)> OSG::Action::Functor [inherited]

Definition at line 101 of file OSGAction.h.

typedef ActionBase::ResultE(NodeCore::*) OSG::Action::Callback(Action *) [inherited]

Definition at line 103 of file OSGAction.h.


Member Enumeration Documentation

enum OSG::ActionBase::ResultE [inherited]

Enumerator:
Continue 
Skip 
Quit 

Definition at line 71 of file OSGActionBase.h.

00072     {
00073         Continue,   // continue with my children
00074         Skip,       // skip my children
00075                     // really needed? Cancel, 
00076                     // skip my brothers, go one step up
00077         Quit        // forget it, you're done
00078     };


Constructor & Destructor Documentation

RenderAction::~RenderAction ( void   )  [virtual]

Definition at line 504 of file OSGRenderAction.cpp.

References _occ_bb_dl, _occlusionQuery, _pNodeFactory, and deleteOcclusionQueriesPool().

00505 {
00506     delete _pNodeFactory;
00507 
00508 #ifndef OSG_WINCE
00509     if(_occ_bb_dl != 0)
00510         glDeleteLists(_occ_bb_dl, 1);
00511 
00512     if(_occlusionQuery != 0)
00513         _glDeleteQueriesARB(1, &_occlusionQuery);
00514 #endif
00515 
00516     deleteOcclusionQueriesPool();
00517 }

RenderAction::RenderAction ( void   )  [protected]

Definition at line 266 of file OSGRenderAction.cpp.

References _arbOcclusionQuery, _cgChunkId, _cgfxChunkId, OSG::Action::_enterFunctors, _funcBeginQueryARB, _funcDeleteQueriesARB, _funcEndQueryARB, _funcGenQueriesARB, _funcGetQueryObjectuivARB, OSG::Action::_leaveFunctors, _pNodeFactory, _shlChunkId, _vDefaultEnterFunctors, _vDefaultLeaveFunctors, NullFC, OSG_DLSYM_UNDERSCORE, OSG::Window::registerExtension(), OSG::Window::registerFunction(), OSG::subRef(), and OSG::SingletonHolder< SingletonT >::the().

Referenced by create().

00266                                :
00267      Inherited           (),
00268     _pNodeFactory        (NULL),
00269 
00270     _uiMatrixId          (0),
00271     _currMatrix          (),
00272     _vMatrixStack        (),
00273 
00274     _mMatMap             (),
00275 
00276     _pMatRoots           (),
00277     _pTransMatRoots      (),
00278     _pNoStateSortRoot    (NULL),
00279     _pNoStateSortTransRoot(NULL),
00280 
00281     _ocRoot              (),
00282     _uiActiveMatrix      (0),
00283     _pActiveState        (NULL),
00284 
00285     _uiNumMaterialChanges(0),
00286     _uiNumMatrixChanges  (0),
00287     _uiNumGeometries     (0),
00288     _uiNumOcclusionTests (0),
00289     _uiNumOcclusionCulled(0),
00290     _uiNumTransGeometries(0),
00291 
00292     _bSortTrans               (true),
00293     _bZWriteTrans             (false),
00294     _bLocalLights             (false),
00295     _bCorrectTwoSidedLighting (false),
00296     _bOcclusionCulling        (false),
00297     _occlusionCullingMode     (OcclusionStopAndWait),
00298     _occlusionCullingPixels   (0),
00299     _occlusionCullingThreshold(64),
00300     _currentOcclusionQueryIndex(0),
00301     _occluded_nodes            (),
00302     _hier_occlusions           (),
00303     _occ_bb_dl                 (0),
00304 
00305     _bSmallFeatureCulling   (false),
00306     _smallFeaturesPixels    (10.0f),
00307     _smallFeaturesThreshold (32),
00308     _worldToScreenMatrix    (),
00309 
00310     _useGLFinish            (true),
00311 
00312     _vLights(),
00313     _lightsMap(),
00314     _lightsState(0),
00315     _activeLightsState(0),
00316     _activeLightsCount(0),
00317     _activeLightsMask(0),
00318 
00319     _lightsTable(),
00320     _lightsPath(),
00321     _lightEnvsLightsState(),
00322 
00323     _vClipPlanes(),
00324     _clipPlanesMap(),
00325     _clipPlanesState(0),
00326     _activeClipPlanesState(0),
00327     _activeClipPlanesCount(0),
00328     _activeClipPlanesMask(0),
00329 
00330     _clipPlanesTable(),
00331     _clipPlanesPath(),
00332 
00333     _stateSorting(true),
00334     _visibilityStack(),
00335 
00336     _occlusionQuery         (0),
00337     _occlusionQueriesPool   (),
00338     _occlusionQueries       (),
00339 
00340     _glGenQueriesARB        (NULL),
00341     _glDeleteQueriesARB     (NULL),
00342     _glBeginQueryARB        (NULL),
00343     _glEndQueryARB          (NULL),
00344     _glGetQueryObjectuivARB (NULL),
00345 
00346     _cgChunkId(-1),
00347     _cgfxChunkId(-1),
00348     _shlChunkId(-1)
00349 {
00350     if(_vDefaultEnterFunctors != NULL)
00351         _enterFunctors = *_vDefaultEnterFunctors;
00352 
00353     if(_vDefaultLeaveFunctors != NULL)
00354         _leaveFunctors = *_vDefaultLeaveFunctors;
00355 
00356     _pNodeFactory = new DrawTreeNodeFactory;
00357 
00358     _arbOcclusionQuery          = Window::registerExtension("GL_ARB_occlusion_query");
00359     _funcGenQueriesARB          = Window::registerFunction (OSG_DLSYM_UNDERSCORE"glGenQueriesARB", _arbOcclusionQuery);
00360     _funcDeleteQueriesARB       = Window::registerFunction (OSG_DLSYM_UNDERSCORE"glDeleteQueriesARB", _arbOcclusionQuery);
00361     _funcBeginQueryARB          = Window::registerFunction (OSG_DLSYM_UNDERSCORE"glBeginQueryARB", _arbOcclusionQuery);
00362     _funcEndQueryARB            = Window::registerFunction (OSG_DLSYM_UNDERSCORE"glEndQueryARB", _arbOcclusionQuery);
00363     _funcGetQueryObjectuivARB   = Window::registerFunction (OSG_DLSYM_UNDERSCORE"glGetQueryObjectuivARB", _arbOcclusionQuery);
00364 
00365     // we can't include OSGCGChunk here because it is in Contrib ...
00366     StateChunkPtr cgChunk = dynamic_cast<StateChunkPtr>(FieldContainerFactory::the()->createContainer("CGChunk"));
00367     if(cgChunk != NullFC)
00368     {
00369         _cgChunkId = cgChunk->getClass()->getId();
00370         subRef(cgChunk);
00371     }
00372 
00373     // we can't include OSGCGFXChunk here because it is in Contrib ...
00374     StateChunkPtr cgfxChunk = dynamic_cast<StateChunkPtr>(FieldContainerFactory::the()->createContainer("CGFXChunk"));
00375     if(cgfxChunk != NullFC)
00376     {
00377         _cgfxChunkId = cgfxChunk->getClass()->getId();
00378         subRef(cgfxChunk);
00379     }
00380 
00381     StateChunkPtr shlChunk = dynamic_cast<StateChunkPtr>(FieldContainerFactory::the()->createContainer("SHLChunk"));
00382     if(shlChunk != NullFC)
00383     {
00384         _shlChunkId = shlChunk->getClass()->getId();
00385         subRef(shlChunk);
00386     }
00387 }

RenderAction::RenderAction ( const RenderAction source  )  [protected]

Definition at line 393 of file OSGRenderAction.cpp.

References _pNodeFactory.

00393                                                      :
00394      Inherited           (source),
00395     _pNodeFactory        (NULL),
00396 
00397     _uiMatrixId          (source._uiMatrixId),
00398     _currMatrix          (source._currMatrix),
00399     _vMatrixStack        (source._vMatrixStack),
00400 
00401     _mMatMap             (source._mMatMap),
00402 
00403     _pMatRoots           (source._pMatRoots),
00404     _pTransMatRoots      (source._pTransMatRoots),
00405     _pNoStateSortRoot    (source._pNoStateSortRoot),
00406     _pNoStateSortTransRoot(source._pNoStateSortTransRoot),
00407 
00408     _ocRoot              (source._ocRoot),
00409 
00410     _uiActiveMatrix      (source._uiActiveMatrix),
00411     _pActiveState        (source._pActiveState),
00412 
00413     _uiNumMaterialChanges(source._uiNumMaterialChanges),
00414     _uiNumMatrixChanges  (source._uiNumMatrixChanges),
00415     _uiNumGeometries     (source._uiNumGeometries),
00416     _uiNumOcclusionTests (source._uiNumOcclusionTests),
00417     _uiNumOcclusionCulled(source._uiNumOcclusionCulled),
00418     _uiNumTransGeometries(source._uiNumTransGeometries),
00419 
00420     _bSortTrans                (source._bSortTrans),
00421     _bZWriteTrans              (source._bZWriteTrans),
00422     _bLocalLights              (source._bLocalLights),
00423     _bCorrectTwoSidedLighting  (source._bCorrectTwoSidedLighting),
00424     _bOcclusionCulling         (source._bOcclusionCulling),
00425     _occlusionCullingMode      (source._occlusionCullingMode),
00426     _occlusionCullingPixels    (source._occlusionCullingPixels),
00427     _occlusionCullingThreshold (source._occlusionCullingThreshold),
00428     _currentOcclusionQueryIndex(source._currentOcclusionQueryIndex),
00429     _occluded_nodes            (source._occluded_nodes),
00430     _hier_occlusions           (source._hier_occlusions),
00431     _occ_bb_dl                 (source._occ_bb_dl),
00432 
00433     _bSmallFeatureCulling   (source._bSmallFeatureCulling),
00434     _smallFeaturesPixels    (source._smallFeaturesPixels),
00435     _smallFeaturesThreshold (source._smallFeaturesThreshold),
00436     _worldToScreenMatrix    (source._worldToScreenMatrix),
00437 
00438     _useGLFinish            (source._useGLFinish),
00439 
00440     _vLights             (source._vLights),
00441     _lightsMap           (source._lightsMap),
00442     _lightsState         (source._lightsState),
00443     _activeLightsState   (source._activeLightsState),
00444     _activeLightsCount   (source._activeLightsCount),
00445     _activeLightsMask    (source._activeLightsMask),
00446 
00447     _lightsTable         (source._lightsTable),
00448     _lightsPath          (source._lightsPath),
00449     _lightEnvsLightsState(source._lightEnvsLightsState),
00450 
00451     _vClipPlanes            (source._vClipPlanes),
00452     _clipPlanesMap          (source._clipPlanesMap),
00453