1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2003 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGRENDERACTIONBASE_H_
40 #define _OSGRENDERACTIONBASE_H_
45 #include "OSGBaseTypes.h"
46 #include "OSGAction.h"
47 #include "OSGStatElemTypes.h"
48 #include "OSGFrustumVolume.h"
50 #include "OSGMixinHead.h"
51 #include "OSGDataSlotMixin.h"
52 #include "OSGDataSlotPool.h"
54 #include "OSGRenderPartitionBase.h"
55 #include "OSGRenderPropertiesPool.h"
66 class TraversalValidator
;
68 template <class ParentT
>
69 class StageHandlerMixin
;
71 /*! \ingroup GrpSystemActionBase
72 \ingroup GrpLibOSGSystem
76 struct RenderDataSlotDesc
78 typedef Action ParentT
;
79 typedef MFUnrecFieldContainerPtr DataStore
;
81 typedef ActionDataSlotPool DataSlotIdPool
;
84 static void dumpElement(const FieldContainer
*pVal
)
86 fprintf(stderr
, "%p", static_cast<const void *>(pVal
));
90 fprintf(stderr
, " (%s)", pVal
->getType().getCName());
95 /*! \ingroup GrpSystemActionBase
98 typedef DataSlotMixin
<
100 RenderDataSlotDesc
> > RenderActionBaseParent
;
104 /*! \brief Base class using the render action interface of window
105 \ingroup GrpSystemActionBase
106 \ingroup GrpLibOSGSystem
109 class OSG_SYSTEM_DLLMAPPING RenderActionBase
: public RenderActionBaseParent
111 /*========================== PUBLIC =================================*/
115 typedef RenderActionBaseParent Inherited
;
116 typedef RenderPropertiesPool::Singleton::ValueType RenderPropType
;
118 static StatElemDesc
<StatTimeElem
> statTravTime
;
119 // static StatElemDesc<StatIntElem> statCullTestedNodes;
120 // static StatElemDesc<StatIntElem> statCulledNodes;
123 /*---------------------------------------------------------------------*/
124 /*! \name Rendering Environment */
127 Viewarea
*getViewarea (void ) const;
128 void setViewarea (Viewarea
*pViewarea
);
130 Node
*getTraversalRoot (void ) const;
131 void setTraversalRoot (Node
*pTravRoot
);
133 Camera
*getCamera (void ) const;
134 void setCamera (Camera
*pCamera
);
136 Background
*getBackground (void ) const;
137 void setBackground (Background
*pBackground
);
139 Window
*getWindow (void ) const;
140 void setWindow (Window
*pWindow
);
142 Material
*getGlobalOverride(void ) const;
143 void setGlobalOverride(Material
*pMat
);
146 /*---------------------------------------------------------------------*/
147 /*! \name Statistics */
150 StatCollector
*getStatCollector (void ) const;
151 void setStatCollector (StatCollector
*pStat
);
153 bool getResetStatistics(void ) const;
154 void setResetStatistics(bool value
);
157 /*---------------------------------------------------------------------*/
161 // control activation of frustum culling
162 virtual bool getFrustumCulling (void ) const;
163 virtual void setFrustumCulling (bool val
= true );
165 virtual bool getCorrectTwoSidedLighting(void ) const;
166 virtual void setCorrectTwoSidedLighting(bool val
= true );
168 // control drawing of checked volumes
169 virtual bool getVolumeDrawing (void ) const;
170 virtual void setVolumeDrawing (bool val
= false);
172 virtual bool getZWriteTrans (void ) const;
173 virtual void setZWriteTrans (bool val
= false);
175 // control automatic frustum calculation
176 bool getAutoFrustum (void ) const;
177 void setAutoFrustum (bool val
= true );
180 virtual const FrustumVolume
&getFrustum (void ) const;
181 virtual void setFrustum (FrustumVolume
&frust
);
184 /*----------- multi-frame buffering / split cull/draw -------------------*/
186 void setUseGLFinish(bool bVal
);
187 bool getUseGLFinish(void );
190 /*---------------------------------------------------------------------*/
194 virtual Action::ResultE
start (void );
195 virtual Action::ResultE
stop (Action::ResultE res
);
197 virtual void frameInit(void );
200 /*---------------------------------------------------------------------*/
204 TraversalValidator
*getTravValidator (void );
205 UInt16
getFrameTravCount(void );
207 void setDrawerId (Int32 iId
);
208 void setDrawableId (Int32 iId
);
211 /*---------------------------------------------------------------------*/
215 RenderPropType
getRenderProperties (void );
216 void setRenderProperties (RenderPropType oProp
);
217 void resetRenderProperties(void );
219 void addRenderProperties (RenderPropType oProp
);
220 void subRenderProperties (RenderPropType oProp
);
223 void setDrawPartPar (bool bVal
);
224 bool getDrawPartPar (void );
227 /*---------------------------------------------------------------------*/
232 virtual Int32
getActivePartitionIdx(void )= 0;
233 virtual Int32
getLastPartitionIdx (void )= 0;
235 virtual void readdPartitionByIndex(UInt32 uiPartIdx
)= 0;
238 /*========================= PROTECTED ===============================*/
242 template <class ParentT
>
243 friend class StageHandlerMixin
;
245 friend class Viewport
;
247 /*---------------------------------------------------------------------*/
248 /*! \name Constructors */
251 RenderActionBase(void);
252 RenderActionBase(const RenderActionBase
&source
);
255 /*---------------------------------------------------------------------*/
256 /*! \name Destructor */
259 virtual ~RenderActionBase(void);
262 /*---------------------------------------------------------------------*/
263 /*! \name Internal updates */
267 virtual void pushPartition (UInt32 uiCopyOnPush
,
268 RenderPartitionBase::Mode eMode
)= 0;
270 virtual void popPartition (void )= 0;
272 virtual void beginPartitionGroup (void )= 0;
273 virtual void endPartitionGroup (void )= 0;
276 /*---------------------------------------------------------------------*/
277 /*! \name Internal updates */
280 Int32
getDrawerId (void);
281 Int32
getDrawableId(void);
284 //-----------------------------------------------------------------------
285 // instance variables
286 //-----------------------------------------------------------------------
289 Background
*_pBackground
;
291 Viewarea
*_pViewarea
;
292 Node
*_pTraversalRoot
;
293 Material
*_pGlobalOverride
;
295 StatCollector
*_pStatistics
;
296 TraversalValidator
*_pTravValidator
;
298 bool _bResetStatistics
;
301 // frustum culling attributes
303 bool _bFrustumCulling
;
304 bool _bVolumeDrawing
;
307 bool _bCorrectTwoSidedLighting
;
309 FrustumVolume _oFrustum
;
311 UInt16 _uiFrameTravCount
;
316 RenderPropType _oCurrentRenderProp
;
319 /*========================== PRIVATE ================================*/
323 /*!\brief prohibit default function (move to 'public' if needed) */
324 void operator =(const RenderActionBase
&source
);
330 #include "OSGRenderActionBase.inl"
332 #endif /* _OSGRENDERACTIONBASE_H_ */