Beispiel #1
0
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();
  }
}
Beispiel #2
0
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::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]);
		}
    }