diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index 2c0a4e76b..47b8171a5 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -2,6 +2,7 @@ #include "renderingmanager.hpp" #include "../mwworld/environment.hpp" +#include "../mwworld/world.hpp" #include "../mwgui/window_manager.hpp" #include @@ -14,12 +15,17 @@ LocalMap::LocalMap(OEngine::Render::OgreRenderer* rend, MWWorld::Environment* en { mRendering = rend; mEnvironment = env; - + + mCameraRotNode = mRendering->getScene()->getRootSceneNode()->createChildSceneNode(); + mCameraNode = mCameraRotNode->createChildSceneNode(); + mCellCamera = mRendering->getScene()->createCamera("CellCamera"); mCellCamera->setProjectionType(PT_ORTHOGRAPHIC); // look down -y const float sqrt0pt5 = 0.707106781; mCellCamera->setOrientation(Quaternion(sqrt0pt5, -sqrt0pt5, 0, 0)); + + mCameraNode->attachObject(mCellCamera); } LocalMap::~LocalMap() @@ -100,11 +106,15 @@ void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell, { mInterior = true; mBounds = bounds; - + Vector2 z(bounds.getMaximum().y, bounds.getMinimum().y); Vector2 min(bounds.getMinimum().x, bounds.getMinimum().z); Vector2 max(bounds.getMaximum().x, bounds.getMaximum().z); + const Vector2& north = mEnvironment->mWorld->getNorthVector(cell); + Radian angle(std::atan2(north.x, north.y)); + mCameraRotNode->setOrientation(Quaternion(Math::Cos(angle/2.f), 0, Math::Sin(angle/2.f), 0)); + Vector2 length = max-min; Vector2 center(bounds.getCenter().x, bounds.getCenter().z); @@ -141,7 +151,7 @@ void LocalMap::render(const float x, const float y, // make everything visible mRendering->getScene()->setAmbientLight(ColourValue(1,1,1)); - mCellCamera->setPosition(Vector3(x, zhigh+100000, y)); + mCameraNode->setPosition(Vector3(x, zhigh+100000, y)); //mCellCamera->setFarClipDistance( (zhigh-zlow) * 1.1 ); mCellCamera->setFarClipDistance(0); // infinite diff --git a/apps/openmw/mwrender/localmap.hpp b/apps/openmw/mwrender/localmap.hpp index efbccf884..42603885a 100644 --- a/apps/openmw/mwrender/localmap.hpp +++ b/apps/openmw/mwrender/localmap.hpp @@ -73,6 +73,8 @@ namespace MWRender static const int sSize = 8192; Ogre::Camera* mCellCamera; + Ogre::SceneNode* mCameraNode; + Ogre::SceneNode* mCameraRotNode; void render(const float x, const float y, const float zlow, const float zhigh, diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 5c661b4a2..24d055c35 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -701,7 +701,6 @@ namespace MWWorld void World::update (float duration) { - getNorthVector(mWorldScene->getCurrentCell()); mWorldScene->update (duration); mWeatherManager->update (duration); @@ -761,10 +760,7 @@ namespace MWWorld ESMS::CellRefList statics = cell->statics; ESMS::LiveCellRef* ref = statics.find("northmarker"); if (!ref) - { - std::cout << "No north marker found." << std::endl; return Vector2(0, 1); - } Ogre::SceneNode* node = ref->mData.getBaseNode(); Vector3 dir = node->_getDerivedOrientation().yAxis(); Vector2 d = Vector2(dir.x, dir.z);