Revision: 2790
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2790&view=rev
Author:   ulteq
Date:     2012-06-06 22:39:49 +0000 (Wed, 06 Jun 2012)
Log Message:
-----------
-Codechange: new survey map WIP

Modified Paths:
--------------
    trunk/source/main/gameplay/RoRFrameListener.cpp
    trunk/source/main/terrain/map/SurveyMapEntity.cpp
    trunk/source/main/terrain/map/SurveyMapManager.cpp
    trunk/source/main/terrain/map/SurveyMapManager.h

Modified: trunk/source/main/gameplay/RoRFrameListener.cpp
===================================================================
--- trunk/source/main/gameplay/RoRFrameListener.cpp     2012-06-06 22:26:39 UTC 
(rev 2789)
+++ trunk/source/main/gameplay/RoRFrameListener.cpp     2012-06-06 22:39:49 UTC 
(rev 2790)
@@ -2392,6 +2392,8 @@
 #ifdef USE_MYGUI
                if (surveyMap)
                {
+                       // TODO: Create Survey Map Behaviors. Implement 
SurveyMapManager : public IManager ...
+#if 0
                        static float alphaValue = 1.0f;
                        float velocity = 0.0f;
                        if (curr_truck)
@@ -2458,6 +2460,7 @@
                                        surveyMap->setAlpha(1.0f / 
sqrt(std::max(1.0f, velocity - 1.0f)));
                                }
                        }
+#endif
                }
 #endif //USE_MYGUI
                

Modified: trunk/source/main/terrain/map/SurveyMapEntity.cpp
===================================================================
--- trunk/source/main/terrain/map/SurveyMapEntity.cpp   2012-06-06 22:26:39 UTC 
(rev 2789)
+++ trunk/source/main/terrain/map/SurveyMapEntity.cpp   2012-06-06 22:39:49 UTC 
(rev 2790)
@@ -154,7 +154,7 @@
 
 void SurveyMapEntity::update()
 {
-       float wscale = mMapControl->getWindowScale();
+       float wscale = 1.0f - mMapControl->getMapSize().length() / 
mMapControl->getWorldSize().length();
 
        mCaption->setVisible(wscale > 0.5f);
 

Modified: trunk/source/main/terrain/map/SurveyMapManager.cpp
===================================================================
--- trunk/source/main/terrain/map/SurveyMapManager.cpp  2012-06-06 22:26:39 UTC 
(rev 2789)
+++ trunk/source/main/terrain/map/SurveyMapManager.cpp  2012-06-06 22:39:49 UTC 
(rev 2790)
@@ -22,17 +22,17 @@
 #include "SurveyMapManager.h"
 
 #include "BeamData.h"
-#include "SurveyMapEntity.h"
 #include "Ogre.h"
+#include "SurveyMapEntity.h"
 
 using namespace Ogre;
 
 SurveyMapManager::SurveyMapManager(Vector3 worldSize) :
          mWorldSize(worldSize)
        , mAlpha(1.0f)
-       , mScale(1.0f)
-       , mX(0)
-       , mY(0)
+       , mMapCenter(Vector3::ZERO)
+       , mMapSize(Vector3::ZERO)
+       , mMapZoom(0.0f)
 {
        initialiseByAttributes(this);
        setVisibility(false);
@@ -90,56 +90,48 @@
        mMapTexture->setImageTexture(name);
 }
 
-void SurveyMapManager::setPosition(int x, int y, float size)
+void SurveyMapManager::setVisibility(bool value)
 {
-       int realx, realy, realw, realh;
+       mMainWidget->setVisible(value);
+}
 
-       mScale = size;
-       mX = x;
-       mY = y;
+void SurveyMapManager::windowResized()
+{
+       // TODO
+}
 
-       updateRenderMetrics();
-       
-       realw = realh = size * std::min(rWinWidth, rWinHeight);
-
-       if (x == -1)
+void SurveyMapManager::updateEntityPositions()
+{
+       for (std::set<SurveyMapEntity *>::iterator it = mMapEntities.begin(); 
it != mMapEntities.end(); it++)
        {
-               realx = 0;
-       } else if (x == 0)
-       {
-               realx = (rWinWidth - realw) / 2;
-       } else if (x == 1)
-       {
-               realx = rWinWidth - realw;
+               (*it)->update();
        }
+}
 
-       if (y == -1)
-       {
-               realy = 0;
-       } else if (y == 0)
-       {
-               realy = (rWinHeight - realh) / 2;
-       } else if (y == 1)
-       {
-               realy = rWinHeight - realh;
-       }
+void SurveyMapManager::updateRenderMetrics(RenderWindow* win)
+{
+       win->getMetrics(rWinWidth, rWinHeight, rWinDepth, rWinLeft, rWinTop);
+}
 
-       mMainWidget->setCoord(realx, realy, realw, realh);
-
-       updateEntityPositions();
+void SurveyMapManager::setMapZoom(Real zoomValue)
+{
+       mMapZoom = zoomValue;
+       mMapZoom = std::max(0.0f, mMapZoom);
+       mMapZoom = std::min(mMapZoom, 1.0f);
 }
 
-void SurveyMapManager::setVisibility(bool value)
+void SurveyMapManager::setMapZoomRelative(Real zoomDelta)
 {
-       mMainWidget->setVisible(value);
+       setMapZoom(mMapZoom + zoomDelta * std::max(0.1f, 1.0f - mMapZoom) / 
100.0f);
 }
 
-void SurveyMapManager::windowResized()
+void SurveyMapManager::setMapCenter(Vector3 position)
 {
-       setPosition(mX, mY, mScale);
+       mMapCenter = position;
+       mMapCenter.y = 0.0f;
 }
 
-String SurveyMapManager::getTypeByDriveable(int driveable)
+Ogre::String SurveyMapManager::getTypeByDriveable( int driveable )
 {
        switch (driveable)
        {
@@ -158,17 +150,4 @@
        }
 }
 
-void SurveyMapManager::updateEntityPositions()
-{
-       for (std::set<SurveyMapEntity *>::iterator it = mMapEntities.begin(); 
it != mMapEntities.end(); it++)
-       {
-               (*it)->update();
-       }
-}
-
-void SurveyMapManager::updateRenderMetrics()
-{
-       gEnv->renderWindow->getMetrics(rWinWidth, rWinHeight, rWinDepth, 
rWinLeft, rWinTop);
-}
-
 #endif // USE_MYGUI

Modified: trunk/source/main/terrain/map/SurveyMapManager.h
===================================================================
--- trunk/source/main/terrain/map/SurveyMapManager.h    2012-06-06 22:26:39 UTC 
(rev 2789)
+++ trunk/source/main/terrain/map/SurveyMapManager.h    2012-06-06 22:39:49 UTC 
(rev 2790)
@@ -28,7 +28,7 @@
 
 ATTRIBUTE_CLASS_LAYOUT(SurveyMapManager, "MapControl.layout");
 
-class SurveyMapManager : public wraps::BaseLayout, public ZeroedMemoryAllocator
+class SurveyMapManager : public wraps::BaseLayout // TODO: public IManager ...
 {
 public:
 
@@ -36,30 +36,38 @@
 
        SurveyMapEntity *createMapEntity(Ogre::String type);
        SurveyMapEntity *createNamedMapEntity(Ogre::String name, Ogre::String 
type);
-       
-       void deleteMapEntity(SurveyMapEntity *ent);
+       void deleteMapEntity(SurveyMapEntity *entity);
+       SurveyMapEntity *getEntityByName(Ogre::String name);
 
-       SurveyMapEntity *getEntityByName(Ogre::String name);
-       Ogre::Vector3 getMapSize() { return mMapSize; };
-       bool getVisibility();
+       void setAlpha(float alpha);
        float getAlpha() { return mAlpha; }
-       float getWindowScale() { return mScale; }
 
-       void setAlpha(float value);
-       void setEntitiesVisibility(bool value);
-       void setMapTexture(Ogre::String name);
-       void setPosition(int x, int y, float size);
        void setVisibility(bool value);
+       bool getVisibility();
 
+       void setMapZoom(Ogre::Real zoomValue);
+       void setMapZoomRelative(Ogre::Real zoomDelta);
+       Ogre::Real getMapZoom() { return mMapZoom; }
+
+       void setMapCenter(Ogre::Vector3 position);
+
+       void setEntitiesVisibility(bool visibility);
+       void setMapTexture(Ogre::String name);
+
+       Ogre::Vector3 getMapSize() { return mMapSize; };
+       Ogre::Vector3 getWorldSize() { return mWorldSize; };
+
        void windowResized();
 
+       void update(Ogre::Real dt);
+
        static Ogre::String getTypeByDriveable(int driveable);
 
 protected:
 
-       float mAlpha, mScale;
-       int mX, mY;
+       Ogre::Real mAlpha, mMapZoom;
 
+       Ogre::Vector3 mMapCenter;
        Ogre::Vector3 mMapSize;
        Ogre::Vector3 mWorldSize;
 
@@ -74,7 +82,7 @@
        int rWinLeft, rWinTop;
        unsigned int rWinWidth, rWinHeight, rWinDepth;
 
-       void updateRenderMetrics();
+       void updateRenderMetrics(Ogre::RenderWindow* win);
 };
 
 #endif // __MAP_CONTROL_H_

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

Reply via email to