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++)
258 ReloadMaterialsNeeded =
true;
262 if (ReloadMaterialsNeeded)
297 return Ogre::PF_FLOAT16_R;
304 return Ogre::PF_FLOAT32_R;
326 return Ogre::PF_FLOAT16_GR;
333 return Ogre::PF_FLOAT32_GR;
348 return Ogre::PF_B8G8R8;
355 return Ogre::PF_FLOAT16_RGB;
362 return Ogre::PF_FLOAT32_RGB;
377 return Ogre::PF_B8G8R8A8;
384 return Ogre::PF_FLOAT16_RGBA;
391 return Ogre::PF_FLOAT32_RGBA;
401 return Ogre::PF_FLOAT32_RGBA;
423 bool IsInUnderwaterError =
false;
430 IsInUnderwaterError =
true;
454 if (IsInUnderwaterError)
470 if (mCameraPlaneDiff != 0)
472 mRttManager->mPlanes[
RTT_REFLECTION]->getParentNode()->translate(0,mCameraPlaneDiff,0);
495 mCReflectionQueueListener.mActive =
false;
502 if ((queueGroupId == Ogre::RENDER_QUEUE_SKIES_EARLY || queueGroupId == Ogre::RENDER_QUEUE_SKIES_LATE || queueGroupId ==
504 (Ogre::RENDER_QUEUE_SKIES_EARLY + 2))
507 mRttManager->mHydrax->getCamera()->disableCustomNearClipPlane();
508 Ogre::Root::getSingleton().getRenderSystem()->_setProjectionMatrix(mRttManager->mHydrax->getCamera()->getProjectionMatrixRS());
516 if ((queueGroupId == Ogre::RENDER_QUEUE_SKIES_EARLY || queueGroupId == Ogre::RENDER_QUEUE_SKIES_LATE || queueGroupId ==
518 (Ogre::RENDER_QUEUE_SKIES_EARLY + 2))
521 mRttManager->mHydrax->getCamera()->enableCustomNearClipPlane(mRttManager->mPlanes[
RTT_REFLECTION]);
522 Ogre::Root::getSingleton().getRenderSystem()->_setProjectionMatrix(mRttManager->mHydrax->getCamera()->getProjectionMatrixRS());
574 Ogre::SceneManager::MovableObjectIterator EntityIterator =
576 Ogre::Entity* CurrentEntity;
579 while (EntityIterator.hasMoreElements())
581 CurrentEntity =
static_cast<Ogre::Entity*
>(EntityIterator.peekNextValue());
583 for(k = 0; k < CurrentEntity->getNumSubEntities(); k++)
585 mMaterials.push(CurrentEntity->getSubEntity(k)->getMaterialName());
590 EntityIterator.moveNext();
626 Ogre::SceneManager::MovableObjectIterator EntityIterator =
628 Ogre::Entity* CurrentEntity;
631 while (EntityIterator.hasMoreElements())
633 CurrentEntity =
static_cast<Ogre::Entity*
>(EntityIterator.peekNextValue());
635 for(k = 0; k < CurrentEntity->getNumSubEntities(); k++)
637 CurrentEntity->getSubEntity(k)->setMaterialName(mMaterials.front());
642 EntityIterator.moveNext();
671 Ogre::SceneManager::MovableObjectIterator EntityIterator =
673 Ogre::Entity* CurrentEntity;
676 while (EntityIterator.hasMoreElements())
678 CurrentEntity =
static_cast<Ogre::Entity*
>(EntityIterator.peekNextValue());
680 for(k = 0; k < CurrentEntity->getNumSubEntities(); k++)
682 mMaterials.push(CurrentEntity->getSubEntity(k)->getMaterialName());
687 EntityIterator.moveNext();
692 bool IsInUnderwaterError =
false;
696 mCameraPlaneDiff = 0;
697 IsInUnderwaterError =
true;
701 mCameraPlaneDiff = 0;
706 if (!IsInUnderwaterError)
716 Ogre::SceneManager::MovableObjectIterator EntityIterator =
718 Ogre::Entity* CurrentEntity;
721 while (EntityIterator.hasMoreElements())
723 CurrentEntity =
static_cast<Ogre::Entity*
>(EntityIterator.peekNextValue());
725 for(k = 0; k < CurrentEntity->getNumSubEntities(); k++)
727 CurrentEntity->getSubEntity(k)->setMaterialName(mMaterials.front());
732 EntityIterator.moveNext();
737 if (mCameraPlaneDiff != 0)
750 mOldMaterialName = mRttManager->mHydrax->getMesh()->getMaterialName();
751 mRttManager->mHydrax->getMesh()->setMaterialName(mRttManager->mHydrax->getGPUNormalMapManager()->getNormalMapMaterial()->getName());
753 Ogre::SceneManager *mSceneMgr = mRttManager->mHydrax->getSceneManager();
756 mSceneMgr->clearSpecialCaseRenderQueues();
757 mSceneMgr->addSpecialCaseRenderQueue(Ogre::RENDER_QUEUE_1);
758 mSceneMgr->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_INCLUDE);
763 mRttManager->mHydrax->getMesh()->setMaterialName(mOldMaterialName);
765 Ogre::SceneManager *mSceneMgr = mRttManager->mHydrax->getSceneManager();
768 mSceneMgr->clearSpecialCaseRenderQueues();
769 mSceneMgr->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_EXCLUDE);