25 #pragma warning(disable:4267)
31 #define _def_Hydrax_Reflection_Rtt_Name "HydraxReflectionMap"
32 #define _def_Hydrax_Refraction_Rtt_Name "HydraxRefractionMap"
33 #define _def_Hydrax_Depth_Rtt_Name "HydraxDepthMap"
34 #define _def_Hydrax_Depth_Reflection_Rtt_Name "HydraxDepthReflectionMap"
35 #define _def_Hydrax_API_Rtt_Name "HydraxAPIMap"
36 #define _def_Hydrax_GPU_Normal_Map_Rtt_Name "HydraxNormalMap"
43 , mReflectionDisplacementError(0.5f)
45 Ogre::String RttNames[6] =
53 for (
int k = 0; k < 6; k++)
55 mPlanes[k] =
static_cast<Ogre::MovablePlane*
>(NULL);
134 Ogre::RenderTarget* RT = Tex->getBuffer()->getRenderTarget();
135 RT->removeAllListeners();
136 RT->removeAllViewports();
138 Ogre::TextureManager::getSingleton().remove(
mRttOptions[Rtt].Name);
139 Ogre::MeshManager::getSingleton().remove(
mRttOptions[Rtt].Name +
"ClipPlane");
143 mPlanes[Rtt] =
static_cast<Ogre::MovablePlane*
>(NULL);
147 if (Ogre::TextureManager::getSingleton().resourceExists(
mRttOptions[Rtt].Name))
149 Ogre::TextureManager::getSingleton().remove(
mRttOptions[Rtt].Name);
155 for (
int k = 0; k < 6; k++)
169 const Ogre::ColourValue& BackgroundColour,
const bool& RenderSky,
170 Ogre::RenderTargetListener* RTListener,
const Ogre::String& MaterialScheme,
171 const bool& ShadowsEnabled)
178 mPlanes[Rtt]->normal = PlaneNormal;
180 Ogre::MeshManager::getSingleton().
181 createPlane(
mRttOptions[Rtt].Name +
"ClipPlane", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
184 10,10,
true, 1,5,5, Ogre::Vector3::UNIT_Z);
186 mPlanes[Rtt]->setCastShadows(
false);
197 mTextures[Rtt] = Ogre::TextureManager::getSingleton()
199 Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
205 Ogre::TU_RENDERTARGET);
207 Ogre::RenderTarget* RT_Texture =
mTextures[Rtt]->getBuffer()->getRenderTarget();
209 Ogre::Viewport *RT_Texture_Viewport = RT_Texture->addViewport(
mHydrax->
getCamera());
210 RT_Texture_Viewport->setClearEveryFrame(
true);
211 RT_Texture_Viewport->setBackgroundColour(BackgroundColour);
212 RT_Texture_Viewport->setOverlaysEnabled(
false);
213 RT_Texture_Viewport->setShadowsEnabled(ShadowsEnabled);
214 if (MaterialScheme !=
"")
216 RT_Texture_Viewport->setMaterialScheme(MaterialScheme);
218 RT_Texture_Viewport->setSkiesEnabled(RenderSky);
220 RT_Texture->addListener(RTListener);
247 bool ReloadMaterialsNeeded =
false;
249 for(
int k = 0; k < 5; k++)
257 ReloadMaterialsNeeded =
true;
261 if (ReloadMaterialsNeeded)
296 return Ogre::PF_FLOAT16_R;
303 return Ogre::PF_FLOAT32_R;
325 return Ogre::PF_FLOAT16_GR;
332 return Ogre::PF_FLOAT32_GR;
347 return Ogre::PF_B8G8R8;
354 return Ogre::PF_FLOAT16_RGB;
361 return Ogre::PF_FLOAT32_RGB;
376 return Ogre::PF_B8G8R8A8;
383 return Ogre::PF_FLOAT16_RGBA;
390 return Ogre::PF_FLOAT32_RGBA;
400 return Ogre::PF_FLOAT32_RGBA;
422 bool IsInUnderwaterError =
false;
429 IsInUnderwaterError =
true;
453 if (IsInUnderwaterError)
469 if (mCameraPlaneDiff != 0)
471 mRttManager->mPlanes[
RTT_REFLECTION]->getParentNode()->translate(0,mCameraPlaneDiff,0);
494 mCReflectionQueueListener.mActive =
false;
501 if ((queueGroupId == Ogre::RENDER_QUEUE_SKIES_EARLY || queueGroupId == Ogre::RENDER_QUEUE_SKIES_LATE || queueGroupId ==
503 (Ogre::RENDER_QUEUE_SKIES_EARLY + 2))
506 mRttManager->mHydrax->getCamera()->disableCustomNearClipPlane();
507 Ogre::Root::getSingleton().getRenderSystem()->_setProjectionMatrix(mRttManager->mHydrax->getCamera()->getProjectionMatrixRS());
515 if ((queueGroupId == Ogre::RENDER_QUEUE_SKIES_EARLY || queueGroupId == Ogre::RENDER_QUEUE_SKIES_LATE || queueGroupId ==
517 (Ogre::RENDER_QUEUE_SKIES_EARLY + 2))
520 mRttManager->mHydrax->getCamera()->enableCustomNearClipPlane(mRttManager->mPlanes[
RTT_REFLECTION]);
521 Ogre::Root::getSingleton().getRenderSystem()->_setProjectionMatrix(mRttManager->mHydrax->getCamera()->getProjectionMatrixRS());
573 Ogre::SceneManager::MovableObjectIterator EntityIterator =
575 Ogre::Entity* CurrentEntity;
580 while (EntityIterator.hasMoreElements())
582 CurrentEntity =
static_cast<Ogre::Entity*
>(EntityIterator.peekNextValue());
584 for(k = 0; k < CurrentEntity->getNumSubEntities(); k++)
586 mMaterials.push(CurrentEntity->getSubEntity(k)->getMaterialName());
591 EntityIterator.moveNext();
627 Ogre::SceneManager::MovableObjectIterator EntityIterator =
629 Ogre::Entity* CurrentEntity;
632 while (EntityIterator.hasMoreElements())
634 CurrentEntity =
static_cast<Ogre::Entity*
>(EntityIterator.peekNextValue());
636 for(k = 0; k < CurrentEntity->getNumSubEntities(); k++)
638 CurrentEntity->getSubEntity(k)->setMaterialName(mMaterials.front());
643 EntityIterator.moveNext();
672 Ogre::SceneManager::MovableObjectIterator EntityIterator =
674 Ogre::Entity* CurrentEntity;
679 while (EntityIterator.hasMoreElements())
681 CurrentEntity =
static_cast<Ogre::Entity*
>(EntityIterator.peekNextValue());
683 for(k = 0; k < CurrentEntity->getNumSubEntities(); k++)
685 mMaterials.push(CurrentEntity->getSubEntity(k)->getMaterialName());
690 EntityIterator.moveNext();
695 bool IsInUnderwaterError =
false;
699 mCameraPlaneDiff = 0;
700 IsInUnderwaterError =
true;
704 mCameraPlaneDiff = 0;
709 if (!IsInUnderwaterError)
719 Ogre::SceneManager::MovableObjectIterator EntityIterator =
721 Ogre::Entity* CurrentEntity;
724 while (EntityIterator.hasMoreElements())
726 CurrentEntity =
static_cast<Ogre::Entity*
>(EntityIterator.peekNextValue());
728 for(k = 0; k < CurrentEntity->getNumSubEntities(); k++)
730 CurrentEntity->getSubEntity(k)->setMaterialName(mMaterials.front());
735 EntityIterator.moveNext();
740 if (mCameraPlaneDiff != 0)
753 mOldMaterialName = mRttManager->mHydrax->getMesh()->getMaterialName();
754 mRttManager->mHydrax->getMesh()->setMaterialName(mRttManager->mHydrax->getGPUNormalMapManager()->getNormalMapMaterial()->getName());
756 Ogre::SceneManager *mSceneMgr = mRttManager->mHydrax->getSceneManager();
759 mSceneMgr->clearSpecialCaseRenderQueues();
760 mSceneMgr->addSpecialCaseRenderQueue(Ogre::RENDER_QUEUE_1);
761 mSceneMgr->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_INCLUDE);
766 mRttManager->mHydrax->getMesh()->setMaterialName(mOldMaterialName);
768 Ogre::SceneManager *mSceneMgr = mRttManager->mHydrax->getSceneManager();
771 mSceneMgr->clearSpecialCaseRenderQueues();
772 mSceneMgr->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_EXCLUDE);