1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 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 //---------------------------------------------------------------------------
41 //---------------------------------------------------------------------------
45 /***************************************************************************\
47 \***************************************************************************/
50 /***************************************************************************\
52 \***************************************************************************/
55 /***************************************************************************\
57 \***************************************************************************/
60 /*-------------------------------------------------------------------------*\
62 \*-------------------------------------------------------------------------*/
64 /*-------------------------------------------------------------------------*\
66 \*-------------------------------------------------------------------------*/
69 /*-------------------------------------------------------------------------*\
71 \*-------------------------------------------------------------------------*/
74 /***************************************************************************\
76 \***************************************************************************/
78 /*-------------------------------------------------------------------------*\
80 \*-------------------------------------------------------------------------*/
83 void RenderPartition::setAction(RenderAction *pAction)
85 _oDrawEnv.setAction(pAction);
89 void RenderPartition::setNodePool(RenderTreeNodePool *pNodePool)
91 _pNodePool = pNodePool;
95 void RenderPartition::setStatePool(StateOverridePool *pStatePool)
97 _pStatePool = pStatePool;
101 void RenderPartition::setTreeBuilderPool(TreeBuilderPool *pTreeBuilderPool)
103 _pTreeBuilderPool = pTreeBuilderPool;
107 void RenderPartition::setStatCollector(StatCollectorP pStatCollector)
109 _oDrawEnv.setStatCollector(pStatCollector);
113 StatCollectorP RenderPartition::getStatCollector(void)
115 return _oDrawEnv.getStatCollector();
119 void RenderPartition::setWindow(Window *pWindow)
121 _oDrawEnv.setWindow(pWindow);
125 Window *RenderPartition::getWindow(void)
127 return _oDrawEnv.getWindow();
131 void RenderPartition::setBackground(Background *pBackground)
133 _pBackground = pBackground;
137 void RenderPartition::pushToForegrounds(Foreground *pForeground)
139 _vpForegrounds.push_back(pForeground);
143 void RenderPartition::clearForegrounds(void)
145 _vpForegrounds.clear();
149 void RenderPartition::setupProjection(const Matrix4f &projection,
150 const Matrix4f &translation)
152 _oDrawEnv.setupProjection(projection, translation);
156 const Matrix4f &RenderPartition::getFullProjection(void)
158 return _oDrawEnv._openGLState.getProjection();
162 const Matrix4f &RenderPartition::getProjection(void)
164 return _oDrawEnv.getCameraProjection();
168 const Matrix4f &RenderPartition::getProjectionTrans(void)
170 return _oDrawEnv.getCameraProjectionTrans();
174 const Matrix4f &RenderPartition::getVPFullProjection(void)
176 return _oDrawEnv.getVPCameraFullProjection();
180 const Matrix4f &RenderPartition::getVPProjection(void)
182 return _oDrawEnv.getVPCameraProjection();
186 const Matrix4f &RenderPartition::getVPProjectionTrans(void)
188 return _oDrawEnv.getVPCameraProjectionTrans();
192 void RenderPartition::setupViewing(const Matrix4f &matrix)
194 _oDrawEnv.setupViewing(matrix);
196 #ifndef OSG_ENABLE_DOUBLE_MATRIX_STACK
197 _modelViewMatrix.second = matrix;
200 temp.convertFrom(matrix);
201 _modelViewMatrix.second = temp;
204 _modelMatrix.setIdentity();
205 _modelMatrixValid = true;
209 const Matrix4f &RenderPartition::getViewing(void)
211 return _oDrawEnv.getCameraViewing();
215 const Matrix4f &RenderPartition::getCameraToWorld(void)
217 return _oDrawEnv.getCameraToWorld();
221 const Matrix4f &RenderPartition::getVPViewing(void)
223 return _oDrawEnv.getVPCameraViewing();
227 const Matrix4f &RenderPartition::getVPCameraToWorld(void)
229 return _oDrawEnv.getCameraToWorld();
233 void RenderPartition::addPartition(RenderPartition *pPart)
235 _vGroupStore.push_back(pPart);
239 DrawEnv &RenderPartition::getDrawEnv(void)
245 RenderPartition::getKeyGen(void) const
251 void RenderPartition::setNear(Real32 camNear)
253 _oDrawEnv.setCameraNear(camNear);
257 void RenderPartition::setFar (Real32 camFar)
259 _oDrawEnv.setCameraFar(camFar);
263 Real32 RenderPartition::getNear(void)
265 return _oDrawEnv.getCameraNear();
269 Real32 RenderPartition::getFar(void)
271 return _oDrawEnv.getCameraFar();
274 /*------------- constructors & destructors --------------------------------*/
276 /*------------------------------ access -----------------------------------*/
278 /*---------------------------- properties ---------------------------------*/
281 void RenderPartition::setViewportDimension(Int32 iPixelLeft,
287 _oDrawEnv.setViewportDimension(iPixelLeft,
295 Int32 RenderPartition::getViewportWidth(void)
297 return _oDrawEnv.getPixelWidth();
301 Int32 RenderPartition::getViewportHeight(void)
303 return _oDrawEnv.getPixelHeight();
307 void RenderPartition::setSetupMode(UInt32 uiSetupMode)
309 _uiSetupMode = uiSetupMode;
313 void RenderPartition::addSetupModeBit(UInt32 uiSetupModeBit)
315 _uiSetupMode |= uiSetupModeBit;
319 void RenderPartition::subSetupMode(UInt32 uiSetupModeBit)
321 _uiSetupMode &= ~uiSetupModeBit;
325 void RenderPartition::disable(void)
330 template<class MatrixType> inline
331 void RenderPartition::pushMatrix(const MatrixType &matrix)
333 _modelViewMatrixStack.push_back(_modelViewMatrix);
335 _modelViewMatrix.first = ++_uiMatrixId;
336 _modelViewMatrix.second.mult(matrix);
338 _modelMatrixValid = false;
342 const Matrix &RenderPartition::getModelMatrix(void) const
350 const Matrix &RenderPartition::topMatrix(void)
352 return getModelMatrix();
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;
369 void RenderPartition::dropFunctor(SimpleDrawCallback &oSimpleCallback)
371 _oSimpleDrawCallback = oSimpleCallback;
375 void RenderPartition::popState(void)
377 _sStateOverrides.pop();
379 // fprintf(stderr, "pop so size %d\n", _sStateOverrides.size());
383 void RenderPartition::addOverride(UInt32 uiSlot, StateChunk *pChunk)
385 _sStateOverrides.top()->addOverride(uiSlot, pChunk);
389 void RenderPartition::subOverride(UInt32 uiSlot, StateChunk *pChunk)
391 _sStateOverrides.top()->subOverride(uiSlot, pChunk);
395 const StateOverride *RenderPartition::getCurrentOverrides(void) const
397 return _sStateOverrides.top();
401 UInt32 RenderPartition::getLightState(void) const
403 return _uiLightState;
407 void RenderPartition::setKeyGen(UInt32 uiKeyGen)
409 _uiKeyGen = uiKeyGen;
413 Material *RenderPartition::getMaterial(void)
419 void RenderPartition::setRenderTarget(FrameBufferObject *pTarget)
421 _pRenderTarget = pTarget;
425 FrameBufferObject *RenderPartition::getRenderTarget(void)
427 return _pRenderTarget;
431 void RenderPartition::setDrawBuffer(GLenum eBuffer)
433 _eDrawBuffer = eBuffer;
437 bool RenderPartition::getFrustumCulling(void) const
439 return _bFrustumCulling;
443 void RenderPartition::setFrustumCulling(bool val)
445 _bFrustumCulling = val;
449 bool RenderPartition::getVolumeDrawing(void) const
451 return _bVolumeDrawing;
455 void RenderPartition::setVolumeDrawing(bool val)
457 _bVolumeDrawing = val;
461 const FrustumVolume &RenderPartition::getFrustum(void) const
467 void RenderPartition::setFrustum(FrustumVolume &frust)
473 void RenderPartition::addPreRenderCallback (const RenderFunctor &oCallback)
475 _vPreRenderCallbacks.push_back(oCallback);
479 void RenderPartition::addPostRenderCallback(const RenderFunctor &oCallback)
481 _vPostRenderCallbacks.push_back(oCallback);
484 /*-------------------------- your_category---------------------------------*/
488 void RenderPartition::setDebugString(std::string szDebugString)
490 _szDebugString = szDebugString;
494 /*-------------------------- assignment -----------------------------------*/
496 /*-------------------------- comparison -----------------------------------*/
498 /*-------------------------------------------------------------------------*\
500 \*-------------------------------------------------------------------------*/
503 void RenderPartition::setNode(Node *pNode)
509 Node *RenderPartition::getNode(void)
514 /*-------------------------------------------------------------------------*\
516 \*-------------------------------------------------------------------------*/