void RttManager::CDepthReflectionListener::postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt) { Hydrax *mHydrax = mRttManager->mHydrax; Ogre::SceneManager::MovableObjectIterator EntityIterator = mHydrax->getSceneManager()->getMovableObjectIterator("Entity"); Ogre::Entity* CurrentEntity; unsigned int k; while (EntityIterator.hasMoreElements()) { CurrentEntity = static_cast<Ogre::Entity*>(EntityIterator.peekNextValue()); for (k = 0; k < CurrentEntity->getNumSubEntities(); k++) { CurrentEntity->getSubEntity(k)->setMaterialName(mMaterials.front()); mMaterials.pop(); } EntityIterator.moveNext(); } mHydrax->getMesh()->getEntity()->setVisible(true); if (mCameraPlaneDiff != 0) { mRttManager->mPlanes[RTT_DEPTH_REFLECTION]->getParentNode()->translate(0, mCameraPlaneDiff, 0); } mRttManager->mPlanes[RTT_DEPTH_REFLECTION]->getParentNode()->translate(0, mHydrax->getPlanesError(), 0); mHydrax->getCamera()->disableReflection(); mHydrax->getCamera()->disableCustomNearClipPlane(); }
void RttManager::CDepthListener::postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt) { Hydrax *mHydrax = mRttManager->mHydrax; Ogre::SceneManager::MovableObjectIterator EntityIterator = mHydrax->getSceneManager()->getMovableObjectIterator("Entity"); Ogre::Entity* CurrentEntity; unsigned int k; while (EntityIterator.hasMoreElements()) { CurrentEntity = static_cast<Ogre::Entity*>(EntityIterator.peekNextValue()); for (k = 0; k < CurrentEntity->getNumSubEntities(); k++) { CurrentEntity->getSubEntity(k)->setMaterialName(mMaterials.front()); mMaterials.pop(); } EntityIterator.moveNext(); } mHydrax->getMesh()->getEntity()->setVisible(true); mHydrax->getGodRaysManager()->setVisible(false); mHydrax->getMesh()->getEntity()->setRenderQueueGroup(Ogre::RENDER_QUEUE_1); if (Ogre::Math::Abs(mHydrax->getPosition().y - mHydrax->getCamera()->getPosition().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()->disableCustomNearClipPlane(); } }
void RttManager::CReflectionListener::postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt) { Hydrax *mHydrax = mRttManager->mHydrax; mHydrax->getMesh()->getEntity()->setVisible(true); if (mCameraPlaneDiff != 0) { mRttManager->mPlanes[RTT_REFLECTION]->getParentNode()->translate(0, mCameraPlaneDiff, 0); } if (mHydrax->_isCurrentFrameUnderwater()) { mRttManager->mPlanes[RTT_REFLECTION]->getParentNode()->translate(0, mHydrax->getPlanesError(), 0); } else { mRttManager->mPlanes[RTT_REFLECTION]->getParentNode()->translate(0, -mHydrax->getPlanesError(), 0); } mHydrax->getCamera()->disableReflection(); mHydrax->getCamera()->disableCustomNearClipPlane(); if (mHydrax->isComponent(HYDRAX_COMPONENT_UNDERWATER)) { if (mHydrax->_isCurrentFrameUnderwater()) { mRttManager->mPlanes[RTT_REFLECTION]->normal = -mRttManager->mPlanes[RTT_REFLECTION]->normal; } } mCReflectionQueueListener.mActive = false; }
void RttManager::CReflectionListener::preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt) { Hydrax *mHydrax = mRttManager->mHydrax; mCReflectionQueueListener.mActive = true; mHydrax->getMesh()->getEntity()->setVisible(false); if (mHydrax->_isCurrentFrameUnderwater()) { mRttManager->mPlanes[RTT_REFLECTION]->getParentNode()->translate(0,-mHydrax->getPlanesError(),0); } else { mRttManager->mPlanes[RTT_REFLECTION]->getParentNode()->translate(0,+mHydrax->getPlanesError(),0); } bool IsInUnderwaterError = false; // Underwater if ( mHydrax->_isCurrentFrameUnderwater() && (mHydrax->getCamera()->getDerivedPosition().y > mRttManager->mPlanes[RTT_REFLECTION]->getParentNode()->getPosition().y)) { mCameraPlaneDiff = 0; IsInUnderwaterError = true; } // Overwater else if ((!mHydrax->_isCurrentFrameUnderwater()) && (mHydrax->getCamera()->getDerivedPosition().y < mRttManager->mPlanes[RTT_REFLECTION]->getParentNode()->getPosition().y)) { mCameraPlaneDiff = mRttManager->mPlanes[RTT_REFLECTION]->getParentNode()->getPosition().y-mHydrax->getCamera()->getDerivedPosition().y+mRttManager->mReflectionDisplacementError; mRttManager->mPlanes[RTT_REFLECTION]->getParentNode()->translate(0,-mCameraPlaneDiff,0); } else { mCameraPlaneDiff = 0; } if (mHydrax->isComponent(HYDRAX_COMPONENT_UNDERWATER)) { if (mHydrax->_isCurrentFrameUnderwater()) { mRttManager->mPlanes[RTT_REFLECTION]->normal = -mRttManager->mPlanes[RTT_REFLECTION]->normal; } } mHydrax->getCamera()->enableReflection(mRttManager->mPlanes[RTT_REFLECTION]); if (IsInUnderwaterError) { mCReflectionQueueListener.mActive = false; } else { mHydrax->getCamera()->enableCustomNearClipPlane(mRttManager->mPlanes[RTT_REFLECTION]); } }
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]); } }
void RttManager::CRefractionListener::postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt) { Hydrax *mHydrax = mRttManager->mHydrax; mHydrax->getMesh()->getEntity()->setVisible(true); if (Ogre::Math::Abs(mHydrax->getPosition().y - mHydrax->getCamera()->getPosition().y) > mHydrax->getPlanesError()) { if (mHydrax->_isCurrentFrameUnderwater()) { mRttManager->mPlanes[RTT_REFRACTION]->normal = -mRttManager->mPlanes[RTT_REFRACTION]->normal; mRttManager->mPlanes[RTT_REFRACTION]->getParentNode()->translate(0, +mHydrax->getPlanesError(), 0); } else { mRttManager->mPlanes[RTT_REFRACTION]->getParentNode()->translate(0, -mHydrax->getPlanesError(), 0); } mHydrax->getCamera()->disableCustomNearClipPlane(); } }