|
|
|
@ -49,8 +49,9 @@ using namespace Ogre;
|
|
|
|
|
|
|
|
|
|
namespace MWRender {
|
|
|
|
|
|
|
|
|
|
RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir,
|
|
|
|
|
const boost::filesystem::path& cacheDir, OEngine::Physic::PhysicEngine* engine,MWWorld::Fallback* fallback)
|
|
|
|
|
RenderingManager::RenderingManager(OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir,
|
|
|
|
|
const boost::filesystem::path& cacheDir, OEngine::Physic::PhysicEngine* engine,
|
|
|
|
|
MWWorld::Fallback* fallback)
|
|
|
|
|
: mRendering(_rend)
|
|
|
|
|
, mFallback(fallback)
|
|
|
|
|
, mObjects(mRendering, mFallback)
|
|
|
|
@ -155,7 +156,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
|
|
|
|
|
mObjects.setRootNode(mRootNode);
|
|
|
|
|
mActors.setRootNode(mRootNode);
|
|
|
|
|
|
|
|
|
|
mPlayer = new MWRender::Player(mRendering.getCamera());
|
|
|
|
|
mCamera = new MWRender::Camera(mRendering.getCamera());
|
|
|
|
|
|
|
|
|
|
mShadows = new Shadows(&mRendering);
|
|
|
|
|
|
|
|
|
@ -184,7 +185,7 @@ RenderingManager::~RenderingManager ()
|
|
|
|
|
mRendering.removeWindowEventListener(this);
|
|
|
|
|
|
|
|
|
|
delete mPlayerAnimation;
|
|
|
|
|
delete mPlayer;
|
|
|
|
|
delete mCamera;
|
|
|
|
|
delete mSkyManager;
|
|
|
|
|
delete mDebugging;
|
|
|
|
|
delete mShadows;
|
|
|
|
@ -269,8 +270,8 @@ void RenderingManager::rotateObject(const MWWorld::Ptr &ptr)
|
|
|
|
|
{
|
|
|
|
|
Ogre::Vector3 rot(ptr.getRefData().getPosition().rot);
|
|
|
|
|
|
|
|
|
|
if(ptr.getRefData().getHandle() == mPlayer->getHandle())
|
|
|
|
|
mPlayer->rotateCamera(rot, false);
|
|
|
|
|
if(ptr.getRefData().getHandle() == mCamera->getHandle())
|
|
|
|
|
mCamera->rotateCamera(rot, false);
|
|
|
|
|
|
|
|
|
|
Ogre::Quaternion newo = Ogre::Quaternion(Ogre::Radian(-rot.z), Ogre::Vector3::UNIT_Z);
|
|
|
|
|
if(!MWWorld::Class::get(ptr).isActor())
|
|
|
|
@ -300,7 +301,7 @@ void RenderingManager::update (float duration, bool paused)
|
|
|
|
|
{
|
|
|
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
|
|
|
|
|
|
|
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
|
|
|
|
MWWorld::Ptr player = world->getPlayer().getPlayer();
|
|
|
|
|
|
|
|
|
|
int blind = MWWorld::Class::get(player).getCreatureStats(player).getMagicEffects().get(MWMechanics::EffectKey(ESM::MagicEffect::Blind)).mMagnitude;
|
|
|
|
|
mRendering.getFader()->setFactor(1.f-(blind / 100.f));
|
|
|
|
@ -313,16 +314,16 @@ void RenderingManager::update (float duration, bool paused)
|
|
|
|
|
Ogre::Vector3 playerPos(_playerPos[0], _playerPos[1], _playerPos[2]);
|
|
|
|
|
|
|
|
|
|
Ogre::Vector3 orig, dest;
|
|
|
|
|
mPlayer->setCameraDistance();
|
|
|
|
|
if (!mPlayer->getPosition(orig, dest)) {
|
|
|
|
|
orig.z += mPlayer->getHeight() * mRootNode->getScale().z;
|
|
|
|
|
mCamera->setCameraDistance();
|
|
|
|
|
if(!mCamera->getPosition(orig, dest))
|
|
|
|
|
{
|
|
|
|
|
orig.z += mCamera->getHeight() * mRootNode->getScale().z;
|
|
|
|
|
|
|
|
|
|
btVector3 btOrig(orig.x, orig.y, orig.z);
|
|
|
|
|
btVector3 btDest(dest.x, dest.y, dest.z);
|
|
|
|
|
std::pair<std::string, float> test =
|
|
|
|
|
mPhysicsEngine->rayTest(btOrig, btDest);
|
|
|
|
|
std::pair<std::string,float> test = mPhysicsEngine->rayTest(btOrig, btDest);
|
|
|
|
|
if (!test.first.empty()) {
|
|
|
|
|
mPlayer->setCameraDistance(test.second * orig.distance(dest), false, false);
|
|
|
|
|
mCamera->setCameraDistance(test.second * orig.distance(dest), false, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -336,14 +337,12 @@ void RenderingManager::update (float duration, bool paused)
|
|
|
|
|
|
|
|
|
|
Ogre::Vector3 cam = mRendering.getCamera()->getRealPosition();
|
|
|
|
|
|
|
|
|
|
applyFog(world->isUnderwater (world->getPlayer().getPlayer().getCell(), cam));
|
|
|
|
|
applyFog(world->isUnderwater(player.getCell(), cam));
|
|
|
|
|
|
|
|
|
|
if(paused)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mPlayer->update(duration);
|
|
|
|
|
mCamera->update(duration);
|
|
|
|
|
|
|
|
|
|
mActors.update (duration);
|
|
|
|
|
mObjects.update (duration);
|
|
|
|
@ -354,18 +353,11 @@ void RenderingManager::update (float duration, bool paused)
|
|
|
|
|
mSkyManager->setGlare(mOcclusionQuery->getSunVisibility());
|
|
|
|
|
|
|
|
|
|
Ogre::SceneNode *node = data.getBaseNode();
|
|
|
|
|
//Ogre::Quaternion orient =
|
|
|
|
|
//node->convertLocalToWorldOrientation(node->_getDerivedOrientation());
|
|
|
|
|
Ogre::Quaternion orient =
|
|
|
|
|
node->_getDerivedOrientation();
|
|
|
|
|
Ogre::Quaternion orient = node->_getDerivedOrientation();
|
|
|
|
|
|
|
|
|
|
mLocalMap->updatePlayer(playerPos, orient);
|
|
|
|
|
|
|
|
|
|
mWater->updateUnderwater(
|
|
|
|
|
world->isUnderwater(
|
|
|
|
|
world->getPlayer().getPlayer().getCell(),
|
|
|
|
|
cam)
|
|
|
|
|
);
|
|
|
|
|
mWater->updateUnderwater(world->isUnderwater(player.getCell(), cam));
|
|
|
|
|
|
|
|
|
|
mWater->update(duration, playerPos);
|
|
|
|
|
}
|
|
|
|
@ -862,7 +854,7 @@ void RenderingManager::getTriangleBatchCount(unsigned int &triangles, unsigned i
|
|
|
|
|
void RenderingManager::setupPlayer(const MWWorld::Ptr &ptr)
|
|
|
|
|
{
|
|
|
|
|
ptr.getRefData().setBaseNode(mRendering.getScene()->getSceneNode("player"));
|
|
|
|
|
mPlayer->attachTo(ptr);
|
|
|
|
|
mCamera->attachTo(ptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RenderingManager::renderPlayer(const MWWorld::Ptr &ptr)
|
|
|
|
@ -881,27 +873,27 @@ void RenderingManager::renderPlayer(const MWWorld::Ptr &ptr)
|
|
|
|
|
MWWorld::Class::get(ptr).getInventoryStore(ptr),
|
|
|
|
|
RV_Actors);
|
|
|
|
|
}
|
|
|
|
|
mPlayer->setAnimation(mPlayerAnimation);
|
|
|
|
|
mCamera->setAnimation(mPlayerAnimation);
|
|
|
|
|
mWater->removeEmitter(ptr);
|
|
|
|
|
mWater->addEmitter(ptr);
|
|
|
|
|
// apply race height
|
|
|
|
|
MWBase::Environment::get().getWorld()->scaleObject(ptr, 1.f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RenderingManager::getPlayerData(Ogre::Vector3 &eyepos, float &pitch, float &yaw)
|
|
|
|
|
void RenderingManager::getCameraData(Ogre::Vector3 &eyepos, float &pitch, float &yaw)
|
|
|
|
|
{
|
|
|
|
|
eyepos = mPlayer->getPosition();
|
|
|
|
|
eyepos.z += mPlayer->getHeight();
|
|
|
|
|
mPlayer->getSightAngles(pitch, yaw);
|
|
|
|
|
eyepos = mCamera->getPosition();
|
|
|
|
|
eyepos.z += mCamera->getHeight();
|
|
|
|
|
mCamera->getSightAngles(pitch, yaw);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool RenderingManager::vanityRotateCamera(float* rot)
|
|
|
|
|
bool RenderingManager::vanityRotateCamera(const float *rot)
|
|
|
|
|
{
|
|
|
|
|
if(!mPlayer->isVanityOrPreviewModeEnabled())
|
|
|
|
|
if(!mCamera->isVanityOrPreviewModeEnabled())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
Ogre::Vector3 vRot(rot);
|
|
|
|
|
mPlayer->rotateCamera(vRot, true);
|
|
|
|
|
mCamera->rotateCamera(vRot, true);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|