fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / Action / RenderAction / OSGRenderPartition.inl
blob87f56002a1b99878e80a713a9d616adeff26dc02
1 /*---------------------------------------------------------------------------*\
2  *                                OpenSG                                     *
3  *                                                                           *
4  *                                                                           *
5  *             Copyright (C) 2000-2002 by the OpenSG Forum                   *
6  *                                                                           *
7  *                            www.opensg.org                                 *
8  *                                                                           *
9  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
10  *                                                                           *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13  *                                License                                    *
14  *                                                                           *
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.                               *
18  *                                                                           *
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.                          *
23  *                                                                           *
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.                 *
27  *                                                                           *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30  *                                Changes                                    *
31  *                                                                           *
32  *                                                                           *
33  *                                                                           *
34  *                                                                           *
35  *                                                                           *
36  *                                                                           *
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
40 //  Includes
41 //---------------------------------------------------------------------------
43 OSG_BEGIN_NAMESPACE
45 /***************************************************************************\
46  *                               Types                                     *
47 \***************************************************************************/
50 /***************************************************************************\
51  *                           Class variables                               *
52 \***************************************************************************/
55 /***************************************************************************\
56  *                           Class methods                                 *
57 \***************************************************************************/
60 /*-------------------------------------------------------------------------*\
61  -  public                                                                 -
62 \*-------------------------------------------------------------------------*/
64 /*-------------------------------------------------------------------------*\
65  -  protected                                                              -
66 \*-------------------------------------------------------------------------*/
69 /*-------------------------------------------------------------------------*\
70  -  private                                                                -
71 \*-------------------------------------------------------------------------*/
74 /***************************************************************************\
75  *                           Instance methods                              *
76 \***************************************************************************/
78 /*-------------------------------------------------------------------------*\
79  -  public                                                                 -
80 \*-------------------------------------------------------------------------*/
82 inline
83 void RenderPartition::setAction(RenderAction *pAction)
85     _oDrawEnv.setAction(pAction);
88 inline
89 void RenderPartition::setNodePool(RenderTreeNodePool *pNodePool)
91     _pNodePool = pNodePool;
94 inline
95 void RenderPartition::setStatePool(StateOverridePool *pStatePool)
97     _pStatePool = pStatePool;
100 inline 
101 void RenderPartition::setTreeBuilderPool(TreeBuilderPool *pTreeBuilderPool)
103     _pTreeBuilderPool = pTreeBuilderPool;
106 inline
107 void RenderPartition::setStatCollector(StatCollectorP pStatCollector)
109     _oDrawEnv.setStatCollector(pStatCollector);
112 inline
113 StatCollectorP RenderPartition::getStatCollector(void)
115     return _oDrawEnv.getStatCollector();
118 inline
119 void RenderPartition::setWindow(Window *pWindow)
121     _oDrawEnv.setWindow(pWindow);
124 inline
125 Window *RenderPartition::getWindow(void)
127     return _oDrawEnv.getWindow();
130 inline
131 void RenderPartition::setBackground(Background *pBackground)
133     _pBackground = pBackground;
136 inline
137 void RenderPartition::pushToForegrounds(Foreground *pForeground)
139     _vpForegrounds.push_back(pForeground);
142 inline
143 void RenderPartition::clearForegrounds(void)
145     _vpForegrounds.clear();
148 inline
149 void RenderPartition::setupProjection(const Matrix4f &projection,
150                                       const Matrix4f &translation)
152     _oDrawEnv.setupProjection(projection, translation);
155 inline
156 const Matrix4f &RenderPartition::getFullProjection(void)
158     return _oDrawEnv._openGLState.getProjection();
161 inline
162 const Matrix4f &RenderPartition::getProjection(void)
164     return _oDrawEnv.getCameraProjection();
167 inline
168 const Matrix4f &RenderPartition::getProjectionTrans(void)
170     return _oDrawEnv.getCameraProjectionTrans();
173 inline
174 const Matrix4f &RenderPartition::getVPFullProjection(void)
176     return _oDrawEnv.getVPCameraFullProjection();
179 inline
180 const Matrix4f &RenderPartition::getVPProjection(void)
182     return _oDrawEnv.getVPCameraProjection();
185 inline
186 const Matrix4f &RenderPartition::getVPProjectionTrans(void)
188     return _oDrawEnv.getVPCameraProjectionTrans();
191 inline
192 void RenderPartition::setupViewing(const Matrix4f &matrix)
194     _oDrawEnv.setupViewing(matrix);
196 #ifndef OSG_ENABLE_DOUBLE_MATRIX_STACK
197     _modelViewMatrix.second = matrix;
198 #else
199     Matrix4d temp;
200     temp.convertFrom(matrix);
201     _modelViewMatrix.second = temp;
202 #endif
204     _modelMatrix.setIdentity();
205     _modelMatrixValid = true;
208 inline 
209 const Matrix4f &RenderPartition::getViewing(void)
211     return _oDrawEnv.getCameraViewing();
214 inline
215 const Matrix4f &RenderPartition::getCameraToWorld(void)
217     return _oDrawEnv.getCameraToWorld();
220 inline 
221 const Matrix4f &RenderPartition::getVPViewing(void)
223     return _oDrawEnv.getVPCameraViewing();
226 inline
227 const Matrix4f &RenderPartition::getVPCameraToWorld(void)
229     return _oDrawEnv.getCameraToWorld();
232 inline
233 void RenderPartition::addPartition(RenderPartition *pPart)
235     _vGroupStore.push_back(pPart);
238 inline
239 DrawEnv &RenderPartition::getDrawEnv(void)
241     return _oDrawEnv;
244 inline UInt32
245 RenderPartition::getKeyGen(void) const
247     return _uiKeyGen;
250 inline 
251 void RenderPartition::setNear(Real32 camNear)
253     _oDrawEnv.setCameraNear(camNear);
256 inline 
257 void RenderPartition::setFar (Real32 camFar)
259     _oDrawEnv.setCameraFar(camFar);
262 inline 
263 Real32 RenderPartition::getNear(void)
265     return _oDrawEnv.getCameraNear();
268 inline 
269 Real32 RenderPartition::getFar(void)
271     return _oDrawEnv.getCameraFar();
274 /*------------- constructors & destructors --------------------------------*/
276 /*------------------------------ access -----------------------------------*/
278 /*---------------------------- properties ---------------------------------*/
280 inline
281 void RenderPartition::setViewportDimension(Int32 iPixelLeft,
282                                            Int32 iPixelBottom,
283                                            Int32 iPixelRight,
284                                            Int32 iPixelTop,
285                                            bool  bFull       )
287     _oDrawEnv.setViewportDimension(iPixelLeft,
288                                    iPixelBottom,
289                                    iPixelRight,
290                                    iPixelTop,
291                                    bFull);
294 inline
295 Int32 RenderPartition::getViewportWidth(void)
297     return _oDrawEnv.getPixelWidth();
300 inline
301 Int32 RenderPartition::getViewportHeight(void)
303     return _oDrawEnv.getPixelHeight();
306 inline
307 void RenderPartition::setSetupMode(UInt32 uiSetupMode)
309     _uiSetupMode = uiSetupMode;
312 inline
313 void RenderPartition::addSetupModeBit(UInt32 uiSetupModeBit)
315     _uiSetupMode |= uiSetupModeBit;
318 inline
319 void RenderPartition::subSetupMode(UInt32 uiSetupModeBit)
321     _uiSetupMode &= ~uiSetupModeBit;
324 inline
325 void RenderPartition::disable(void)
327     _bDone = true;
330 template<class MatrixType> inline
331 void RenderPartition::pushMatrix(const MatrixType &matrix)
333     _modelViewMatrixStack.push_back(_modelViewMatrix);
334     
335     _modelViewMatrix.first = ++_uiMatrixId;
336     _modelViewMatrix.second.mult(matrix);
337    
338     _modelMatrixValid = false;
341 inline
342 const Matrix &RenderPartition::getModelMatrix(void) const
344     updateModelMatrix();
346     return _modelMatrix;
349 inline
350 const Matrix &RenderPartition::topMatrix(void)
352     return getModelMatrix();
355 inline 
356 const RenderPartition::MatrixT &
357     RenderPartition::getModelViewMatrix(void) const
359     return _modelViewMatrix.second;
362 inline const RenderPartition::MatrixStore &
363 RenderPartition::getMatrixStackTop(void) const
365     return _modelViewMatrix;
368 inline
369 void RenderPartition::dropFunctor(SimpleDrawCallback &oSimpleCallback)
371     _oSimpleDrawCallback = oSimpleCallback;
374 inline
375 void RenderPartition::popState(void)
377     _sStateOverrides.pop();
379 //    fprintf(stderr, "pop so size %d\n", _sStateOverrides.size());
382 inline
383 void RenderPartition::addOverride(UInt32 uiSlot, StateChunk *pChunk)
385     _sStateOverrides.top()->addOverride(uiSlot, pChunk);
388 inline
389 void RenderPartition::subOverride(UInt32 uiSlot, StateChunk *pChunk)
391     _sStateOverrides.top()->subOverride(uiSlot, pChunk);
394 inline
395 const StateOverride *RenderPartition::getCurrentOverrides(void) const
397     return _sStateOverrides.top();
400 inline
401 UInt32 RenderPartition::getLightState(void) const
403     return _uiLightState;
406 inline
407 void RenderPartition::setKeyGen(UInt32 uiKeyGen)
409     _uiKeyGen = uiKeyGen;
412 inline
413 Material *RenderPartition::getMaterial(void)
415     return _pMaterial;
418 inline
419 void RenderPartition::setRenderTarget(FrameBufferObject *pTarget)
421     _pRenderTarget = pTarget;
424 inline
425 FrameBufferObject *RenderPartition::getRenderTarget(void)
427     return _pRenderTarget;
430 inline
431 void RenderPartition::setDrawBuffer(GLenum eBuffer)
433     _eDrawBuffer = eBuffer;
436 inline
437 bool RenderPartition::getFrustumCulling(void) const
439     return _bFrustumCulling;
442 inline
443 void RenderPartition::setFrustumCulling(bool val)
445     _bFrustumCulling = val;
447     
448 inline
449 bool RenderPartition::getVolumeDrawing(void) const
451     return _bVolumeDrawing;
454 inline
455 void RenderPartition::setVolumeDrawing(bool val)
457     _bVolumeDrawing = val;
459     
460 inline
461 const FrustumVolume &RenderPartition::getFrustum(void) const
463     return _oFrustum;
466 inline
467 void RenderPartition::setFrustum(FrustumVolume &frust)
469     _oFrustum = frust;
472 inline
473 void RenderPartition::addPreRenderCallback (const RenderFunctor &oCallback)
475     _vPreRenderCallbacks.push_back(oCallback);
478 inline
479 void RenderPartition::addPostRenderCallback(const RenderFunctor &oCallback)
481     _vPostRenderCallbacks.push_back(oCallback);
484 /*-------------------------- your_category---------------------------------*/
486 #ifdef OSG_DEBUG
487 inline
488 void RenderPartition::setDebugString(std::string szDebugString)
490     _szDebugString = szDebugString;
492 #endif
494 /*-------------------------- assignment -----------------------------------*/
496 /*-------------------------- comparison -----------------------------------*/
498 /*-------------------------------------------------------------------------*\
499  -  protected                                                              -
500 \*-------------------------------------------------------------------------*/
502 inline
503 void  RenderPartition::setNode(Node *pNode)
505     _pNode = pNode;
508 inline
509 Node *RenderPartition::getNode(void)
511     return _pNode;
514 /*-------------------------------------------------------------------------*\
515  -  private                                                                -
516 \*-------------------------------------------------------------------------*/
518 OSG_END_NAMESPACE