Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
	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]);
		}
    }
Exemplo n.º 3
0
    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);
		}
    }
Exemplo n.º 4
0
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();
  }
}