Revision: 2589
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2589&view=rev
Author:   ulteq
Date:     2012-05-17 20:45:37 +0000 (Thu, 17 May 2012)
Log Message:
-----------
-Codechange: CameraSystem WIP (nearly done)
fixed height finder usage in the camera manager
added CameraBehaviorFixed
adaptive CameraBehaviorVehicleSpline (only active, when there is at least one 
camera rail)

Modified Paths:
--------------
    trunk/source/main/gameplay/RoRFrameListener.cpp
    trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp
    trunk/source/main/gfx/camera/CameraBehaviorVehicle.cpp
    trunk/source/main/gfx/camera/CameraBehaviorVehicle.h
    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

Added Paths:
-----------
    trunk/source/main/gfx/camera/CameraBehaviorStatic.cpp
    trunk/source/main/gfx/camera/CameraBehaviorStatic.h

Removed Paths:
-------------
    trunk/source/main/gfx/camera/CameraBehaviorVehicleStatic.cpp
    trunk/source/main/gfx/camera/CameraBehaviorVehicleStatic.h

Modified: trunk/source/main/gameplay/RoRFrameListener.cpp
===================================================================
--- trunk/source/main/gameplay/RoRFrameListener.cpp     2012-05-17 18:13:18 UTC 
(rev 2588)
+++ trunk/source/main/gameplay/RoRFrameListener.cpp     2012-05-17 20:45:37 UTC 
(rev 2589)
@@ -1132,7 +1132,7 @@
        person = (Character *)CharacterFactory::getSingleton().createLocal(-1);
        
        // init camera manager after mygui and after we have a character
-       new CameraManager(mSceneMgr, mCamera, this, hfinder, person, ow, dof);
+       new CameraManager(mSceneMgr, mCamera, this, person, ow, dof);
 
        person->setVisible(false);
 

Modified: trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp    2012-05-17 
18:13:18 UTC (rev 2588)
+++ trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp    2012-05-17 
20:45:37 UTC (rev 2589)
@@ -47,7 +47,7 @@
                float angle = ctx.mCharacter->getAngle();
                
                camRotY += Degree(ms.Y.rel * 0.13f);
-               angle   +=        ms.X.rel * 0.13f;
+               angle   +=        ms.X.rel * 0.01f;
 
                ctx.mCharacter->setAngle(angle);
 

Added: trunk/source/main/gfx/camera/CameraBehaviorStatic.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorStatic.cpp                       
        (rev 0)
+++ trunk/source/main/gfx/camera/CameraBehaviorStatic.cpp       2012-05-17 
20:45:37 UTC (rev 2589)
@@ -0,0 +1,67 @@
+/*
+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 "CameraBehaviorStatic.h"
+
+#include "Beam.h"
+#include "Character.h"
+#include "DepthOfFieldEffect.h"
+#include "heightfinder.h"
+#include "RoRFrameListener.h"
+
+using namespace Ogre;
+
+void CameraBehaviorStatic::update(const CameraManager::cameraContext_t &ctx)
+{
+       Vector3 lookAt(Vector3::ZERO);
+       Vector3 camPosition(0.0f, 0.0f, 5.0f);
+
+       if ( ctx.mCurrTruck )
+       {
+               lookAt = ctx.mCurrTruck->getPosition();
+       } else
+       {
+               lookAt = ctx.mCharacter->getPosition();
+       }
+
+       camPosition.x = ((int)(lookAt.x) / 100) * 100 + 50;
+       camPosition.z = ((int)(lookAt.z) / 100) * 100 + 50;
+
+       if ( RoRFrameListener::hfinder )
+       {
+               camPosition.y += 
RoRFrameListener::hfinder->getHeightAt(camPosition.x, camPosition.z);
+       } else
+       {
+               camPosition.y += lookAt.y;
+       }
+       
+       float camDist = camPosition.distance(lookAt);
+       float fov = atan2(20.0f, camDist);
+
+       ctx.mCamera->setPosition(camPosition);
+       ctx.mCamera->lookAt(lookAt);
+       ctx.mCamera->setFOVy(Radian(fov));
+
+       if ( ctx.mDof )
+       {
+               ctx.mDof->setFocusMode(DOFManager::Manual);
+               ctx.mDof->setFocus(camDist);
+               ctx.mDof->setLensFOV(Radian(fov));
+       }
+}

Added: trunk/source/main/gfx/camera/CameraBehaviorStatic.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorStatic.h                         
(rev 0)
+++ trunk/source/main/gfx/camera/CameraBehaviorStatic.h 2012-05-17 20:45:37 UTC 
(rev 2589)
@@ -0,0 +1,44 @@
+/*
+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/>.
+*/
+#ifndef __CAMERA_BEHAVIOR_STATIC_H_
+#define __CAMERA_BEHAVIOR_STATIC_H_
+
+#include "RoRPrerequisites.h"
+
+#include "ICameraBehavior.h"
+
+class CameraBehaviorStatic : public ICameraBehavior
+{
+public:
+
+       void update(const CameraManager::cameraContext_t &ctx);
+
+       bool mouseMoved(const CameraManager::cameraContext_t &ctx, const 
OIS::MouseEvent& _arg) { return false; };
+       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) {};
+       void deactivate(const CameraManager::cameraContext_t &ctx) {};
+       void reset(const CameraManager::cameraContext_t &ctx) {};
+
+       bool switchBehavior(const CameraManager::cameraContext_t &ctx) { return 
true; };
+};
+
+#endif // __CAMERA_BEHAVIOR_STATIC_H_

Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicle.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicle.cpp      2012-05-17 
18:13:18 UTC (rev 2588)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicle.cpp      2012-05-17 
20:45:37 UTC (rev 2589)
@@ -36,8 +36,8 @@
 
 void CameraBehaviorVehicle::update(const CameraManager::cameraContext_t &ctx)
 {
-       Vector3 dir = (currTruck->nodes[currTruck->cameranodepos[0]].smoothpos
-                                - 
currTruck->nodes[currTruck->cameranodedir[0]].smoothpos).normalisedCopy();
+       Vector3 dir = 
(ctx.mCurrTruck->nodes[ctx.mCurrTruck->cameranodepos[0]].smoothpos
+                                - 
ctx.mCurrTruck->nodes[ctx.mCurrTruck->cameranodedir[0]].smoothpos).normalisedCopy();
 
        targetDirection = -atan2(dir.dotProduct(Vector3::UNIT_X), 
dir.dotProduct(-Vector3::UNIT_Z));
        targetPitch     = 0.0f;
@@ -47,15 +47,16 @@
                targetPitch = -asin(dir.dotProduct(Vector3::UNIT_Y));
        }
 
-       camLookAt = currTruck->getPosition();
+       camDistMin = ctx.mCurrTruck->getMinimalCameraRadius() * 2.0f;
 
+       camLookAt = ctx.mCurrTruck->getPosition();
+
        CameraBehavior::update(ctx);
 }
 
 void CameraBehaviorVehicle::activate(const CameraManager::cameraContext_t &ctx)
 {
-       currTruck = ctx.mCurrTruck;
-       camDistMin = currTruck->getMinimalCameraRadius() * 2.0f;
+       camDistMin = ctx.mCurrTruck->getMinimalCameraRadius() * 2.0f;
        reset(ctx);
 }
 

Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicle.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicle.h        2012-05-17 
18:13:18 UTC (rev 2588)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicle.h        2012-05-17 
20:45:37 UTC (rev 2589)
@@ -39,7 +39,6 @@
 
 protected:
 
-       Beam *currTruck;
        bool camPitching;
 };
 

Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp       
2012-05-17 18:13:18 UTC (rev 2588)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp       
2012-05-17 20:45:37 UTC (rev 2589)
@@ -36,13 +36,13 @@
 {
        CameraBehavior::update(ctx);
 
-       Vector3 dir = 
(currTruck->nodes[currTruck->cameranodepos[currTruck->currentcamera]].smoothpos
-                                - 
currTruck->nodes[currTruck->cameranodedir[currTruck->currentcamera]].smoothpos).normalisedCopy();
+       Vector3 dir = 
(ctx.mCurrTruck->nodes[ctx.mCurrTruck->cameranodepos[ctx.mCurrTruck->currentcamera]].smoothpos
+                                - 
ctx.mCurrTruck->nodes[ctx.mCurrTruck->cameranodedir[ctx.mCurrTruck->currentcamera]].smoothpos).normalisedCopy();
 
-       Vector3 roll = 
(currTruck->nodes[currTruck->cameranodepos[currTruck->currentcamera]].smoothpos
-                                 - 
currTruck->nodes[currTruck->cameranoderoll[currTruck->currentcamera]].smoothpos).normalisedCopy();
+       Vector3 roll = 
(ctx.mCurrTruck->nodes[ctx.mCurrTruck->cameranodepos[ctx.mCurrTruck->currentcamera]].smoothpos
+                                 - 
ctx.mCurrTruck->nodes[ctx.mCurrTruck->cameranoderoll[ctx.mCurrTruck->currentcamera]].smoothpos).normalisedCopy();
 
-       if ( currTruck->revroll[currTruck->currentcamera] )
+       if ( ctx.mCurrTruck->revroll[ctx.mCurrTruck->currentcamera] )
        {
                roll = -roll;
        }
@@ -53,42 +53,43 @@
 
        Quaternion orientation = Quaternion(camRotX, up) * 
Quaternion(Degree(180.0) + camRotY, roll) * Quaternion(roll, up, dir);
 
-       
ctx.mCamera->setPosition(currTruck->nodes[currTruck->cinecameranodepos[currTruck->currentcamera]].smoothpos);
+       
ctx.mCamera->setPosition(ctx.mCurrTruck->nodes[ctx.mCurrTruck->cinecameranodepos[ctx.mCurrTruck->currentcamera]].smoothpos);
        ctx.mCamera->setOrientation(orientation);
 }
 
 void CameraBehaviorVehicleCineCam::activate(const 
CameraManager::cameraContext_t &ctx)
 {
-       CameraBehaviorVehicle::activate(ctx);
-
-       if ( currTruck->freecinecamera <= 0 )
+       if ( ctx.mCurrTruck->freecinecamera <= 0 )
        {
                CameraManager::getSingleton().switchToNextBehavior();
                return;
        }
 
+       currTruck = ctx.mCurrTruck;
+
        ctx.mCamera->setFOVy(Degree(fovInternal));
 
        reset(ctx);
 
-       currTruck->prepareInside(true);
+       ctx.mCurrTruck->prepareInside(true);
 
        if ( ctx.mOverlayWrapper )
        {
-               if ( currTruck->driveable == AIRPLANE )
-                       ctx.mOverlayWrapper->showDashboardOverlays(true, 
currTruck);
+               if ( ctx.mCurrTruck->driveable == AIRPLANE )
+                       ctx.mOverlayWrapper->showDashboardOverlays(true, 
ctx.mCurrTruck);
                else
-                       ctx.mOverlayWrapper->showDashboardOverlays(false, 
currTruck);
+                       ctx.mOverlayWrapper->showDashboardOverlays(false, 
ctx.mCurrTruck);
        }
 
-       currTruck->currentcamera = 0;
-       currTruck->changedCamera();
+       ctx.mCurrTruck->currentcamera = 0;
+       ctx.mCurrTruck->changedCamera();
 }
 
 void CameraBehaviorVehicleCineCam::deactivate(const 
CameraManager::cameraContext_t &ctx)
 {
+       // Do not use ctx.mCurrTruck in here (could be null)
        ctx.mCamera->setFOVy(Degree(fovExternal));
-
+               
        currTruck->prepareInside(false);
 
        if ( ctx.mOverlayWrapper )
@@ -108,10 +109,10 @@
 
 bool CameraBehaviorVehicleCineCam::switchBehavior(const 
CameraManager::cameraContext_t &ctx)
 {
-       if ( currTruck->currentcamera < currTruck->freecinecamera-1 )
+       if ( ctx.mCurrTruck->currentcamera < ctx.mCurrTruck->freecinecamera-1 )
        {
-               currTruck->currentcamera++;
-               currTruck->changedCamera();
+               ctx.mCurrTruck->currentcamera++;
+               ctx.mCurrTruck->changedCamera();
                return false;
        }
        return true;

Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h 2012-05-17 
18:13:18 UTC (rev 2588)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h 2012-05-17 
20:45:37 UTC (rev 2589)
@@ -40,6 +40,7 @@
 
 protected:
 
+       Beam *currTruck;
        float 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-17 18:13:18 UTC (rev 2588)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp        
2012-05-17 20:45:37 UTC (rev 2589)
@@ -1,116 +1,123 @@
-/*
-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 "CameraBehaviorVehicleSpline.h"
-
-#include "Beam.h"
-#include "InputEngine.h"
-#include "language.h"
-#include "Ogre.h"
-#include "Settings.h"
-
-using namespace Ogre;
-
-CameraBehaviorVehicleSpline::CameraBehaviorVehicleSpline() :
-         myManualObject(0)
-       , mySceneNode(0)
-       , spline(new SimpleSpline())
-       , splinePos(0.5f)
-{
-}
-
-void CameraBehaviorVehicleSpline::update(const CameraManager::cameraContext_t 
&ctx)
-{
-       Vector3 dir = 
ctx.mCurrTruck->nodes[ctx.mCurrTruck->cameranodepos[0]].smoothpos - 
ctx.mCurrTruck->nodes[ctx.mCurrTruck->cameranodedir[0]].smoothpos;
-       dir.normalise();
-       targetDirection = -atan2(dir.dotProduct(Vector3::UNIT_X), 
dir.dotProduct(-Vector3::UNIT_Z));
-       targetPitch = 0;
-       camIntertia = 1.0f / (ctx.mDt * 4.0f);
-
-       if ( ctx.mCurrTruck->free_camerarail > 0 )
-       {
-               spline->clear();
-               for (int i = 0; i < ctx.mCurrTruck->free_camerarail; i++)
-               {
-                       
spline->addPoint(ctx.mCurrTruck->nodes[ctx.mCurrTruck->cameraRail[i]].AbsPosition);
-               }
-
-               updateSplineDisplay();
-
-               camLookAt = spline->interpolate(splinePos);
-       } else
-       {
-               // fallback :-/
-               camLookAt = ctx.mCurrTruck->getPosition();
-       }
-
-       CameraBehavior::update(ctx);
-}
-
-void CameraBehaviorVehicleSpline::activate(const 
CameraManager::cameraContext_t &ctx)
-{
-       CameraBehavior::activate(ctx);
-
-       if ( !myManualObject )
-       {
-               myManualObject =  ctx.mSceneMgr->createManualObject();
-               mySceneNode = 
ctx.mSceneMgr->getRootSceneNode()->createChildSceneNode();
-
-               myManualObject->begin("tracks/transred", 
Ogre::RenderOperation::OT_LINE_STRIP);
-               for (int i = 0; i < splineDrawResolution; i++)
-               {
-                       myManualObject->position(0, 0, 0);
-               }
-               myManualObject->end();
-
-               mySceneNode->attachObject(myManualObject);
-       }
-}
-
-bool CameraBehaviorVehicleSpline::mouseMoved(const 
CameraManager::cameraContext_t &ctx, const OIS::MouseEvent& _arg)
-{
-       const OIS::MouseState ms = _arg.state;
-
-       if ( INPUTENGINE.isKeyDown(OIS::KC_LCONTROL) && 
ms.buttonDown(OIS::MB_Right) )
-       {
-               splinePos += ms.X.rel * 0.001f;
-               splinePos  = std::max(0.0f, splinePos);
-               splinePos  = std::min(splinePos, 1.0f);
-               return true;
-       } else if ( ms.buttonDown(OIS::MB_Right) )
-       {
-               camRotX += Degree( ms.X.rel * 0.13f);
-               camRotY += Degree(-ms.Y.rel * 0.13f);
-               camDist +=        -ms.Z.rel * 0.02f;
-               return true;
-       }
-       return false;
-}
-
-void CameraBehaviorVehicleSpline::updateSplineDisplay()
-{
-       myManualObject->beginUpdate(0);
-       for (int i = 0; i < splineDrawResolution; i++)
-       {
-               float pos1d = i / (float)splineDrawResolution;
-               Vector3 pos3d = spline->interpolate(pos1d);
-               myManualObject->position(pos3d);
-       }
-       myManualObject->end();
-}
+/*
+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 "CameraBehaviorVehicleSpline.h"
+
+#include "Beam.h"
+#include "InputEngine.h"
+#include "language.h"
+#include "Ogre.h"
+#include "Settings.h"
+
+using namespace Ogre;
+
+CameraBehaviorVehicleSpline::CameraBehaviorVehicleSpline() :
+         CameraBehaviorVehicle()
+       , myManualObject(0)
+       , mySceneNode(0)
+       , spline(new SimpleSpline())
+       , splinePos(0.5f)
+{
+}
+
+void CameraBehaviorVehicleSpline::update(const CameraManager::cameraContext_t 
&ctx)
+{
+       Vector3 dir = 
ctx.mCurrTruck->nodes[ctx.mCurrTruck->cameranodepos[0]].smoothpos - 
ctx.mCurrTruck->nodes[ctx.mCurrTruck->cameranodedir[0]].smoothpos;
+       dir.normalise();
+       targetDirection = -atan2(dir.dotProduct(Vector3::UNIT_X), 
dir.dotProduct(-Vector3::UNIT_Z));
+       targetPitch = 0;
+       camIntertia = 1.0f / (ctx.mDt * 4.0f);
+
+       if ( ctx.mCurrTruck->free_camerarail > 0 )
+       {
+               spline->clear();
+               for (int i = 0; i < ctx.mCurrTruck->free_camerarail; i++)
+               {
+                       
spline->addPoint(ctx.mCurrTruck->nodes[ctx.mCurrTruck->cameraRail[i]].AbsPosition);
+               }
+
+               updateSplineDisplay();
+
+               camLookAt = spline->interpolate(splinePos);
+       } else
+       {
+               // fallback :-/
+               camLookAt = ctx.mCurrTruck->getPosition();
+       }
+
+       CameraBehavior::update(ctx);
+}
+
+void CameraBehaviorVehicleSpline::activate(const 
CameraManager::cameraContext_t &ctx)
+{
+       if ( ctx.mCurrTruck->free_camerarail <= 0 )
+       {
+               CameraManager::getSingleton().switchToNextBehavior();
+               return;
+       }
+
+       CameraBehaviorVehicle::activate(ctx);
+
+       if ( !myManualObject )
+       {
+               myManualObject =  ctx.mSceneMgr->createManualObject();
+               mySceneNode = 
ctx.mSceneMgr->getRootSceneNode()->createChildSceneNode();
+
+               myManualObject->begin("tracks/transred", 
Ogre::RenderOperation::OT_LINE_STRIP);
+               for (int i = 0; i < splineDrawResolution; i++)
+               {
+                       myManualObject->position(0, 0, 0);
+               }
+               myManualObject->end();
+
+               mySceneNode->attachObject(myManualObject);
+       }
+}
+
+bool CameraBehaviorVehicleSpline::mouseMoved(const 
CameraManager::cameraContext_t &ctx, const OIS::MouseEvent& _arg)
+{
+       const OIS::MouseState ms = _arg.state;
+
+       if ( INPUTENGINE.isKeyDown(OIS::KC_LCONTROL) && 
ms.buttonDown(OIS::MB_Right) )
+       {
+               splinePos += ms.X.rel * 0.001f;
+               splinePos  = std::max(0.0f, splinePos);
+               splinePos  = std::min(splinePos, 1.0f);
+               return true;
+       } else if ( ms.buttonDown(OIS::MB_Right) )
+       {
+               camRotX += Degree( ms.X.rel * 0.13f);
+               camRotY += Degree(-ms.Y.rel * 0.13f);
+               camDist +=        -ms.Z.rel * 0.02f;
+               return true;
+       }
+       return false;
+}
+
+void CameraBehaviorVehicleSpline::updateSplineDisplay()
+{
+       myManualObject->beginUpdate(0);
+       for (int i = 0; i < splineDrawResolution; i++)
+       {
+               float pos1d = i / (float)splineDrawResolution;
+               Vector3 pos3d = spline->interpolate(pos1d);
+               myManualObject->position(pos3d);
+       }
+       myManualObject->end();
+}

Deleted: trunk/source/main/gfx/camera/CameraBehaviorVehicleStatic.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicleStatic.cpp        
2012-05-17 18:13:18 UTC (rev 2588)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleStatic.cpp        
2012-05-17 20:45:37 UTC (rev 2589)
@@ -1,32 +0,0 @@
-/*
-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 "CameraBehaviorVehicleStatic.h"
-
-using namespace Ogre;
-
-CameraBehaviorVehicleStatic::CameraBehaviorVehicleStatic()
-{
-       // TODO
-}
-
-void CameraBehaviorVehicleStatic::update(const CameraManager::cameraContext_t 
&ctx)
-{
-       // TODO
-}

Deleted: trunk/source/main/gfx/camera/CameraBehaviorVehicleStatic.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicleStatic.h  2012-05-17 
18:13:18 UTC (rev 2588)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleStatic.h  2012-05-17 
20:45:37 UTC (rev 2589)
@@ -1,45 +0,0 @@
-/*
-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/>.
-*/
-#ifndef __CAMERA_BEHAVIOR_STATIC_H_
-#define __CAMERA_BEHAVIOR_STATIC_H_
-
-#include "RoRPrerequisites.h"
-
-#include "CameraBehaviorVehicle.h"
-
-class CameraBehaviorVehicleStatic : public CameraBehaviorVehicle
-{
-public:
-
-       CameraBehaviorVehicleStatic();
-
-       void update(const CameraManager::cameraContext_t &ctx);
-
-       bool mouseMoved(const CameraManager::cameraContext_t &ctx, const 
OIS::MouseEvent& _arg) { return false; };
-       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) {};
-       void deactivate(const CameraManager::cameraContext_t &ctx) {};
-
-       bool switchBehavior(const CameraManager::cameraContext_t &ctx) { return 
true; };
-};
-
-#endif // __CAMERA_BEHAVIOR_STATIC_H_

Modified: trunk/source/main/gfx/camera/CameraManager.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraManager.cpp      2012-05-17 18:13:18 UTC 
(rev 2588)
+++ trunk/source/main/gfx/camera/CameraManager.cpp      2012-05-17 20:45:37 UTC 
(rev 2589)
@@ -26,16 +26,16 @@
 #include "CameraBehaviorCharacter.h"
 #include "CameraBehaviorFixed.h"
 #include "CameraBehaviorFree.h"
+#include "CameraBehaviorStatic.h"
 #include "CameraBehaviorVehicle.h"
 #include "CameraBehaviorVehicleCineCam.h"
 #include "CameraBehaviorVehicleSpline.h"
-#include "CameraBehaviorVehicleStatic.h"
 
 #include "ICameraBehavior.h"
 
 using namespace Ogre;
 
-CameraManager::CameraManager(SceneManager *scm, Camera *cam, RoRFrameListener 
*efl, HeightFinder *hf, Character *ps, OverlayWrapper *ow, DOFManager *dof) : 
+CameraManager::CameraManager(SceneManager *scm, Camera *cam, RoRFrameListener 
*efl, Character *ps, OverlayWrapper *ow, DOFManager *dof) : 
          currentBehavior(0)
        , currentBehaviorID(-1)
        , mTransScale(1.0f)
@@ -52,7 +52,6 @@
        ctx.mCurrTruck = 0;
        ctx.mDof = dof;
        ctx.mEfl = efl;
-       ctx.mHfinder = hf;
        ctx.mOverlayWrapper = ow;
        ctx.mSceneMgr = scm;
 }
@@ -71,7 +70,7 @@
 {
        globalBehaviors.insert(std::pair<int, 
ICameraBehavior*>(CAMERA_BEHAVIOR_CHARACTER, new CameraBehaviorCharacter()));
        globalBehaviors.insert(std::pair<int, 
ICameraBehavior*>(CAMERA_BEHAVIOR_VEHICLE, new CameraBehaviorVehicle()));
-       globalBehaviors.insert(std::pair<int, 
ICameraBehavior*>(CAMERA_BEHAVIOR_VEHICLE_STATIC, new 
CameraBehaviorVehicleStatic()));
+       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()));
@@ -143,9 +142,12 @@
        if ( !ctx.mCurrTruck && 
dynamic_cast<CameraBehaviorVehicle*>(currentBehavior) )
        {
                switchBehavior(CAMERA_BEHAVIOR_CHARACTER);
-       } else if ( ctx.mCurrTruck && currentBehaviorID != 
CAMERA_BEHAVIOR_FIXED && !dynamic_cast<CameraBehaviorVehicle*>(currentBehavior) 
)
+       } else if ( ctx.mCurrTruck && 
!dynamic_cast<CameraBehaviorVehicle*>(currentBehavior) )
        {
-               switchBehavior(CAMERA_BEHAVIOR_VEHICLE);
+               if ( currentBehaviorID != CAMERA_BEHAVIOR_STATIC && 
currentBehaviorID != CAMERA_BEHAVIOR_FIXED )
+               {
+                       switchBehavior(CAMERA_BEHAVIOR_VEHICLE);
+               }
        }
 
        if ( currentBehavior )

Modified: trunk/source/main/gfx/camera/CameraManager.h
===================================================================
--- trunk/source/main/gfx/camera/CameraManager.h        2012-05-17 18:13:18 UTC 
(rev 2588)
+++ trunk/source/main/gfx/camera/CameraManager.h        2012-05-17 20:45:37 UTC 
(rev 2589)
@@ -33,14 +33,13 @@
 
 public:
 
-       CameraManager(Ogre::SceneManager *scm, Ogre::Camera *cam, 
RoRFrameListener *efl,  HeightFinder *hf, Character *ps, OverlayWrapper *ow, 
DOFManager *dof);
+       CameraManager(Ogre::SceneManager *scm, Ogre::Camera *cam, 
RoRFrameListener *efl, Character *ps, OverlayWrapper *ow, DOFManager *dof);
        ~CameraManager();
 
        typedef struct cameraContext {
                Beam *mCurrTruck;
                Character *mCharacter;
                DOFManager *mDof;
-               HeightFinder *mHfinder;
                Ogre::Camera *mCamera;
                Ogre::Degree mRotScale;
                Ogre::SceneManager *mSceneMgr;
@@ -53,7 +52,7 @@
        enum CameraBehaviors {
                CAMERA_BEHAVIOR_CHARACTER=0,
                CAMERA_BEHAVIOR_VEHICLE,
-               CAMERA_BEHAVIOR_VEHICLE_STATIC,
+               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
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel

Reply via email to