Revision: 2632
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2632&view=rev
Author:   ulteq
Date:     2012-05-22 17:43:20 +0000 (Tue, 22 May 2012)
Log Message:
-----------
-Bugfix: Survey map (WIP)
~new default camera height (500m)
~changed camera aspect ratio to auto
~changed how the zoom works
~changed how the map size is used (setOrthoWindow())
+added setMapCenter()
-removed setCamera()

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-22 15:43:30 UTC 
(rev 2631)
+++ trunk/source/main/gameplay/RoRFrameListener.cpp     2012-05-22 17:43:20 UTC 
(rev 2632)
@@ -5192,15 +5192,8 @@
        
        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);
+               Vector3 position = Vector3(mapsizex / 2.0f, 0.0f, mapsizez / 
2.0f);
+               mtc->setMapCenter(position);
                mtc->update();
        }
 #endif //USE_MYGUI

Modified: trunk/source/main/gui/MapTextureCreator.cpp
===================================================================
--- trunk/source/main/gui/MapTextureCreator.cpp 2012-05-22 15:43:30 UTC (rev 
2631)
+++ trunk/source/main/gui/MapTextureCreator.cpp 2012-05-22 17:43:20 UTC (rev 
2632)
@@ -32,15 +32,14 @@
          mSceneManager(scm)
        , mMainCam(cam)
        , mEfl(efl)
-       , mCamOrientation(Quaternion::ZERO)
-       , mCamLookAt(Vector3::ZERO)
        , mCamera(NULL)
+       , mMapCenter(Vector3::ZERO)
+       , mMapZoom(0.0f)
        , mMaterial(NULL)
        , mRttTex(NULL)
        , mStatics(NULL)
        , mTextureUnitState(NULL)
        , mViewport(NULL)
-       , mCamZoom(3.0f)
 {
        mCounter++;
        init();
@@ -72,37 +71,29 @@
 
        mRttTex->addListener(this);
 
-       mCamera->setFarClipDistance(1000.0f);
-       mCamera->setAspectRatio(1.0f);
        mCamera->setFixedYawAxis(false);
        mCamera->setProjectionType(PT_ORTHOGRAPHIC);
-       mCamera->setFOVy(Radian(Math::HALF_PI));
-       mCamera->setNearClipDistance(mCamZoom);
 
        return true;
 }
 
-void MapTextureCreator::setCameraMode(PolygonMode polygonMode)
+void MapTextureCreator::setMapZoom(Real zoomValue)
 {
-       mCamera->setPolygonMode(polygonMode);
+       mMapZoom = std::max(0.0f, zoomValue);
+       mMapZoom = std::min(zoomValue, 1.0f);
 }
 
-void MapTextureCreator::setCameraZoom(Real zoom)
+void MapTextureCreator::setMapZoomRelative(Real zoomDelta)
 {
-       mCamZoom = std::max(0.3f, zoom);
+       setMapZoom(mMapZoom + zoomDelta * mMapZoom / 100.0f);
 }
 
-void MapTextureCreator::setCameraZoomRelative(Real zoomDelta)
+void MapTextureCreator::setMapCenter(Vector3 position)
 {
-       mCamZoom = std::max(0.3f, mCamZoom + zoomDelta * mCamZoom / 100.0f);
+       mMapCenter = position;
+       mMapCenter.y = 0.0f;
 }
 
-void MapTextureCreator::setCamera(Vector3 lookAt, Quaternion orientation)
-{
-       mCamLookAt = lookAt;
-       mCamOrientation = orientation;
-}
-
 void MapTextureCreator::setStaticGeometry(StaticGeometry *staticGeometry)
 {
        mStatics = staticGeometry;
@@ -112,17 +103,12 @@
 {
        if ( !mRttTex ) return;
 
-       float width = mEfl->mapsizex;
-       float height = mEfl->mapsizez;
-       float zoomFactor = mCamZoom * ((width + height) / 2.0f) * 0.1f;
+       float orthoWindowWidth = mEfl->mapsizex - mEfl->mapsizex * mMapZoom;
+       float orthoWindowHeight = mEfl->mapsizez - mEfl->mapsizez * mMapZoom;
 
-       mCamera->setNearClipDistance(mCamZoom);
-       mCamera->setPosition(mCamLookAt + Vector3(0.0f, zoomFactor, 0.0f));
-       if ( mCamOrientation != Quaternion::ZERO )
-       {
-               mCamera->setOrientation(mCamOrientation);
-       }
-       mCamera->lookAt(mCamLookAt);
+       mCamera->setOrthoWindow(orthoWindowWidth, orthoWindowHeight);
+       mCamera->setPosition(mMapCenter + Vector3(0.0f, 500.0f, 0.0f));
+       mCamera->lookAt(mMapCenter);
 
        preRenderTargetUpdate();
 
@@ -145,7 +131,7 @@
 {
        Beam **trucks = BeamFactory::getSingleton().getTrucks();
 
-       float f = std::max(20.0f, 50.0f - mCamZoom);
+       float f = 20.0f + 30.0f * mMapZoom;
 
        for (int i=0; i < BeamFactory::getSingleton().getTruckCount(); i++)
        {

Modified: trunk/source/main/gui/MapTextureCreator.h
===================================================================
--- trunk/source/main/gui/MapTextureCreator.h   2012-05-22 15:43:30 UTC (rev 
2631)
+++ trunk/source/main/gui/MapTextureCreator.h   2012-05-22 17:43:20 UTC (rev 
2632)
@@ -33,10 +33,9 @@
        Ogre::String getMaterialName();
        Ogre::String getRTName();
        
-       void setCamera(Ogre::Vector3 lookAt, Ogre::Quaternion orientation);
-       void setCameraMode(Ogre::PolygonMode polygonMode);
-       void setCameraZoom(Ogre::Real zoom);
-       void setCameraZoomRelative(Ogre::Real zoomDelta);
+       void setMapCenter(Ogre::Vector3 position);
+       void setMapZoom(Ogre::Real zoomValue);
+       void setMapZoomRelative(Ogre::Real zoomDelta);
        void setStaticGeometry(Ogre::StaticGeometry *staticGeometry);
 
        void update();
@@ -51,13 +50,12 @@
        Ogre::Camera *mCamera;
        Ogre::Camera *mMainCam;
        Ogre::MaterialPtr mMaterial;
-       Ogre::Quaternion mCamOrientation;
-       Ogre::Real mCamZoom;
+       Ogre::Real mMapZoom;
        Ogre::RenderTarget *mRttTex;
        Ogre::SceneManager *mSceneManager;
        Ogre::StaticGeometry *mStatics;
-       Ogre::TextureUnitState* mTextureUnitState;
-       Ogre::Vector3 mCamLookAt;
+       Ogre::TextureUnitState *mTextureUnitState;
+       Ogre::Vector3 mMapCenter;
        Ogre::Viewport *mViewport;
        RoRFrameListener *mEfl;
 

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
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel

Reply via email to