Revision: 2574
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2574&view=rev
Author:   ulteq
Date:     2012-05-15 18:34:34 +0000 (Tue, 15 May 2012)
Log Message:
-----------
-Codechange: moved getCamera() back to the RoRFrameListener

Modified Paths:
--------------
    trunk/source/main/gameplay/Character.cpp
    trunk/source/main/gameplay/RoRFrameListener.cpp
    trunk/source/main/gameplay/RoRFrameListener.h
    trunk/source/main/gameplay/Savegame.cpp
    trunk/source/main/gameplay/SceneMouse.cpp
    trunk/source/main/gfx/PreviewRenderer.cpp
    trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp
    trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h
    trunk/source/main/gfx/camera/CameraManager.h
    trunk/source/main/physics/Beam.cpp

Modified: trunk/source/main/gameplay/Character.cpp
===================================================================
--- trunk/source/main/gameplay/Character.cpp    2012-05-15 18:18:54 UTC (rev 
2573)
+++ trunk/source/main/gameplay/Character.cpp    2012-05-15 18:34:34 UTC (rev 
2574)
@@ -295,7 +295,7 @@
        if(physicsEnabled && !remote)
        {
                // disable character movement when using the free camera mode 
or when the menu is opened
-               if(!CameraManager::singletonExists() || 
CameraManager::getSingleton().getCameraMode() == 
CameraManager::CAMERA_BEHAVIOR_FREE) return;
+               if(!CameraManager::singletonExists() || 
CameraManager::getSingleton().getCameraBehavior() == 
CameraManager::CAMERA_BEHAVIOR_FREE) return;
 
                // small hack: if not visible do not apply physics
                //mode perso

Modified: trunk/source/main/gameplay/RoRFrameListener.cpp
===================================================================
--- trunk/source/main/gameplay/RoRFrameListener.cpp     2012-05-15 18:18:54 UTC 
(rev 2573)
+++ trunk/source/main/gameplay/RoRFrameListener.cpp     2012-05-15 18:34:34 UTC 
(rev 2574)
@@ -2011,7 +2011,7 @@
                        as->addData("MP_ServerName", SSETTING("Server name", 
""));
                        as->addData("MP_ServerPort", SSETTING("Server port", 
""));
                        as->addData("MP_NetworkEnabled", SSETTING("Network 
enable", "No"));
-                       as->addData("Camera_Mode", 
CameraManager::singletonExists() ? 
TOSTRING(CameraManager::getSingleton().getCameraMode()) : "None");
+                       as->addData("Camera_Mode", 
CameraManager::singletonExists() ? 
TOSTRING(CameraManager::getSingleton().getCameraBehavior()) : "None");
                        as->addData("Camera_Position", 
TOSTRING(mCamera->getPosition()));
 
                        const RenderTarget::FrameStats& stats = 
mWindow->getStatistics();
@@ -2133,7 +2133,7 @@
        {
                if (CameraManager::singletonExists() &&
                        (!CameraManager::getSingleton().hasActiveBehavior() ||
-                       CameraManager::getSingleton().getCameraMode() != 
CameraManager::CAMERA_BEHAVIOR_FREE))
+                       CameraManager::getSingleton().getCameraBehavior() != 
CameraManager::CAMERA_BEHAVIOR_FREE))
                {
                        if (!curr_truck)
                        {
@@ -3070,7 +3070,7 @@
                                        bigMap->setVisibility(true);
                                        if (CameraManager::singletonExists() &&
                                                
CameraManager::getSingleton().hasActiveBehavior() &&
-                                               
CameraManager::getSingleton().getCameraMode() != 
CameraManager::CAMERA_BEHAVIOR_VEHICLE_CINECAM)
+                                               
CameraManager::getSingleton().getCameraBehavior() != 
CameraManager::CAMERA_BEHAVIOR_VEHICLE_CINECAM)
                                        {
                                                //make it small again
                                                
bigMap->updateRenderMetrics(mWindow);
@@ -5709,7 +5709,7 @@
                if (curr_truck
                        && CameraManager::singletonExists()
                        && CameraManager::getSingleton().hasActiveBehavior()
-                       && CameraManager::getSingleton().getCameraMode() != 
CameraManager::CAMERA_BEHAVIOR_VEHICLE_CINECAM)
+                       && CameraManager::getSingleton().getCameraBehavior() != 
CameraManager::CAMERA_BEHAVIOR_VEHICLE_CINECAM)
                {
                        if (ow) ow->showDashboardOverlays(true, curr_truck);
                        //if (bigMap) bigMap->setVisibility(true);

Modified: trunk/source/main/gameplay/RoRFrameListener.h
===================================================================
--- trunk/source/main/gameplay/RoRFrameListener.h       2012-05-15 18:18:54 UTC 
(rev 2573)
+++ trunk/source/main/gameplay/RoRFrameListener.h       2012-05-15 18:34:34 UTC 
(rev 2574)
@@ -293,6 +293,7 @@
 
        Ogre::RenderWindow *getRenderWindow() { return mWindow; };
        Ogre::SceneManager *getSceneMgr() { return mSceneMgr; };
+       Ogre::Camera *getCamera() { return mCamera; };
        Ogre::String saveTerrainMesh();
 
        OverlayWrapper *getOverlayWrapper() { return ow; };

Modified: trunk/source/main/gameplay/Savegame.cpp
===================================================================
--- trunk/source/main/gameplay/Savegame.cpp     2012-05-15 18:18:54 UTC (rev 
2573)
+++ trunk/source/main/gameplay/Savegame.cpp     2012-05-15 18:34:34 UTC (rev 
2574)
@@ -80,9 +80,9 @@
                                // WARNING: breaks if Real == double!
                                memcpy(&h.player_pos, pos.ptr(), sizeof(float) 
* 3);
                        }
-                       if(CameraManager::singletonExists() && 
CameraManager::getSingleton().getCamera())
+                       if(RoRFrameListener::eflsingleton->getCamera())
                        {
-                               Vector3 pos = 
CameraManager::getSingleton().getCamera()->getPosition();
+                               Vector3 pos = 
RoRFrameListener::eflsingleton->getCamera()->getPosition();
                                // WARNING: breaks if Real == double!
                                memcpy(&h.cam_pos, pos.ptr(), sizeof(float) * 
3);
                        }

Modified: trunk/source/main/gameplay/SceneMouse.cpp
===================================================================
--- trunk/source/main/gameplay/SceneMouse.cpp   2012-05-15 18:18:54 UTC (rev 
2573)
+++ trunk/source/main/gameplay/SceneMouse.cpp   2012-05-15 18:34:34 UTC (rev 
2574)
@@ -18,12 +18,11 @@
 along with Rigs of Rods.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include "SceneMouse.h"
-#include "RoRFrameListener.h"
+
 #include "Beam.h"
 #include "BeamFactory.h"
-#include <Ogre.h>
-
 #include "CameraManager.h"
+#include "RoRFrameListener.h"
 
 #ifdef USE_MYGUI
 # include <MyGUI.h>
@@ -31,7 +30,7 @@
 
 using namespace Ogre;
 
-SceneMouse::SceneMouse(Ogre::SceneManager *scm) :
+SceneMouse::SceneMouse(SceneManager *scm) :
          scm(scm)
 {
        setSingleton(this);
@@ -49,7 +48,7 @@
        pickLineMaterial->getTechnique(0)->getPass(0)->setAmbient(0,0,1);
        
pickLineMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(0,0,1);
 
-       pickLine->begin("PickLineMaterial", 
Ogre::RenderOperation::OT_LINE_LIST);
+       pickLine->begin("PickLineMaterial", RenderOperation::OT_LINE_LIST);
        pickLine->position(0, 0, 0);
        pickLine->position(0, 0, 0);
        pickLine->end();
@@ -67,11 +66,11 @@
 void SceneMouse::releaseMousePick()
 {
        // hide mouse line
-       if(pickLineNode)
+       if (pickLineNode)
                pickLineNode->setVisible(false);
 
        // remove forces
-       if(grab_truck)
+       if (grab_truck)
                grab_truck->mouseMove(minnode, Vector3::ZERO, 0);
 
        // reset the variables
@@ -91,11 +90,11 @@
        const OIS::MouseState ms = _arg.state;
 
        // check if handled by the camera
-       if(!CameraManager::singletonExists() || 
CameraManager::getSingleton().mouseMoved(_arg))
+       if (!CameraManager::singletonExists() || 
CameraManager::getSingleton().mouseMoved(_arg))
                return true;
 
        // experimental mouse hack
-       if(ms.buttonDown(OIS::MB_Left) && mouseGrabState == 0)
+       if (ms.buttonDown(OIS::MB_Left) && mouseGrabState == 0)
        {
                lastMouseY = ms.Y.abs;
                lastMouseX = ms.X.abs;
@@ -108,15 +107,15 @@
                grab_truck = NULL;
                for(int i = 0; i < trucksnum; i++)
                {
-                       if(!trucks[i]) continue;
-                       if(trucks[i] && (trucks[i]->state == ACTIVATED || 
trucks[i]->state == DESACTIVATED))
+                       if (!trucks[i]) continue;
+                       if (trucks[i] && (trucks[i]->state == ACTIVATED || 
trucks[i]->state == DESACTIVATED))
                        {
                                minnode = -1;
                                // walk all nodes
                                for (int j = 0; j < trucks[i]->free_node; j++)
                                {
                                        // check if the mouse grab mode is ok
-                                       if(trucks[i]->nodes[j].mouseGrabMode == 
1) continue;
+                                       if (trucks[i]->nodes[j].mouseGrabMode 
== 1) continue;
 
                                        // check if our ray intersects with the 
node
                                        std::pair<bool, Real> pair = 
mouseRay.intersects(Sphere(trucks[i]->nodes[j].smoothpos, 0.1f));
@@ -134,11 +133,11 @@
                                }
                        }
                        
-                       if(grab_truck) break;
+                       if (grab_truck) break;
                }
 
                // check if we hit a node
-               if(grab_truck && minnode != -1)
+               if (grab_truck && minnode != -1)
                {
                        mouseGrabState = 1;
                        pickLineNode->setVisible(true);
@@ -151,7 +150,7 @@
                                }
                        }
                }
-       } else if(ms.buttonDown(OIS::MB_Left) && mouseGrabState == 1)
+       } else if (ms.buttonDown(OIS::MB_Left) && mouseGrabState == 1)
        {
                // force applying and so forth happens in update()
                lastMouseY = ms.Y.abs;
@@ -159,7 +158,7 @@
                // not fixed
                return false;
 
-       } else if(!ms.buttonDown(OIS::MB_Left) && mouseGrabState == 1)
+       } else if (!ms.buttonDown(OIS::MB_Left) && mouseGrabState == 1)
        {
                releaseMousePick();
                // not fixed
@@ -171,7 +170,7 @@
 
 void SceneMouse::update(float dt)
 {
-       if(mouseGrabState == 1 && grab_truck)
+       if (mouseGrabState == 1 && grab_truck)
        {
                // get values
                Ray mouseRay = getMouseRay();
@@ -186,7 +185,6 @@
                // add forces
                grab_truck->mouseMove(minnode, lastgrabpos, mouseGrabForce);
        }
-
 }
 
 bool SceneMouse::mousePressed(const OIS::MouseEvent& _arg, OIS::MouseButtonID 
_id)
@@ -196,15 +194,16 @@
 
 bool SceneMouse::mouseReleased(const OIS::MouseEvent& _arg, OIS::MouseButtonID 
_id)
 {
-       if(mouseGrabState == 1)
+       if (mouseGrabState == 1)
+       {
                releaseMousePick();
+       }
 
        return true;
 }
 
 bool SceneMouse::keyPressed(const OIS::KeyEvent& _arg)
 {
-       // return false, not handled
        return false;
 }
 
@@ -215,11 +214,8 @@
 
 Ray SceneMouse::getMouseRay()
 {
-       if (CameraManager::singletonExists())
-       {
-               Camera *cam = CameraManager::getSingleton().getCamera();
-               Viewport *vp = cam->getViewport();
-               return 
cam->getCameraToViewportRay((float)lastMouseX/(float)vp->getActualWidth(),(float)lastMouseY/(float)vp->getActualHeight());
-       }
-       return Ray();
+       Camera *cam = RoRFrameListener::eflsingleton->getCamera();
+       Viewport *vp = cam->getViewport();
+
+       return cam->getCameraToViewportRay((float)lastMouseX / 
(float)vp->getActualWidth(), (float)lastMouseY / (float)vp->getActualHeight());
 }

Modified: trunk/source/main/gfx/PreviewRenderer.cpp
===================================================================
--- trunk/source/main/gfx/PreviewRenderer.cpp   2012-05-15 18:18:54 UTC (rev 
2573)
+++ trunk/source/main/gfx/PreviewRenderer.cpp   2012-05-15 18:34:34 UTC (rev 
2574)
@@ -116,7 +116,7 @@
 
        SceneNode *camNode = 
sceneMgr->getRootSceneNode()->createChildSceneNode();
 
-       Camera *cam = CameraManager::getSingleton().getCamera(); 
//RoRFrameListener::eflsingleton->getCamera();
+       Camera *cam = RoRFrameListener::eflsingleton->getCamera();
        cam->setLodBias(1000.0f);
        cam->setAspectRatio(1.0f);
 

Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp       
2012-05-15 18:18:54 UTC (rev 2573)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp       
2012-05-15 18:34:34 UTC (rev 2574)
@@ -28,6 +28,8 @@
 CameraBehaviorVehicleCineCam::CameraBehaviorVehicleCineCam() :
          CameraBehaviorVehicle()
 {
+       fovInternal = FSETTING("FOV Internal", 75);
+       fovExternal = FSETTING("FOV External", 60);
 }
 
 void CameraBehaviorVehicleCineCam::update(const CameraManager::cameraContext_t 
&ctx)
@@ -52,9 +54,13 @@
 
 void CameraBehaviorVehicleCineCam::activate(const 
CameraManager::cameraContext_t &ctx)
 {
-       float fov = FSETTING("FOV Internal", 75);
+       if (ctx.mCurrTruck->freecinecamera <= 0)
+       {
+               CameraManager::getSingleton().switchToNextBehavior();
+               return;
+       }
 
-       ctx.mCamera->setFOVy(Degree(fov));
+       ctx.mCamera->setFOVy(Degree(fovInternal));
 
        camRotX = 0.0f;
        camRotY = Degree(DEFAULT_INTERNAL_CAM_PITCH);
@@ -75,10 +81,8 @@
 
 void CameraBehaviorVehicleCineCam::deactivate(const 
CameraManager::cameraContext_t &ctx)
 {
-       float fov = FSETTING("FOV External", 60);
+       ctx.mCamera->setFOVy(Degree(fovExternal));
 
-       ctx.mCamera->setFOVy(Degree(fov));
-
        ctx.mCurrTruck->prepareInside(false);
 
        if ( ctx.mOverlayWrapper )

Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h 2012-05-15 
18:18:54 UTC (rev 2573)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h 2012-05-15 
18:34:34 UTC (rev 2574)
@@ -39,6 +39,7 @@
 
 protected:
 
+       float fovInternal, fovExternal;
        static const int DEFAULT_INTERNAL_CAM_PITCH = -15;
 };
 

Modified: trunk/source/main/gfx/camera/CameraManager.h
===================================================================
--- trunk/source/main/gfx/camera/CameraManager.h        2012-05-15 18:18:54 UTC 
(rev 2573)
+++ trunk/source/main/gfx/camera/CameraManager.h        2012-05-15 18:34:34 UTC 
(rev 2574)
@@ -61,11 +61,12 @@
 
        void update(float dt);
 
+       void switchBehavior(int newBehavior);
+       void switchToNextBehavior();
+
        bool hasActiveBehavior() { return currentBehavior!=0; };
+       int getCameraBehavior() { return currentBehaviorID; };
 
-       Ogre::Camera *getCamera() { return ctx.mCamera; };
-       int getCameraMode() { return currentBehaviorID; };
-
 protected:
 
        cameraContext_t ctx;
@@ -80,9 +81,6 @@
 
        void createGlobalBehaviors();
 
-       void switchBehavior(int newBehavior);
-       void switchToNextBehavior();
-
        bool mouseMoved(const OIS::MouseEvent& _arg);
        bool mousePressed(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id);
        bool mouseReleased(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id);

Modified: trunk/source/main/physics/Beam.cpp
===================================================================
--- trunk/source/main/physics/Beam.cpp  2012-05-15 18:18:54 UTC (rev 2573)
+++ trunk/source/main/physics/Beam.cpp  2012-05-15 18:34:34 UTC (rev 2574)
@@ -5594,7 +5594,7 @@
        if (driveable != TRUCK ||
                !CameraManager::singletonExists() ||
                !CameraManager::getSingleton().hasActiveBehavior() ||
-               CameraManager::getSingleton().getCameraMode() != 
CameraManager::CAMERA_BEHAVIOR_FREE)
+               CameraManager::getSingleton().getCameraBehavior() != 
CameraManager::CAMERA_BEHAVIOR_FREE)
        {
                return;
        }

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