OSG::RenderTraversalActionBase Class Reference

Base class using the render action interface of window.

#include <OSGRenderTraversalActionBase.h>

Inheritance diagram for OSG::RenderTraversalActionBase:

OSG::DataSlotMixin< MixinHead< RenderTravDataSlotDesc > > OSG::MixinHead< RenderTravDataSlotDesc > OSG::Action OSG::ActionBase OSG::RenderTraversalAction List of all members.

Public Types

typedef boost::function< ResultE(NodeCorePtrConstArg, Action *)> Functor
typedef ActionBase::ResultE(NodeCore::*) Callback (Action *)
enum  ResultE { Continue, Skip, Quit }

Public Member Functions

ValuePtr getData (Int32 iSlotId)
void setDataX (FieldBundleP pBundle, Int32 iSlotId)
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
Destructor


virtual ~RenderTraversalActionBase (void)
Rendering Environment


ViewportgetViewport (void) const
void setViewport (Viewport *pViewport)
CameragetCamera (void) const
void setCamera (Camera *pCamera)
BackgroundgetBackground (void) const
void setBackground (Background *pBackground)
WindowgetWindow (void) const
void setWindow (Window *pWindow)
StatCollectorgetStatCollector (void) const
void setStatCollector (StatCollector *pStat)
Culling


virtual bool getFrustumCulling (void) const
virtual void setFrustumCulling (bool val=true)
virtual bool getVolumeDrawing (void) const
virtual void setVolumeDrawing (bool val=false)
bool getAutoFrustum (void) const
void setAutoFrustum (bool val=true)
virtual const FrustumVolumegetFrustum (void) const
virtual void setFrustum (FrustumVolume &frust)
Lights


virtual bool isVisible (Node *node)=0
Lights


virtual ActionBase::ResultE start (void)
virtual ActionBase::ResultE stop (ActionBase::ResultE res)
Lights


StageValidatorgetStageValidator (void)
Lights


virtual void pushPartition (UInt32 uiCopyOnPush, RenderPartitionBase::Mode eMode)=0
virtual void popPartition (void)=0
virtual void beginPartitionGroup (void)=0
virtual void endPartitionGroup (void)=0
virtual Int32 getActivePartitionIdx (void)=0
virtual Int32 getLastPartitionIdx (void)=0
virtual void readdPartitionByIndex (UInt32 uiPartIdx)=0

Static Public Member Functions

static Actioncreate (void)
 create a new action
static void setPrototype (Action *proto)
static ActiongetPrototype (void)
static void registerEnterDefault (const FieldContainerType &type, const Functor &func)
static void registerLeaveDefault (const FieldContainerType &type, const Functor &func)

Static Public Attributes

static StatElemDesc< StatTimeElemstatTravTime

Protected Types

typedef Inherited::Desc Desc
typedef Desc::DataStore DataStore

Protected Member Functions

ResultE callEnter (NodeCorePtrConstArg core)
ResultE callLeave (NodeCorePtrConstArg core)
ResultE recurse (NodePtrConstArg node)
ResultE callNewList (void)
virtual std::vector< Functor > * getDefaultEnterFunctors (void)
virtual std::vector< Functor > * getDefaultLeaveFunctors (void)
Constructors


 RenderTraversalActionBase (void)
 RenderTraversalActionBase (const RenderTraversalActionBase &source)

Static Protected Member Functions

static ResultE _defaultEnterFunction (NodeCorePtrConstArg node, Action *action)
static ResultE _defaultLeaveFunction (NodeCorePtrConstArg node, Action *action)

Protected Attributes

Camera_pCamera
Background_pBackground
Window_pWindow
Viewport_pViewport
StatCollector_pStatistics
StageValidator_pStageValidator
bool _bFrustumCulling
bool _bVolumeDrawing
bool _bAutoFrustum
FrustumVolume _oFrustum
DataStore _mfData
std::vector< Functor_enterFunctors
std::vector< Functor_leaveFunctors
NodePtr _actNode
std::vector< NodePtr > * _actList
bool _useNewList
std::vector< NodePtr > _newList
UInt32 _travMask

Private Types

typedef RenderTravActionBaseParent Inherited

Private Member Functions

void operator= (const RenderTraversalActionBase &source)
 prohibit default function (move to 'public' if needed)

Detailed Description

Definition at line 79 of file OSGRenderTraversalActionBase.h.


Member Typedef Documentation

Reimplemented from OSG::MixinHead< RenderTravDataSlotDesc >.

Definition at line 139 of file OSGDataSlotMixin.h.

Definition at line 141 of file OSGDataSlotMixin.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

RenderTraversalActionBase::~RenderTraversalActionBase ( void   )  [virtual]

Definition at line 117 of file OSGRenderTraversalActionBase.cpp.

References _pStageValidator, _pStatistics, and OSG::subRef().

00118 {
00119     OSG::subRef(_pStatistics);
00120 
00121     delete _pStageValidator;
00122 }

RenderTraversalActionBase::RenderTraversalActionBase ( void   )  [protected]

Definition at line 77 of file OSGRenderTraversalActionBase.cpp.

References _pStageValidator.

00077                                                          :
00078      Inherited      (     ),
00079     _pCamera        (NULL ),
00080     _pBackground    (NULL ),
00081     _pWindow        (NULL ),
00082     _pViewport      (NULL ),
00083     _pStatistics    (NULL ),
00084     _pStageValidator(NULL ),
00085 
00086     _bFrustumCulling(true ),
00087     _bVolumeDrawing (false),
00088     _bAutoFrustum   (true ),
00089     _oFrustum       (     )
00090 {
00091     _pStageValidator = new StageValidator();
00092 }

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

Definition at line 94 of file OSGRenderTraversalActionBase.cpp.

References _pStageValidator, _pStatistics, and OSG::setRefd().

00095                                              :
00096 
00097      Inherited      (source                 ),
00098     _pCamera        (source._pCamera        ),
00099     _pBackground    (source._pBackground    ),
00100     _pWindow        (source._pWindow        ),
00101     _pViewport      (source._pViewport      ),
00102     _pStageValidator(NULL                   ),
00103     _pStatistics    (NULL                   ),
00104     _bFrustumCulling(source._bFrustumCulling),
00105     _bVolumeDrawing (source._bVolumeDrawing ),
00106     _bAutoFrustum   (source._bAutoFrustum   ),
00107     _oFrustum       (source._oFrustum       )
00108 {
00109     OSG::setRefd(_pStatistics, source._pStatistics);
00110 
00111     _pStageValidator = new StageValidator();
00112 }


Member Function Documentation

Viewport * OSG::RenderTraversalActionBase::getViewport ( void   )  const [inline]

void RenderTraversalActionBase::setViewport ( Viewport pViewport  ) 

Definition at line 171 of file OSGRenderTraversalActionBase.cpp.

References _pViewport.

00172 {
00173     _pViewport = pViewport;
00174 }

Camera * OSG::RenderTraversalActionBase::getCamera ( void   )  const [inline]

Definition at line 83 of file OSGRenderTraversalActionBase.inl.

References _pCamera.

Referenced by OSG::ScreenLOD::renderEnter(), and start().

00084 {
00085     return _pCamera;
00086 }

void RenderTraversalActionBase::setCamera ( Camera pCamera  ) 

Definition at line 176 of file OSGRenderTraversalActionBase.cpp.

References _pCamera.

00177 {
00178     _pCamera = pCamera;
00179 }

Background * OSG::RenderTraversalActionBase::getBackground ( void   )  const [inline]

Definition at line 89 of file OSGRenderTraversalActionBase.inl.

References _pBackground.

Referenced by OSG::SimpleShadowMapEngine::doLightPass().

00090 {
00091     return _pBackground;
00092 }

void RenderTraversalActionBase::setBackground ( Background pBackground  ) 

Definition at line 181 of file OSGRenderTraversalActionBase.cpp.

References _pBackground.

00182 {
00183     _pBackground = pBackground;
00184 }

Window * OSG::RenderTraversalActionBase::getWindow ( void   )  const [inline]

Definition at line 95 of file OSGRenderTraversalActionBase.inl.

References _pWindow.

Referenced by OSG::SimpleShadowMapEngine::doLightPass(), and OSG::StageHandlerMixin< ParentT >::validate().

00096 {
00097     return _pWindow;
00098 }

void RenderTraversalActionBase::setWindow ( Window pWindow  ) 

Definition at line 186 of file OSGRenderTraversalActionBase.cpp.

References _pWindow.

00187 {
00188     _pWindow = pWindow;
00189 }

StatCollector * OSG::RenderTraversalActionBase::getStatCollector ( void   )  const [inline]

Definition at line 131 of file OSGRenderTraversalActionBase.inl.

References _pStatistics.

00132 {
00133     return _pStatistics;
00134 }

void RenderTraversalActionBase::setStatCollector ( StatCollector pStat  ) 

Definition at line 191 of file OSGRenderTraversalActionBase.cpp.

References _pStatistics, and OSG::setRefd().

00192 {
00193     OSG::setRefd(_pStatistics, pStatistics);
00194 }

bool OSG::RenderTraversalActionBase::getFrustumCulling ( void   )  const [inline, virtual]

Reimplemented in OSG::RenderTraversalAction.

Definition at line 107 of file OSGRenderTraversalActionBase.inl.

References _bFrustumCulling.

00108 {
00109     return _bFrustumCulling;
00110 }

void RenderTraversalActionBase::setFrustumCulling ( bool  val = true  )  [virtual]

Reimplemented in OSG::RenderTraversalAction.

Definition at line 200 of file OSGRenderTraversalActionBase.cpp.

References _bFrustumCulling.

00201 {
00202     _bFrustumCulling = val;
00203 }

bool OSG::RenderTraversalActionBase::getVolumeDrawing ( void   )  const [inline, virtual]

Definition at line 113 of file OSGRenderTraversalActionBase.inl.

References _bVolumeDrawing.

00114 {
00115     return _bVolumeDrawing;
00116 }

void RenderTraversalActionBase::setVolumeDrawing ( bool  val = false  )  [virtual]

Definition at line 216 of file OSGRenderTraversalActionBase.cpp.

References _bVolumeDrawing.

00217 {
00218     _bVolumeDrawing = val;
00219 }

bool OSG::RenderTraversalActionBase::getAutoFrustum ( void   )  const [inline]

Definition at line 119 of file OSGRenderTraversalActionBase.inl.

References _bAutoFrustum.

00120 {
00121     return _bAutoFrustum;
00122 }

void RenderTraversalActionBase::setAutoFrustum ( bool  val = true  ) 

Definition at line 208 of file OSGRenderTraversalActionBase.cpp.

References _bAutoFrustum.

00209 {
00210     _bAutoFrustum = val;
00211 }

const FrustumVolume & OSG::RenderTraversalActionBase::getFrustum ( void   )  const [inline, virtual]

Reimplemented in OSG::RenderTraversalAction.

Definition at line 125 of file OSGRenderTraversalActionBase.inl.

References _oFrustum.

00126 {
00127     return _oFrustum;
00128 }

void RenderTraversalActionBase::setFrustum ( FrustumVolume frust  )  [virtual]

Reimplemented in OSG::RenderTraversalAction.

Definition at line 223 of file OSGRenderTraversalActionBase.cpp.

References _oFrustum.

00224 {
00225     _oFrustum = oFrustum;
00226 }

virtual bool OSG::RenderTraversalActionBase::isVisible ( Node node  )  [pure virtual]

Implemented in OSG::RenderTraversalAction.

ActionBase::ResultE RenderTraversalActionBase::start ( void   )  [virtual]

Reimplemented from OSG::Action.

Reimplemented in OSG::RenderTraversalAction.

Definition at line 124 of file OSGRenderTraversalActionBase.cpp.

References _bAutoFrustum, _bFrustumCulling, _oFrustum, _pStageValidator, _pStatistics, OSG::ActionBase::Continue, getCamera(), OSG::StatCollector::getElem(), OSG::Camera::getFrustum(), getViewport(), OSG::StageValidator::incEventCounter(), OSG::StatCollector::reset(), OSG::Drawable::statNLines, OSG::Drawable::statNPoints, OSG::Drawable::statNPrimitives, OSG::Drawable::statNTriangles, OSG::Drawable::statNVertices, and statTravTime.

00125 {
00126     if(_bFrustumCulling   == true &&
00127        _bAutoFrustum      == true &&
00128         getCamera      () != NULL &&
00129         getViewport    () != NULL)
00130     {
00131         getCamera()->getFrustum(_oFrustum, *getViewport());
00132     }
00133 
00134     if(_pStatistics != NULL)
00135     {
00136         _pStatistics->reset();
00137 
00138 
00139         _pStatistics->getElem(statTravTime       )->start();
00140 //    getStatistics()->getElem(statCullTestedNodes)->reset();
00141 //    getStatistics()->getElem(statCulledNodes    )->reset();
00142     //getStatistics()->getElem(RenderTraversalAction::statNTextures)->reset();
00143     //getStatistics()->getElem(RenderTraversalAction::statNTexBytes)->reset();
00144 
00145     // this really doesn't belong here, but don't know a better place to put it
00146         if(_pStatistics->getElem(Drawable::statNTriangles,false) != NULL)
00147         {
00148             _pStatistics->getElem(Drawable::statNTriangles )->set(0);
00149             _pStatistics->getElem(Drawable::statNLines     )->set(0);
00150             _pStatistics->getElem(Drawable::statNPoints    )->set(0);
00151             _pStatistics->getElem(Drawable::statNVertices  )->set(0);
00152             _pStatistics->getElem(Drawable::statNPrimitives)->set(0);
00153         }
00154     }
00155 
00156     _pStageValidator->incEventCounter();
00157 
00158     return Action::Continue;
00159 }

ActionBase::ResultE RenderTraversalActionBase::stop ( ActionBase::ResultE  res  )  [virtual]

Reimplemented from OSG::Action.

Reimplemented in OSG::RenderTraversalAction.

Definition at line 161 of file OSGRenderTraversalActionBase.cpp.

References _pStatistics, OSG::StatCollector::getElem(), and statTravTime.

00162 {
00163     if(_pStatistics != NULL)
00164     {
00165         _pStatistics->getElem(statTravTime)->stop();
00166     }
00167 
00168     return res;
00169 }

StageValidator * OSG::RenderTraversalActionBase::getStageValidator ( void   )  [inline]

Definition at line 137 of file OSGRenderTraversalActionBase.inl.

References _pStageValidator.

Referenced by OSG::StageHandlerMixin< ParentT >::validate().

00138 {
00139     return _pStageValidator;
00140 }

virtual void OSG::RenderTraversalActionBase::pushPartition ( UInt32  uiCopyOnPush,
RenderPartitionBase::Mode  eMode 
) [pure virtual]

virtual void OSG::RenderTraversalActionBase::popPartition ( void   )  [pure virtual]

virtual void OSG::RenderTraversalActionBase::beginPartitionGroup ( void   )  [pure virtual]

virtual void OSG::RenderTraversalActionBase::endPartitionGroup ( void   )  [pure virtual]

virtual Int32 OSG::RenderTraversalActionBase::getActivePartitionIdx ( void   )  [pure virtual]

virtual Int32 OSG::RenderTraversalActionBase::getLastPartitionIdx ( void   )  [pure virtual]

virtual void OSG::RenderTraversalActionBase::readdPartitionByIndex ( UInt32  uiPartIdx  )  [pure virtual]

void OSG::RenderTraversalActionBase::operator= ( const RenderTraversalActionBase source  )  [private]

ValuePtr OSG::DataSlotMixin< MixinHead< RenderTravDataSlotDesc > >::getData ( Int32  iSlotId  )  [inline, inherited]

void OSG::DataSlotMixin< MixinHead< RenderTravDataSlotDesc > >::setDataX ( FieldBundleP  pBundle,
Int32  iSlotId 
) [inherited]

Action * Action::create ( void   )  [static, inherited]

Reimplemented in OSG::RenderTraversalAction, OSG::VRMLWriteAction, OSG::RenderAction, and OSG::IntersectAction.

Definition at line 183 of file OSGAction.cpp.

References OSG::Action::_prototype, and OSG::Action::Action().

00184 {
00185     Action *act;
00186     
00187     if(_prototype)
00188     {
00189         act = new Action(*_prototype);
00190     }
00191     else
00192     {
00193         act = new Action();
00194     }
00195 
00196     return act;
00197 }

void Action::setPrototype ( Action proto  )  [static, inherited]

Definition at line 125 of file OSGAction.cpp.

References OSG::Action::_prototype.

00126 {
00127     _prototype = proto;
00128 }

Action * Action::getPrototype ( void   )  [static, inherited]

Reimplemented in OSG::RenderTraversalAction, OSG::VRMLWriteAction, OSG::RenderAction, and OSG::IntersectAction.

Definition at line 130 of file OSGAction.cpp.

References OSG::Action::_prototype.

00131 {
00132     return _prototype;
00133 }

void Action::registerEnterDefault ( const FieldContainerType type,
const Functor func 
) [static, inherited]

Reimplemented in OSG::RenderTraversalAction, OSG::RenderAction, and OSG::IntersectAction.

Definition at line 83 of file OSGAction.cpp.

References OSG::Action::_defaultEnterFunction(), OSG::Action::_defaultEnterFunctors, and OSG::TypeBase::getId().

00085 {
00086     if(_defaultEnterFunctors == NULL)
00087         _defaultEnterFunctors = new std::vector<Action::Functor>;
00088 
00089 #ifndef OSG_WINCE
00090     while(type.getId() >= _defaultEnterFunctors->size())
00091     {
00092         _defaultEnterFunctors->push_back(&Action::_defaultEnterFunction);
00093     }
00094 #else
00095     while(type.getId() >= _defaultEnterFunctors->size())
00096     {
00097         _defaultEnterFunctors->push_back(&NodeCore::defaultEnter);
00098     }
00099 #endif
00100     
00101     (*_defaultEnterFunctors)[type.getId()] = func;
00102 }

void Action::registerLeaveDefault ( const FieldContainerType type,
const Functor func 
) [static, inherited]

Reimplemented in OSG::RenderTraversalAction, OSG::RenderAction, and OSG::IntersectAction.

Definition at line 104 of file OSGAction.cpp.

References OSG::Action::_defaultLeaveFunction(), OSG::Action::_defaultLeaveFunctors, and OSG::TypeBase::getId().

00106 {
00107     if(_defaultLeaveFunctors == NULL)
00108         _defaultLeaveFunctors = new std::vector<Action::Functor>;
00109 
00110 #ifndef OSG_WINCE
00111     while(type.getId() >= _defaultLeaveFunctors->size())
00112     {
00113         _defaultLeaveFunctors->push_back(&Action::_defaultLeaveFunction);
00114     }
00115 #else
00116     while(type.getId() >= _defaultLeaveFunctors->size())
00117     {
00118         _defaultLeaveFunctors->push_back(&NodeCore::defaultLeave);
00119     }
00120 #endif
00121     
00122     (*_defaultLeaveFunctors)[type.getId()] = func;
00123 }

void Action::registerEnterFunction ( const FieldContainerType type,
const Functor func 
) [inherited]

Definition at line 212 of file OSGAction.cpp.

References OSG::Action::_defaultEnterFunction(), OSG::Action::_enterFunctors, and OSG::TypeBase::getId().

00214 {
00215 #ifndef OSG_WINCE
00216     while(type.getId() >= _enterFunctors.size())
00217     {
00218         _enterFunctors.push_back(&Action::_defaultEnterFunction);
00219     }
00220 #else
00221     while(type.getId() >= _enterFunctors.size())
00222     {
00223         _enterFunctors.push_back(&NodeCore::defaultEnter);
00224     }
00225 #endif
00226     
00227     _enterFunctors[type.getId()] = func;
00228 }

void Action::registerLeaveFunction ( const FieldContainerType type,
const Functor func 
) [inherited]

Definition at line 230 of file OSGAction.cpp.

References OSG::Action::_defaultLeaveFunction(), OSG::Action::_leaveFunctors, and OSG::TypeBase::getId().

00232 {
00233 #ifndef OSG_WINCE
00234     while(type.getId() >= _leaveFunctors.size())
00235     {
00236         _leaveFunctors.push_back(&Action::_defaultLeaveFunction);
00237     }
00238 #else
00239     while(type.getId() >= _leaveFunctors.size())
00240     {
00241         _leaveFunctors.push_back(&NodeCore::defaultLeave);
00242     }
00243 #endif
00244     
00245     _leaveFunctors[type.getId()] = func;
00246 }

ActionBase::ResultE Action::apply ( std::vector< NodePtr >::iterator  begin,
std::vector< NodePtr >::iterator  end 
) [virtual, inherited]