Revision: 2592
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2592&view=rev
Author:   ulteq
Date:     2012-05-18 22:39:26 +0000 (Fri, 18 May 2012)
Log Message:
-----------
-Codechange: CameraSystem WIP (nearly done)
restricted camera position to positions above ground
re-enabled free cam during truck driving
enabled static cam usage without a truck
made the fov changes in static cam transparent
added checks for ctx.mCurrTruck being null
added mHfinder to the camera context

Modified Paths:
--------------
    trunk/source/main/gfx/camera/CameraBehavior.cpp
    trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp
    trunk/source/main/gfx/camera/CameraBehaviorCharacter.h
    trunk/source/main/gfx/camera/CameraBehaviorFree.cpp
    trunk/source/main/gfx/camera/CameraBehaviorStatic.cpp
    trunk/source/main/gfx/camera/CameraBehaviorStatic.h
    trunk/source/main/gfx/camera/CameraBehaviorVehicle.cpp
    trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp
    trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h
    trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp
    trunk/source/main/gfx/camera/CameraManager.cpp
    trunk/source/main/gfx/camera/CameraManager.h

Modified: trunk/source/main/gfx/camera/CameraBehavior.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehavior.cpp     2012-05-18 15:27:19 UTC 
(rev 2591)
+++ trunk/source/main/gfx/camera/CameraBehavior.cpp     2012-05-18 22:39:26 UTC 
(rev 2592)
@@ -20,6 +20,7 @@
 #include "CameraBehavior.h"
 
 #include "InputEngine.h"
+#include "heightfinder.h"
 #include "Ogre.h"
 
 using namespace Ogre;
@@ -98,15 +99,22 @@
                camDist = std::min(camDist, camDistMax);
        }
 
-       Vector3 desiredPosition = camLookAt + camDist * 0.5f * Vector3( \
-                         sin(targetDirection + camRotX.valueRadians()) * 
cos(targetPitch + camRotY.valueRadians()) \
-                       , sin(targetPitch     + camRotY.valueRadians()) \
-                       , cos(targetDirection + camRotX.valueRadians()) * 
cos(targetPitch + camRotY.valueRadians()) \
+       Vector3 desiredPosition = camLookAt + camDist * 0.5f * Vector3(
+                         sin(targetDirection + camRotX.valueRadians()) * 
cos(targetPitch + camRotY.valueRadians())
+                       , sin(targetPitch     + camRotY.valueRadians())
+                       , cos(targetDirection + camRotX.valueRadians()) * 
cos(targetPitch + camRotY.valueRadians())
                        );
 
-       Vector3 position = (desiredPosition + ctx.mCamera->getPosition() * 
camIntertia) / (1.0f + camIntertia);
+       if ( ctx.mHfinder )
+       {
+               float h = ctx.mHfinder->getHeightAt(desiredPosition.x, 
desiredPosition.z) + 1.0f;
 
-       ctx.mCamera->setPosition(position);
+               desiredPosition.y = std::max(h, desiredPosition.y);
+       }
+
+       Vector3 camTrans = (desiredPosition - ctx.mCamera->getPosition()) 0.1f;
+
+       ctx.mCamera->move(camTrans);
        ctx.mCamera->lookAt(camLookAt);
 }
 

Modified: trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp    2012-05-18 
15:27:19 UTC (rev 2591)
+++ trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp    2012-05-18 
22:39:26 UTC (rev 2592)
@@ -49,6 +49,9 @@
                camRotY += Degree(ms.Y.rel * 0.13f);
                angle   +=        ms.X.rel * 0.01f;
 
+               camRotY  = Radian(std::min(+Math::HALF_PI * 0.65f, 
camRotY.valueRadians()));
+               camRotY  = Radian(std::max(camRotY.valueRadians(), 
-Math::HALF_PI * 0.9f));
+
                ctx.mCharacter->setAngle(angle);
 
 #ifdef USE_MYGUI
@@ -61,6 +64,15 @@
        return CameraBehavior::mouseMoved(ctx, _arg);
 }
 
+void CameraBehaviorCharacter::activate(const CameraManager::cameraContext_t 
&ctx, bool reset)
+{
+       if ( reset )
+       {
+               camMode = CHARACTER_THIRD_PERSON;
+               this->reset(ctx);
+       }
+}
+
 void CameraBehaviorCharacter::reset(const CameraManager::cameraContext_t &ctx)
 {
        camRotX =  0.0f;
@@ -82,9 +94,7 @@
 
 bool CameraBehaviorCharacter::switchBehavior(const 
CameraManager::cameraContext_t &ctx)
 {
-       camMode = (camMode + 1) % CHARACTER_END;
-
        reset(ctx);
 
-       return false;
+       return ++camMode >= CHARACTER_END;
 }

Modified: trunk/source/main/gfx/camera/CameraBehaviorCharacter.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorCharacter.h      2012-05-18 
15:27:19 UTC (rev 2591)
+++ trunk/source/main/gfx/camera/CameraBehaviorCharacter.h      2012-05-18 
22:39:26 UTC (rev 2592)
@@ -34,6 +34,7 @@
 
        bool mouseMoved(const CameraManager::cameraContext_t &ctx, const 
OIS::MouseEvent& _arg);
 
+       void activate(const CameraManager::cameraContext_t &ctx, bool reset = 
true);
        void reset(const CameraManager::cameraContext_t &ctx);
 
        bool switchBehavior(const CameraManager::cameraContext_t &ctx);
@@ -41,8 +42,8 @@
 protected:
 
        enum CameraModes {
-               CHARACTER_FIRST_PERSON=0,
-               CHARACTER_THIRD_PERSON,
+               CHARACTER_THIRD_PERSON=0,
+               CHARACTER_FIRST_PERSON,
                CHARACTER_END
        };
 

Modified: trunk/source/main/gfx/camera/CameraBehaviorFree.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorFree.cpp 2012-05-18 15:27:19 UTC 
(rev 2591)
+++ trunk/source/main/gfx/camera/CameraBehaviorFree.cpp 2012-05-18 22:39:26 UTC 
(rev 2592)
@@ -1,96 +1,106 @@
-/*
-This source file is part of Rigs of Rods
-Copyright 2005-2012 Pierre-Michel Ricordel
-Copyright 2007-2012 Thomas Fischer
-
-For more information, see http://www.rigsofrods.com/
-
-Rigs of Rods is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License version 3, as
-published by the Free Software Foundation.
-
-Rigs of Rods is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Rigs of Rods.  If not, see <http://www.gnu.org/licenses/>.
-*/
-#include "CameraBehaviorFree.h"
-
-#include "InputEngine.h"
-#include "mygui/BaseLayout.h"
-#include "Ogre.h"
-
-using namespace Ogre;
-
-void CameraBehaviorFree::update(const CameraManager::cameraContext_t &ctx)
-{
-       Vector3 mTrans(Vector3::ZERO);
-       Degree mRotX(0.0f);
-       Degree mRotY(0.0f);
-
-       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_SIDESTEP_LEFT) )
-       {
-               mTrans.x -= ctx.mTransScale;
-       }
-       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_SIDESTEP_RIGHT) )
-       {
-               mTrans.x += ctx.mTransScale;
-       }
-
-       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_FORWARD) )
-       {
-               mTrans.z -= ctx.mTransScale;
-       }
-       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_BACKWARDS) )
-       {
-               mTrans.z += ctx.mTransScale;
-       }
-
-       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_ROT_UP) )
-       {
-               mRotY += ctx.mRotScale;
-       }
-       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_ROT_DOWN) )
-       {
-               mRotY -= ctx.mRotScale;
-       }
-
-       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_UP) )
-       {
-               mTrans.y += ctx.mTransScale;
-       }
-       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_DOWN) )
-       {
-               mTrans.y -= ctx.mTransScale;
-       }
-       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_RIGHT) )
-       {
-               mRotX -= ctx.mRotScale;
-       }
-       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_LEFT) )
-       {
-               mRotX += ctx.mRotScale;
-       }
-
-       ctx.mCamera->yaw(mRotX);
-       ctx.mCamera->pitch(mRotY);
-
-       ctx.mCamera->setPosition(ctx.mCamera->getPosition() + 
ctx.mCamera->getOrientation() * mTrans);
-}
-
-bool CameraBehaviorFree::mouseMoved(const CameraManager::cameraContext_t &ctx, 
const OIS::MouseEvent& _arg)
-{
-       const OIS::MouseState ms = _arg.state;
-
-       ctx.mCamera->yaw(Degree(-ms.X.rel * 0.13f));
-       ctx.mCamera->pitch(Degree(-ms.Y.rel * 0.13f));
-
-#ifdef USE_MYGUI
-       MyGUI::PointerManager::getInstance().setVisible(false);
-
-#endif // USE_MYGUI
-       return true;
-}
+/*
+This source file is part of Rigs of Rods
+Copyright 2005-2012 Pierre-Michel Ricordel
+Copyright 2007-2012 Thomas Fischer
+
+For more information, see http://www.rigsofrods.com/
+
+Rigs of Rods is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License version 3, as
+published by the Free Software Foundation.
+
+Rigs of Rods is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Rigs of Rods.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "CameraBehaviorFree.h"
+
+#include "heightfinder.h"
+#include "InputEngine.h"
+#include "mygui/BaseLayout.h"
+#include "Ogre.h"
+
+using namespace Ogre;
+
+void CameraBehaviorFree::update(const CameraManager::cameraContext_t &ctx)
+{
+       Vector3 mTrans(Vector3::ZERO);
+       Degree mRotX(0.0f);
+       Degree mRotY(0.0f);
+
+       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_SIDESTEP_LEFT) )
+       {
+               mTrans.x -= ctx.mTransScale;
+       }
+       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_SIDESTEP_RIGHT) )
+       {
+               mTrans.x += ctx.mTransScale;
+       }
+
+       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_FORWARD) )
+       {
+               mTrans.z -= ctx.mTransScale;
+       }
+       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_BACKWARDS) )
+       {
+               mTrans.z += ctx.mTransScale;
+       }
+
+       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_ROT_UP) )
+       {
+               mRotY += ctx.mRotScale;
+       }
+       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_ROT_DOWN) )
+       {
+               mRotY -= ctx.mRotScale;
+       }
+
+       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_UP) )
+       {
+               mTrans.y += ctx.mTransScale;
+       }
+       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_DOWN) )
+       {
+               mTrans.y -= ctx.mTransScale;
+       }
+       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_RIGHT) )
+       {
+               mRotX -= ctx.mRotScale;
+       }
+       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_LEFT) )
+       {
+               mRotX += ctx.mRotScale;
+       }
+
+       ctx.mCamera->yaw(mRotX);
+       ctx.mCamera->pitch(mRotY);
+
+       Vector3 camPosition = ctx.mCamera->getPosition() + 
ctx.mCamera->getOrientation() * mTrans;
+
+       if ( ctx.mHfinder )
+       {
+               float h = ctx.mHfinder->getHeightAt(camPosition.x, 
camPosition.z) + 1.0f;
+
+               camPosition.y = std::max(h, camPosition.y);
+       }
+
+       ctx.mCamera->setPosition(camPosition);
+}
+
+bool CameraBehaviorFree::mouseMoved(const CameraManager::cameraContext_t &ctx, 
const OIS::MouseEvent& _arg)
+{
+       const OIS::MouseState ms = _arg.state;
+
+       ctx.mCamera->yaw(Degree(-ms.X.rel * 0.13f));
+       ctx.mCamera->pitch(Degree(-ms.Y.rel * 0.13f));
+
+#ifdef USE_MYGUI
+       MyGUI::PointerManager::getInstance().setVisible(false);
+
+#endif // USE_MYGUI
+       return true;
+}

Modified: trunk/source/main/gfx/camera/CameraBehaviorStatic.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorStatic.cpp       2012-05-18 
15:27:19 UTC (rev 2591)
+++ trunk/source/main/gfx/camera/CameraBehaviorStatic.cpp       2012-05-18 
22:39:26 UTC (rev 2592)
@@ -23,7 +23,7 @@
 #include "Character.h"
 #include "DepthOfFieldEffect.h"
 #include "heightfinder.h"
-#include "RoRFrameListener.h"
+#include "Ogre.h"
 
 using namespace Ogre;
 
@@ -44,9 +44,9 @@
        camPosition.z = ((int)(lookAt.z) / 100) * 100 + 50;
        camPosition.y =        lookAt.y;
 
-       if ( RoRFrameListener::hfinder )
+       if ( ctx.mHfinder)
        {
-               float h = RoRFrameListener::hfinder->getHeightAt(camPosition.x, 
camPosition.z);
+               float h = ctx.mHfinder->getHeightAt(camPosition.x, 
camPosition.z);
 
                camPosition.y = std::max(h, camPosition.y);
        }
@@ -67,3 +67,13 @@
                ctx.mDof->setLensFOV(Radian(fov));
        }
 }
+
+void CameraBehaviorStatic::activate(const CameraManager::cameraContext_t &ctx, 
bool reset)
+{
+       fovPreviously = ctx.mCamera->getFOVy();
+}
+
+void CameraBehaviorStatic::deactivate(const CameraManager::cameraContext_t 
&ctx)
+{
+       ctx.mCamera->setFOVy(fovPreviously);
+}

Modified: trunk/source/main/gfx/camera/CameraBehaviorStatic.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorStatic.h 2012-05-18 15:27:19 UTC 
(rev 2591)
+++ trunk/source/main/gfx/camera/CameraBehaviorStatic.h 2012-05-18 22:39:26 UTC 
(rev 2592)
@@ -34,11 +34,15 @@
        bool mousePressed(const CameraManager::cameraContext_t &ctx, const 
OIS::MouseEvent& _arg, OIS::MouseButtonID _id) { return false; };
        bool mouseReleased(const CameraManager::cameraContext_t &ctx, const 
OIS::MouseEvent& _arg, OIS::MouseButtonID _id) { return false; };
 
-       void activate(const CameraManager::cameraContext_t &ctx, bool reset = 
true) {};
-       void deactivate(const CameraManager::cameraContext_t &ctx) {};
+       void activate(const CameraManager::cameraContext_t &ctx, bool reset = 
true);
+       void deactivate(const CameraManager::cameraContext_t &ctx);
        void reset(const CameraManager::cameraContext_t &ctx) {};
 
        bool switchBehavior(const CameraManager::cameraContext_t &ctx) { return 
true; };
+
+protected:
+
+       Ogre::Radian fovPreviously;
 };
 
 #endif // __CAMERA_BEHAVIOR_STATIC_H_

Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicle.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicle.cpp      2012-05-18 
15:27:19 UTC (rev 2591)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicle.cpp      2012-05-18 
22:39:26 UTC (rev 2592)
@@ -47,6 +47,8 @@
                targetPitch = -asin(dir.dotProduct(Vector3::UNIT_Y));
        }
 
+       camIntertia = 1.0f / (ctx.mDt * 4.0f);
+
        camDistMin = ctx.mCurrTruck->getMinimalCameraRadius() * 2.0f;
 
        camLookAt = ctx.mCurrTruck->getPosition();
@@ -56,8 +58,11 @@
 
 void CameraBehaviorVehicle::activate(const CameraManager::cameraContext_t 
&ctx, bool reset)
 {
-       if ( reset )
+       if ( !ctx.mCurrTruck )
        {
+               CameraManager::getSingleton().switchToNextBehavior();
+       } else if ( reset )
+       {
                this->reset(ctx);
        }
 }

Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp       
2012-05-18 15:27:19 UTC (rev 2591)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp       
2012-05-18 22:39:26 UTC (rev 2592)
@@ -27,10 +27,11 @@
 
 CameraBehaviorVehicleCineCam::CameraBehaviorVehicleCineCam() :
          CameraBehaviorVehicle()
+       , currTruck(0)
        , lastCineCam(0)
 {
-       fovInternal = FSETTING("FOV Internal", 75);
-       fovExternal = FSETTING("FOV External", 60);
+       fovInternal = Degree(FSETTING("FOV Internal", 75.0f));
+       fovExternal = Degree(FSETTING("FOV External", 60.0f));
 }
 
 void CameraBehaviorVehicleCineCam::update(const CameraManager::cameraContext_t 
&ctx)
@@ -60,12 +61,12 @@
 
 void CameraBehaviorVehicleCineCam::activate(const 
CameraManager::cameraContext_t &ctx, bool reset)
 {
-       if ( ctx.mCurrTruck->freecinecamera <= 0 )
+       if ( !ctx.mCurrTruck || ctx.mCurrTruck->freecinecamera <= 0 )
        {
                CameraManager::getSingleton().switchToNextBehavior();
                return;
        }
-
+       
        if ( reset )
        {
                lastCineCam = 0;
@@ -74,7 +75,7 @@
 
        currTruck = ctx.mCurrTruck;
 
-       ctx.mCamera->setFOVy(Degree(fovInternal));
+       ctx.mCamera->setFOVy(fovInternal);
 
        ctx.mCurrTruck->prepareInside(true);
 
@@ -93,7 +94,12 @@
 void CameraBehaviorVehicleCineCam::deactivate(const 
CameraManager::cameraContext_t &ctx)
 {
        // Do not use ctx.mCurrTruck in here (could be null)
-       ctx.mCamera->setFOVy(Degree(fovExternal));
+       if ( !currTruck )
+       {
+               return;
+       }
+
+       ctx.mCamera->setFOVy(fovExternal);
                
        currTruck->prepareInside(false);
 
@@ -116,7 +122,7 @@
 
 bool CameraBehaviorVehicleCineCam::switchBehavior(const 
CameraManager::cameraContext_t &ctx)
 {
-       if ( ctx.mCurrTruck->currentcamera < ctx.mCurrTruck->freecinecamera-1 )
+       if ( ctx.mCurrTruck && ctx.mCurrTruck->currentcamera < 
ctx.mCurrTruck->freecinecamera-1 )
        {
                ctx.mCurrTruck->currentcamera++;
                ctx.mCurrTruck->changedCamera();

Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h 2012-05-18 
15:27:19 UTC (rev 2591)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h 2012-05-18 
22:39:26 UTC (rev 2592)
@@ -42,7 +42,7 @@
 
        Beam *currTruck;
        int lastCineCam;
-       float fovInternal, fovExternal;
+       Ogre::Radian fovInternal, fovExternal;
        static const int DEFAULT_INTERNAL_CAM_PITCH = -15;
 };
 

Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp        
2012-05-18 15:27:19 UTC (rev 2591)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp        
2012-05-18 22:39:26 UTC (rev 2592)
@@ -66,14 +66,12 @@
 
 void CameraBehaviorVehicleSpline::activate(const 
CameraManager::cameraContext_t &ctx, bool reset)
 {
-       if ( ctx.mCurrTruck->free_camerarail <= 0 )
+       if ( !ctx.mCurrTruck || ctx.mCurrTruck->free_camerarail <= 0 )
        {
                CameraManager::getSingleton().switchToNextBehavior();
                return;
        }
 
-       CameraBehaviorVehicle::activate(ctx, reset);
-
        if ( !myManualObject )
        {
                myManualObject =  ctx.mSceneMgr->createManualObject();

Modified: trunk/source/main/gfx/camera/CameraManager.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraManager.cpp      2012-05-18 15:27:19 UTC 
(rev 2591)
+++ trunk/source/main/gfx/camera/CameraManager.cpp      2012-05-18 22:39:26 UTC 
(rev 2592)
@@ -21,6 +21,7 @@
 
 #include "BeamFactory.h"
 #include "InputEngine.h"
+#include "RoRFrameListener.h"
 
 #include "CameraBehavior.h"
 #include "CameraBehaviorCharacter.h"
@@ -71,8 +72,8 @@
 void CameraManager::createGlobalBehaviors()
 {
        globalBehaviors.insert(std::pair<int, 
ICameraBehavior*>(CAMERA_BEHAVIOR_CHARACTER, new CameraBehaviorCharacter()));
+       globalBehaviors.insert(std::pair<int, 
ICameraBehavior*>(CAMERA_BEHAVIOR_STATIC, new CameraBehaviorStatic()));
        globalBehaviors.insert(std::pair<int, 
ICameraBehavior*>(CAMERA_BEHAVIOR_VEHICLE, new CameraBehaviorVehicle()));
-       globalBehaviors.insert(std::pair<int, 
ICameraBehavior*>(CAMERA_BEHAVIOR_STATIC, new CameraBehaviorStatic()));
        globalBehaviors.insert(std::pair<int, 
ICameraBehavior*>(CAMERA_BEHAVIOR_VEHICLE_SPLINE, new 
CameraBehaviorVehicleSpline()));
        globalBehaviors.insert(std::pair<int, 
ICameraBehavior*>(CAMERA_BEHAVIOR_VEHICLE_CINECAM, new 
CameraBehaviorVehicleCineCam()));
        globalBehaviors.insert(std::pair<int, 
ICameraBehavior*>(CAMERA_BEHAVIOR_FREE, new CameraBehaviorFree()));
@@ -144,6 +145,7 @@
 
        ctx.mCurrTruck  = BeamFactory::getSingleton().getCurrentTruck();
        ctx.mDt         = dt;
+       ctx.mHfinder    = RoRFrameListener::hfinder;
        ctx.mRotScale   = Degree(mRotScale);
        ctx.mTransScale = mTransScale;
 
@@ -157,7 +159,7 @@
                toggleBehavior(CAMERA_BEHAVIOR_FIXED);
        }
 
-       if ( !ctx.mCurrTruck && 
INPUTENGINE.getEventBoolValueBounce(EV_CAMERA_FREE_MODE) )
+       if ( INPUTENGINE.getEventBoolValueBounce(EV_CAMERA_FREE_MODE) )
        {
                toggleBehavior(CAMERA_BEHAVIOR_FREE);
        }
@@ -167,7 +169,7 @@
                switchBehavior(CAMERA_BEHAVIOR_CHARACTER);
        } else if ( ctx.mCurrTruck && 
!dynamic_cast<CameraBehaviorVehicle*>(currentBehavior) )
        {
-               if ( currentBehaviorID != CAMERA_BEHAVIOR_STATIC && 
currentBehaviorID != CAMERA_BEHAVIOR_FIXED )
+               if ( currentBehaviorID != CAMERA_BEHAVIOR_STATIC && 
currentBehaviorID < CAMERA_BEHAVIOR_END )
                {
                        switchBehavior(CAMERA_BEHAVIOR_VEHICLE);
                }

Modified: trunk/source/main/gfx/camera/CameraManager.h
===================================================================
--- trunk/source/main/gfx/camera/CameraManager.h        2012-05-18 15:27:19 UTC 
(rev 2591)
+++ trunk/source/main/gfx/camera/CameraManager.h        2012-05-18 22:39:26 UTC 
(rev 2592)
@@ -40,6 +40,7 @@
                Beam *mCurrTruck;
                Character *mCharacter;
                DOFManager *mDof;
+               HeightFinder *mHfinder;
                Ogre::Camera *mCamera;
                Ogre::Degree mRotScale;
                Ogre::SceneManager *mSceneMgr;
@@ -51,8 +52,8 @@
 
        enum CameraBehaviors {
                CAMERA_BEHAVIOR_CHARACTER=0,
+               CAMERA_BEHAVIOR_STATIC,
                CAMERA_BEHAVIOR_VEHICLE,
-               CAMERA_BEHAVIOR_STATIC,
                CAMERA_BEHAVIOR_VEHICLE_SPLINE,
                CAMERA_BEHAVIOR_VEHICLE_CINECAM,
                CAMERA_BEHAVIOR_END,

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