void RttManager::CDepthListener::preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt) { Hydrax *mHydrax = mRttManager->mHydrax; Ogre::SceneManager::MovableObjectIterator EntityIterator = mHydrax->getSceneManager()->getMovableObjectIterator("Entity"); Ogre::Entity* CurrentEntity; unsigned int k; mMaterials.empty(); while (EntityIterator.hasMoreElements()) { CurrentEntity = static_cast<Ogre::Entity*>(EntityIterator.peekNextValue()); for(k = 0; k < CurrentEntity->getNumSubEntities(); k++) { mMaterials.push(CurrentEntity->getSubEntity(k)->getMaterialName()); CurrentEntity->getSubEntity(k)->setMaterialName(mHydrax->getMaterialManager()->getMaterial(MaterialManager::MAT_DEPTH)->getName()); } EntityIterator.moveNext(); } if (Ogre::Math::Abs(mHydrax->getPosition().y - mHydrax->getCamera()->getDerivedPosition().y) > mHydrax->getPlanesError()) { if (mHydrax->_isCurrentFrameUnderwater()) { mRttManager->mPlanes[RTT_DEPTH]->normal = -mRttManager->mPlanes[RTT_DEPTH]->normal; mRttManager->mPlanes[RTT_DEPTH]->getParentNode()->translate(0,-mHydrax->getPlanesError(),0); } else { mRttManager->mPlanes[RTT_DEPTH]->getParentNode()->translate(0,mHydrax->getPlanesError(),0); mHydrax->getCamera()->enableCustomNearClipPlane(mRttManager->mPlanes[RTT_DEPTH]); } } if (mHydrax->_isCurrentFrameUnderwater()) { mHydrax->getMesh()->getEntity()->setVisible(true); mHydrax->getMesh()->getEntity()->setMaterialName( mHydrax->getMaterialManager()->getMaterial(MaterialManager::MAT_SIMPLE_RED)-> getName()); mHydrax->getMesh()->getEntity()->setRenderQueueGroup(Ogre::RENDER_QUEUE_SKIES_EARLY); mHydrax->getGodRaysManager()->setVisible(true); } else { mHydrax->getMesh()->getEntity()->setVisible(false); } }
void RttManager::CDepthReflectionListener::preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt) { Hydrax *mHydrax = mRttManager->mHydrax; mHydrax->getMesh()->getEntity()->setVisible(false); Ogre::SceneManager::MovableObjectIterator EntityIterator = mHydrax->getSceneManager()->getMovableObjectIterator("Entity"); Ogre::Entity* CurrentEntity; unsigned int k; mMaterials.empty(); while (EntityIterator.hasMoreElements()) { CurrentEntity = static_cast<Ogre::Entity*>(EntityIterator.peekNextValue()); for(k = 0; k < CurrentEntity->getNumSubEntities(); k++) { mMaterials.push(CurrentEntity->getSubEntity(k)->getMaterialName()); CurrentEntity->getSubEntity(k)->setMaterialName(mHydrax->getMaterialManager()->getMaterial(MaterialManager::MAT_DEPTH)->getName()); } EntityIterator.moveNext(); } mRttManager->mPlanes[RTT_DEPTH_REFLECTION]->getParentNode()->translate(0,-mHydrax->getPlanesError(),0); bool IsInUnderwaterError = false; if (mHydrax->getCamera()->getDerivedPosition().y > mRttManager->mPlanes[RTT_DEPTH_REFLECTION]->getParentNode()->getPosition().y) { mCameraPlaneDiff = 0; IsInUnderwaterError = true; } else { mCameraPlaneDiff = 0; } mHydrax->getCamera()->enableReflection(mRttManager->mPlanes[RTT_DEPTH_REFLECTION]); if (!IsInUnderwaterError) { mHydrax->getCamera()->enableCustomNearClipPlane(mRttManager->mPlanes[RTT_DEPTH_REFLECTION]); } }