Пример #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();
  }
}
Пример #2
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();
  }
}