Revision: 2600 http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2600&view=rev Author: ulteq Date: 2012-05-19 18:44:07 +0000 (Sat, 19 May 2012) Log Message: ----------- -Bugfix: Overview map (WIP) lookAt and orientation now set in RoRFrameListener style++
Modified Paths: -------------- trunk/source/main/gameplay/RoRFrameListener.cpp trunk/source/main/gui/MapTextureCreator.cpp trunk/source/main/gui/MapTextureCreator.h Modified: trunk/source/main/gameplay/RoRFrameListener.cpp =================================================================== --- trunk/source/main/gameplay/RoRFrameListener.cpp 2012-05-19 18:28:23 UTC (rev 2599) +++ trunk/source/main/gameplay/RoRFrameListener.cpp 2012-05-19 18:44:07 UTC (rev 2600) @@ -5137,6 +5137,15 @@ if (mtc) { + Quaternion orientation = Quaternion(Degree(0), Vector3::UNIT_X); + Vector3 lookAt = Vector3(mapsizex / 2.0f, 0.0f, mapsizez / 2.0f); + + if (hfinder) + { + lookAt.y += hfinder->getHeightAt(mapsizex / 2.0f, mapsizez / 2.0f); + } + + mtc->setCamera(lookAt, orientation); mtc->update(); } #endif //USE_MYGUI Modified: trunk/source/main/gui/MapTextureCreator.cpp =================================================================== --- trunk/source/main/gui/MapTextureCreator.cpp 2012-05-19 18:28:23 UTC (rev 2599) +++ trunk/source/main/gui/MapTextureCreator.cpp 2012-05-19 18:44:07 UTC (rev 2600) @@ -19,7 +19,6 @@ */ #include "MapTextureCreator.h" -#include "heightfinder.h" #include "ResourceBuffer.h" #include "RoRFrameListener.h" #include "water.h" @@ -32,15 +31,15 @@ mSceneManager(mgr) , mMainCam(mMainCam) , mEfl(efl) - , mCamDir(Quaternion::ZERO) - , mCamPos(Vector3::ZERO) + , mCamOrientation(Quaternion::ZERO) + , mCamLookAt(Vector3::ZERO) , mCamera(NULL) , mMaterial(NULL) , mRttTex(NULL) , mStatics(NULL) , mTextureUnitState(NULL) , mViewport(NULL) - , mZoom(3.0f) + , mCamZoom(3.0f) { mCounter++; init(); @@ -80,30 +79,30 @@ mCamera->setFixedYawAxis(false); mCamera->setProjectionType(PT_ORTHOGRAPHIC); mCamera->setFOVy(Radian(Math::HALF_PI)); - mCamera->setNearClipDistance(mZoom); + mCamera->setNearClipDistance(mCamZoom); return true; } -void MapTextureCreator::setCameraMode(PolygonMode pm) +void MapTextureCreator::setCameraMode(PolygonMode polygonMode) { - mCamera->setPolygonMode(pm); + mCamera->setPolygonMode(polygonMode); } -void MapTextureCreator::setCameraZoom(float z) +void MapTextureCreator::setCameraZoom(Real zoom) { - mZoom = std::max(0.3f, z); + mCamZoom = std::max(0.3f, zoom); } -void MapTextureCreator::setCamPosition(Vector3 pos, Quaternion direction) +void MapTextureCreator::setCamera(Vector3 lookAt, Quaternion orientation) { - mCamPos = pos; - mCamDir = direction; + mCamLookAt = lookAt; + mCamOrientation = orientation; } -void MapTextureCreator::setStaticGeometry(StaticGeometry *geo) +void MapTextureCreator::setStaticGeometry(StaticGeometry *staticGeometry) { - mStatics = geo; + mStatics = staticGeometry; } void MapTextureCreator::update() @@ -112,20 +111,17 @@ float width = mEfl->mapsizex; float height = mEfl->mapsizez; - float zoomFactor = mZoom * ((width + height) / 2.0f) * 0.002f; - - mCamPos = Vector3(mEfl->mapsizex / 2.0f, mEfl->hfinder->getHeightAt(mEfl->mapsizex / 2.0f, mEfl->mapsizez / 2.0f) , mEfl->mapsizez / 2.0f); - mCamDir = Quaternion(Degree(0), Vector3::UNIT_X); + float zoomFactor = mCamZoom * ((width + height) / 2.0f) * 0.002f; - mCamera->setNearClipDistance(mZoom); - mCamera->setPosition(mCamPos + Vector3(0.0f, zoomFactor, 0.0f)); - if ( mCamDir != Quaternion::ZERO ) + mCamera->setNearClipDistance(mCamZoom); + mCamera->setPosition(mCamLookAt + Vector3(0.0f, zoomFactor, 0.0f)); + if ( mCamOrientation != Quaternion::ZERO ) { - mCamera->setOrientation(mCamDir); + mCamera->setOrientation(mCamOrientation); } - mCamera->lookAt(mCamPos - Vector3(0.0f, zoomFactor, 0.0f)); + mCamera->lookAt(mCamLookAt); - float f = std::max(20.0f, 50.0f - mZoom); + float f = std::max(20.0f, 50.0f - mCamZoom); if ( mStatics ) { Modified: trunk/source/main/gui/MapTextureCreator.h =================================================================== --- trunk/source/main/gui/MapTextureCreator.h 2012-05-19 18:28:23 UTC (rev 2599) +++ trunk/source/main/gui/MapTextureCreator.h 2012-05-19 18:44:07 UTC (rev 2600) @@ -33,10 +33,10 @@ Ogre::String getMaterialName(); Ogre::String getRTName(); - void setCamPosition(Ogre::Vector3 pos, Ogre::Quaternion direction); - void setCameraMode(Ogre::PolygonMode pm); - void setCameraZoom(float z); - void setStaticGeometry(Ogre::StaticGeometry *geo); + void setCamera(Ogre::Vector3 lookAt, Ogre::Quaternion orientation); + void setCameraMode(Ogre::PolygonMode polygonMode); + void setCameraZoom(Ogre::Real zoom); + void setStaticGeometry(Ogre::StaticGeometry *staticGeometry); void update(); @@ -50,17 +50,16 @@ Ogre::Camera *mCamera; Ogre::Camera *mMainCam; Ogre::MaterialPtr mMaterial; - Ogre::Quaternion mCamDir; + Ogre::Quaternion mCamOrientation; + Ogre::Real mCamZoom; Ogre::RenderTarget *mRttTex; Ogre::SceneManager *mSceneManager; Ogre::StaticGeometry *mStatics; Ogre::TextureUnitState* mTextureUnitState; - Ogre::Vector3 mCamPos; + Ogre::Vector3 mCamLookAt; Ogre::Viewport *mViewport; RoRFrameListener *mEfl; - float mZoom; - static int mCounter; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Rigsofrods-devel mailing list Rigsofrods-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel