OSGDrawEnv.inl
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 OSG_BEGIN_NAMESPACE
00041
00042 inline
00043 void DrawEnv::setAction(RAction *pAction)
00044 {
00045 _pRenderAction = pAction;
00046 }
00047
00048 inline
00049 void DrawEnv::setWindow(Window *pWindow)
00050 {
00051 _pWindow = pWindow;
00052 }
00053
00054 inline
00055 void DrawEnv::setupProjection(const Matrixr &projection,
00056 const Matrixr &translation)
00057 {
00058 _cameraProjection = projection;
00059 _cameraProjectionTrans = translation;
00060
00061 _cameraFullProjection = projection;
00062 _cameraFullProjection.mult(translation);
00063 }
00064
00065 inline
00066 void DrawEnv::setupViewing(const Matrixr &matrix)
00067 {
00068 _cameraViewing = matrix;
00069 _cameraToWorld.invertFrom(matrix);
00070 _worldToScreen.setValue(_cameraProjection);
00071 _worldToScreen.mult(_cameraProjectionTrans);
00072 _worldToScreen.mult(_cameraViewing);
00073 }
00074
00075 inline
00076 void DrawEnv::setObjectToWorld(const Matrixr &matrix)
00077 {
00078 _objectToWorld = matrix;
00079 }
00080
00081 inline
00082 void DrawEnv::setCameraNear(const Real &camNear)
00083 {
00084 _cameraNear = camNear;
00085 }
00086
00087 inline
00088 void DrawEnv::setCameraFar(const Real &camFar)
00089 {
00090 _cameraFar = camFar;
00091 }
00092
00093 inline
00094 void DrawEnv::setActiveTexTarget(UInt32 uiSlot,
00095 GLenum uiTarget)
00096 {
00097 _aActiveTexTargets[uiSlot] = uiTarget;
00098 }
00099
00100 inline
00101 void DrawEnv::setActiveShader(UInt32 uiActiveShader)
00102 {
00103 _uiActiveShader = uiActiveShader;
00104 }
00105
00106 inline
00107 UInt32 DrawEnv::getActiveShader(void)
00108 {
00109 return _uiActiveShader;
00110 }
00111
00112 inline
00113 const Matrixr &DrawEnv::getWorldToScreen(void) const
00114 {
00115 return _worldToScreen;
00116 }
00117
00118 inline
00119 const Matrixr &DrawEnv::getCameraFullProjection(void) const
00120 {
00121 return _cameraFullProjection;
00122 }
00123
00124 inline
00125 const Matrixr &DrawEnv::getCameraProjection(void) const
00126 {
00127 return _cameraProjection;
00128 }
00129
00130 inline
00131 const Matrixr &DrawEnv::getCameraProjectionTrans(void) const
00132 {
00133 return _cameraProjectionTrans;
00134 }
00135
00136 inline
00137 const Matrixr &DrawEnv::getCameraDecoration(void) const
00138 {
00139 return _cameraDecoration;
00140 }
00141
00142
00143 inline
00144 const Matrixr &DrawEnv::getCameraViewing(void) const
00145 {
00146 return _cameraViewing;
00147 }
00148
00149 inline
00150 const Matrixr &DrawEnv::getCameraToWorld(void) const
00151 {
00152 return _cameraToWorld;
00153 }
00154
00155 inline
00156 const Matrixr &DrawEnv::getObjectToWorld(void) const
00157 {
00158 return _objectToWorld;
00159 }
00160
00161 inline
00162 Real DrawEnv::getCameraNear(void) const
00163 {
00164 return _cameraNear;
00165 }
00166
00167 inline
00168 Real DrawEnv::getCameraFar(void) const
00169 {
00170 return _cameraFar;
00171 }
00172
00173 inline
00174 DrawEnv::RAction *DrawEnv::getAction(void) const
00175 {
00176 return _pRenderAction;
00177 }
00178
00179 inline
00180 Window *DrawEnv::getWindow(void) const
00181 {
00182 return _pWindow;
00183 }
00184
00185 inline
00186 GLenum DrawEnv::getActiveTexTarget(UInt32 uiSlot) const
00187 {
00188 return _aActiveTexTargets[uiSlot];
00189 }
00190
00191 inline
00192 const Matrixr &DrawEnv::getVPCameraFullProjection(void) const
00193 {
00194 return _vpCameraFullProjection;
00195 }
00196
00197 inline
00198 const Matrixr &DrawEnv::getVPCameraProjection(void) const
00199 {
00200 return _vpCameraProjection;
00201 }
00202
00203
00204 inline
00205 const Matrixr &DrawEnv::getVPCameraProjectionTrans(void) const
00206 {
00207 return _vpCameraProjectionTrans;
00208 }
00209
00210
00211 inline
00212 const Matrixr &DrawEnv::getVPCameraViewing(void) const
00213 {
00214 return _vpCameraViewing;
00215 }
00216
00217 inline
00218 const Matrixr &DrawEnv::getVPCameraToWorld(void) const
00219 {
00220 return _vpCameraToWorld;
00221 }
00222
00223 inline
00224 const Matrixr &DrawEnv::getVPWorldToScreen(void) const
00225 {
00226 return _vpWorldToScreen;
00227 }
00228
00229 inline
00230 void DrawEnv::setVPCameraMatrices(const Matrixr &mFullprojection,
00231 const Matrixr &mProjection,
00232 const Matrixr &mProjectionTrans,
00233 const Matrixr &mViewing,
00234 const Matrixr &mToWorld,
00235 const Matrixr &mWorldToScreen )
00236 {
00237 _vpCameraFullProjection = mFullprojection;
00238 _vpCameraProjection = mProjection;
00239 _vpCameraProjectionTrans = mProjectionTrans;
00240 _vpCameraViewing = mViewing;
00241 _vpCameraToWorld = mToWorld;
00242 _vpWorldToScreen = mWorldToScreen;
00243 }
00244
00245
00246 inline
00247 void DrawEnv::initVPMatricesFromCamera(void)
00248 {
00249 _vpCameraFullProjection = _cameraFullProjection;
00250 _vpCameraProjection = _cameraProjection;
00251 _vpCameraProjectionTrans = _cameraProjectionTrans;
00252 _vpCameraViewing = _cameraViewing;
00253 _vpCameraToWorld = _cameraToWorld;
00254 _vpWorldToScreen = _worldToScreen;
00255 }
00256
00257 inline
00258 UInt32 DrawEnv::getNumStateChanges(void) const
00259 {
00260 return _uiNumStateChanges;
00261 }
00262
00263 inline
00264 UInt32 DrawEnv::getNumShaderChanges(void) const
00265 {
00266 return _uiNumShaderChanges;
00267 }
00268
00269 inline
00270 UInt32 DrawEnv::getNumShaderParamChanges(void) const
00271 {
00272 return _uiNumShaderParamChanges;
00273 }
00274
00275 inline
00276 void DrawEnv::incNumShaderChanges(void)
00277 {
00278 ++_uiNumShaderChanges;
00279 }
00280
00281 inline
00282 void DrawEnv::incNumShaderParamChanges(void)
00283 {
00284 ++_uiNumShaderParamChanges;
00285 }
00286
00287 inline
00288 void DrawEnv::setStatCollector(StatCollector *pStatCollector)
00289 {
00290 OSG::setRefd(_pStatCollector, pStatCollector);
00291 }
00292
00293 inline
00294 StatCollector* DrawEnv::getStatCollector(void)
00295 {
00296 return _pStatCollector;
00297 }
00298
00299 inline
00300 void DrawEnv::clearState(void)
00301 {
00302 _pActiveState = NULL;
00303 _pActiveStateOverride = NULL;
00304 _uiNumStateChanges = 0;
00305 _uiNumShaderChanges = 0;
00306 _uiNumShaderParamChanges = 0;
00307
00308
00309 _cameraDecoration .setIdentity();
00310
00311 _iPixelLeft = 0;
00312 _iPixelRight = 1;
00313 _iPixelBottom = 0;
00314 _iPixelTop = 1;
00315
00316 _bFull = true;
00317
00318 _uiLightState = 0;
00319 }
00320
00321 inline
00322 void DrawEnv::deactivateState(void)
00323 {
00324 if(_pActiveStateOverride != NULL)
00325 {
00326 deactivate(_pActiveState, _pActiveStateOverride);
00327 }
00328 else
00329 {
00330 deactivate(_pActiveState);
00331 }
00332
00333 _pActiveState = NULL;
00334 _pActiveStateOverride = NULL;
00335 }
00336
00337 inline
00338 void DrawEnv::activateState(State *pNewState,
00339 StateOverride *pNewStateOverride)
00340 {
00341 if(pNewState != NULL)
00342 {
00343 if(_pActiveState != NULL)
00344 {
00345 if(pNewState != _pActiveState ||
00346 pNewStateOverride != _pActiveStateOverride )
00347 {
00348 if(pNewStateOverride != NULL)
00349 {
00350 if(_pActiveStateOverride != NULL)
00351 {
00352 changeTo( pNewState, pNewStateOverride,
00353 _pActiveState, _pActiveStateOverride);
00354 }
00355 else
00356 {
00357 changeTo( pNewState, pNewStateOverride,
00358 _pActiveState );
00359 }
00360 }
00361 else if(_pActiveStateOverride != NULL)
00362 {
00363 changeTo(pNewState, _pActiveState, _pActiveStateOverride);
00364 }
00365 else
00366 {
00367 changeTo(pNewState, _pActiveState);
00368 }
00369
00370 _pActiveState = pNewState;
00371 _pActiveStateOverride = pNewStateOverride;
00372 }
00373 else
00374 {
00375 if(_pActiveStateOverride != NULL)
00376 {
00377 updateChunk(_pActiveState,
00378 _pActiveStateOverride);
00379 }
00380 else
00381 {
00382 updateChunk(_pActiveState);
00383 }
00384 }
00385 }
00386 else
00387 {
00388 if(pNewStateOverride != NULL)
00389 {
00390 activate(pNewState, pNewStateOverride);
00391 }
00392 else
00393 {
00394 activate(pNewState);
00395 }
00396
00397 _pActiveState = pNewState;
00398 _pActiveStateOverride = pNewStateOverride;
00399 }
00400 }
00401 }
00402
00403
00404 inline
00405 void DrawEnv::setViewportDimension (Int32 iPixelLeft,
00406 Int32 iPixelBottom,
00407 Int32 iPixelRight,
00408 Int32 iPixelTop,
00409 bool bFull )
00410 {
00411 _iPixelLeft = iPixelLeft;
00412 _iPixelRight = iPixelRight;
00413 _iPixelBottom = iPixelBottom;
00414 _iPixelTop = iPixelTop;
00415 _bFull = bFull;
00416 }
00417
00418 inline
00419 Int32 DrawEnv::getPixelLeft(void) const
00420 {
00421 return _iPixelLeft;
00422 }
00423
00424 inline
00425 Int32 DrawEnv::getPixelRight(void) const
00426 {
00427 return _iPixelRight;
00428 }
00429
00430 inline
00431 Int32 DrawEnv::getPixelBottom(void) const
00432 {
00433 return _iPixelBottom;
00434 }
00435
00436 inline
00437 Int32 DrawEnv::getPixelTop(void) const
00438 {
00439 return _iPixelTop;
00440 }
00441
00442 inline
00443 Int32 DrawEnv::getPixelWidth(void) const
00444 {
00445 return _iPixelRight - _iPixelLeft + 1;
00446 }
00447
00448 inline
00449 Int32 DrawEnv::getPixelHeight(void) const
00450 {
00451 return _iPixelTop - _iPixelBottom + 1;
00452 }
00453
00454 inline
00455 bool DrawEnv::getFull(void) const
00456 {
00457 return _bFull;
00458 }
00459
00460 inline
00461 void DrawEnv::setTileFullSize(const Vec2u &uiTileFullSize)
00462 {
00463 _uiTileFullSize = uiTileFullSize;
00464 }
00465
00466 inline
00467 void DrawEnv::setTileRegion(const Vec4f &vTileRegion)
00468 {
00469 _vTileRegion = vTileRegion;
00470 }
00471
00472 inline
00473 const Vec2u &DrawEnv::getTileFullSize(void) const
00474 {
00475 return _uiTileFullSize;
00476 }
00477
00478 inline
00479 const Vec4f &DrawEnv::getTileRegion(void) const
00480 {
00481 return _vTileRegion;
00482 }
00483
00484 inline
00485 void DrawEnv::setLightState(UInt32 uiState)
00486 {
00487 _uiLightState = uiState;
00488 }
00489
00490 inline
00491 UInt32 DrawEnv::getLightState(void)
00492 {
00493 return _uiLightState;
00494 }
00495
00496 template<class Action, class Result> inline
00497 Result DrawEnv::doGetData(Action *pAction, UInt32 iSlotId)
00498 {
00499 return pAction->template getData<Result>(iSlotId);
00500 }
00501
00502 template<class ValuePtr> inline
00503 ValuePtr DrawEnv::getData(Int32 iSlotId) const
00504 {
00505 OSG_ASSERT(_pRenderAction != NULL);
00506
00507 return doGetData<RenderActionBase, ValuePtr>(_pRenderAction, iSlotId);
00508 }
00509
00510 OSG_END_NAMESPACE