Revision: 2564
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2564&view=rev
Author:   ulteq
Date:     2012-05-14 19:16:35 +0000 (Mon, 14 May 2012)
Log Message:
-----------
-Codechange: CameraSystem WIP
moved sound update routine out of the camera manager
began work on cinecam

Modified Paths:
--------------
    trunk/source/main/gameplay/RoRFrameListener.cpp
    trunk/source/main/gfx/camera/CameraBehavior.cpp
    trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp
    trunk/source/main/gfx/camera/CameraBehaviorFree.cpp
    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/gameplay/RoRFrameListener.cpp
===================================================================
--- trunk/source/main/gameplay/RoRFrameListener.cpp     2012-05-14 17:24:35 UTC 
(rev 2563)
+++ trunk/source/main/gameplay/RoRFrameListener.cpp     2012-05-14 19:16:35 UTC 
(rev 2564)
@@ -1128,7 +1128,7 @@
        person = (Character *)CharacterFactory::getSingleton().createLocal(-1);
        
        // init camera manager after mygui and after we have a character
-       new CameraManager(mSceneMgr, mCamera, this, hfinder);
+       new CameraManager(mSceneMgr, mCamera, this, hfinder, person, ow);
 
        person->setVisible(false);
 
@@ -5390,6 +5390,15 @@
                CameraManager::getSingleton().update(dt);
        }
 
+#ifdef USE_OPENAL
+       // update audio listener position
+       static Vector3 lastCameraPosition;
+       Vector3 cameraSpeed = (mCamera->getPosition() - lastCameraPosition) / 
dt;
+       lastCameraPosition = mCamera->getPosition();
+
+       SoundScriptManager::getSingleton().setCamera(mCamera->getPosition(), 
mCamera->getDirection(), mCamera->getUp(), cameraSpeed);
+#endif // USE_OPENAL
+
        Beam *curr_truck = BeamFactory::getSingleton().getCurrentTruck();
 
        // environment map

Modified: trunk/source/main/gfx/camera/CameraBehavior.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehavior.cpp     2012-05-14 17:24:35 UTC 
(rev 2563)
+++ trunk/source/main/gfx/camera/CameraBehavior.cpp     2012-05-14 19:16:35 UTC 
(rev 2564)
@@ -98,9 +98,9 @@
                camDist = 20;
        }
 
-       if ( minCamDist > 0 )
+       if ( minCamDist > 0.0f )
                camDist = std::max(minCamDist, camDist);
-       if ( maxCamDist > 0 )
+       if ( maxCamDist > 0.0f )
                camDist = std::min(camDist, maxCamDist);
 
        camIdealPosition = camDist * 0.5f * Vector3( \
@@ -112,7 +112,7 @@
        float real_camdist = camIdealPosition.length();
 
        camIdealPosition = camIdealPosition + camCenterPosition + 
camTranslation;
-       Vector3 newPosition = ( camIdealPosition + camRatio * 
ctx.mCamera->getPosition() ) / (camRatio+1.0f);
+       Vector3 newPosition = (camIdealPosition + camRatio * 
ctx.mCamera->getPosition()) / (camRatio + 1.0f);
 
        ctx.mCamera->setPosition(newPosition);
        ctx.mCamera->lookAt(camCenterPosition);

Modified: trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp    2012-05-14 
17:24:35 UTC (rev 2563)
+++ trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp    2012-05-14 
19:16:35 UTC (rev 2564)
@@ -38,8 +38,24 @@
        CameraBehavior::update(ctx);
 }
 
-// TODO: First-person mouse interaction
+bool CameraBehaviorCharacter::mouseMoved(const CameraManager::cameraContext_t 
&ctx, const OIS::MouseEvent& _arg)
+{
+       if ( camMode == CHARACTER_FIRST_PERSON )
+       {
+               const OIS::MouseState ms = _arg.state;
+               float angle = ctx.mCharacter->getAngle();
+               
+               camRotY += Degree((float)ms.Y.rel * 0.13f);
+               angle += ms.X.rel * 0.01f;
 
+               ctx.mCharacter->setAngle(angle);
+
+               return true;
+       }
+
+       return CameraBehavior::mouseMoved(ctx, _arg);
+}
+
 bool CameraBehaviorCharacter::switchBehavior(const 
CameraManager::cameraContext_t &ctx)
 {
        camMode = (camMode + 1) % CHARACTER_END;
@@ -47,9 +63,9 @@
        if ( camMode == CHARACTER_FIRST_PERSON )
        {
                camRotY = 0.1f;
-               camDist = 0.1;
+               camDist = 0.1f;
                camRatio = 0.0f;
-               camPositionOffset = Vector3(0.1f, 1.82f, 0.0f);
+               camPositionOffset = Vector3(0.0f, 1.82f, 0.0f);
        } else if ( camMode == CHARACTER_THIRD_PERSON )
        {
                camRotY = 0.3f;
@@ -60,21 +76,3 @@
 
        return false;
 }
-
-bool CameraBehaviorCharacter::mouseMoved(const CameraManager::cameraContext_t 
&ctx, const OIS::MouseEvent& _arg)
-{
-       if ( camMode == CHARACTER_FIRST_PERSON )
-       {
-               const OIS::MouseState ms = _arg.state;
-               float angle = ctx.mCharacter->getAngle();
-               
-               camRotY += Degree((float)ms.Y.rel * 0.13f);
-               angle += ms.X.rel * 0.01f;
-
-               ctx.mCharacter->setAngle(angle);
-
-               return true;
-       }
-
-       return CameraBehavior::mouseMoved(ctx, _arg);
-}

Modified: trunk/source/main/gfx/camera/CameraBehaviorFree.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorFree.cpp 2012-05-14 17:24:35 UTC 
(rev 2563)
+++ trunk/source/main/gfx/camera/CameraBehaviorFree.cpp 2012-05-14 19:16:35 UTC 
(rev 2564)
@@ -20,36 +20,12 @@
 #include "CameraBehaviorFree.h"
 
 #include "Console.h"
-#include "DepthOfFieldEffect.h"
 #include "InputEngine.h"
-#include "Ogre.h"
-#include "Settings.h"
 #include "language.h"
+#include "Ogre.h"
 
 using namespace Ogre;
 
-void CameraBehaviorFree::activate(const CameraManager::cameraContext_t &ctx)
-{
-       ctx.mCamera->setFixedYawAxis(true, Vector3::UNIT_Y);
-
-       CONSOLE_PUTMESSAGE(Console::CONSOLE_MSGTYPE_INFO, 
Console::CONSOLE_SYSTEM_NOTICE, _L("free camera"), "camera_go.png", 3000, 
false);
-
-#ifdef USE_MYGUI
-       MyGUI::PointerManager::getInstance().setVisible(false);
-#endif // USE_MYGUI
-}
-
-void CameraBehaviorFree::deactivate(const CameraManager::cameraContext_t &ctx)
-{
-       ctx.mCamera->setFixedYawAxis(false);
-
-       CONSOLE_PUTMESSAGE(Console::CONSOLE_MSGTYPE_INFO, 
Console::CONSOLE_SYSTEM_NOTICE, _L("normal camera"), "camera.png", 3000, false);
-
-#ifdef USE_MYGUI
-       MyGUI::PointerManager::getInstance().setVisible(true);
-#endif // USE_MYGUI
-}
-
 void CameraBehaviorFree::update(const CameraManager::cameraContext_t &ctx)
 {
        Vector3 mTranslateVector = Vector3::ZERO;
@@ -93,6 +69,28 @@
        ctx.mCamera->setPosition(ctx.mCamera->getPosition() + trans);
 }
 
+void CameraBehaviorFree::activate(const CameraManager::cameraContext_t &ctx)
+{
+       ctx.mCamera->setFixedYawAxis(true, Vector3::UNIT_Y);
+
+       CONSOLE_PUTMESSAGE(Console::CONSOLE_MSGTYPE_INFO, 
Console::CONSOLE_SYSTEM_NOTICE, _L("free camera"), "camera_go.png", 3000, 
false);
+
+#ifdef USE_MYGUI
+       MyGUI::PointerManager::getInstance().setVisible(false);
+#endif // USE_MYGUI
+}
+
+void CameraBehaviorFree::deactivate(const CameraManager::cameraContext_t &ctx)
+{
+       ctx.mCamera->setFixedYawAxis(false);
+
+       CONSOLE_PUTMESSAGE(Console::CONSOLE_MSGTYPE_INFO, 
Console::CONSOLE_SYSTEM_NOTICE, _L("normal camera"), "camera.png", 3000, false);
+
+#ifdef USE_MYGUI
+       MyGUI::PointerManager::getInstance().setVisible(true);
+#endif // USE_MYGUI
+}
+
 bool CameraBehaviorFree::mouseMoved(const CameraManager::cameraContext_t &ctx, 
const OIS::MouseEvent& _arg)
 {
        const OIS::MouseState ms = _arg.state;

Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicle.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicle.cpp      2012-05-14 
17:24:35 UTC (rev 2563)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicle.cpp      2012-05-14 
19:16:35 UTC (rev 2564)
@@ -38,8 +38,8 @@
 
 void CameraBehaviorVehicle::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();
+       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;

Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp       
2012-05-14 17:24:35 UTC (rev 2563)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp       
2012-05-14 19:16:35 UTC (rev 2564)
@@ -1,4 +1,4 @@
-/*
+/*/
 This source file is part of Rigs of Rods
 Copyright 2005-2012 Pierre-Michel Ricordel
 Copyright 2007-2012 Thomas Fischer
@@ -20,35 +20,75 @@
 #include "CameraBehaviorVehicleCineCam.h"
 
 #include "Beam.h"
-#include "DepthOfFieldEffect.h"
-#include "Settings.h"
+#include "OverlayWrapper.h"
 
 using namespace Ogre;
 
-CameraBehaviorVehicleCineCam::CameraBehaviorVehicleCineCam()
+CameraBehaviorVehicleCineCam::CameraBehaviorVehicleCineCam() :
+         CameraBehaviorVehicle()
 {
+       camDist = 0.1f;
        camRatio = 0.0f;
 }
 
-bool CameraBehaviorVehicleCineCam::switchBehavior(const 
CameraManager::cameraContext_t &ctx)
+void CameraBehaviorVehicleCineCam::update(const CameraManager::cameraContext_t 
&ctx)
 {
-       if ( ctx.mCurrTruck->currentcamera < ctx.mCurrTruck->freecinecamera-1 )
+       Vector3 dir = 
(ctx.mCurrTruck->nodes[ctx.mCurrTruck->cameranodepos[ctx.mCurrTruck->currentcamera]].smoothpos
+                                - 
ctx.mCurrTruck->nodes[ctx.mCurrTruck->cameranodedir[ctx.mCurrTruck->currentcamera]].smoothpos).normalisedCopy();
+
+       targetDirection = -atan2(dir.dotProduct(Vector3::UNIT_X), 
dir.dotProduct(-Vector3::UNIT_Z));
+       targetPitch = 0.0f;
+
+       if ( camPitching )
        {
-               ctx.mCurrTruck->currentcamera++;
+               targetPitch = -asin(dir.dotProduct(Vector3::UNIT_Y));
+       }
 
-               // TODO
+       camCenterPosition = 
ctx.mCurrTruck->nodes[ctx.mCurrTruck->cinecameranodepos[ctx.mCurrTruck->currentcamera]].smoothpos;
 
-               return false;
+       CameraBehavior::update(ctx);
+}
+
+void CameraBehaviorVehicleCineCam::activate(const 
CameraManager::cameraContext_t &ctx)
+{
+       camRotX = 0;
+       camRotY = 
Degree(CameraManager::DEFAULT_INTERNAL_CAM_PITCH).valueRadians();
+
+       ctx.mCurrTruck->prepareInside(true);
+
+       if ( ctx.mOverlayWrapper )
+       {
+               if(ctx.mCurrTruck->driveable == AIRPLANE)
+                       ctx.mOverlayWrapper->showDashboardOverlays(true, 
ctx.mCurrTruck);
+               else
+                       ctx.mOverlayWrapper->showDashboardOverlays(false, 
ctx.mCurrTruck);
        }
-       
-       // TODO
 
-       ctx.mCurrTruck->currentcamera = -1;
+       ctx.mCurrTruck->currentcamera = 0;
+       ctx.mCurrTruck->changedCamera();
+}
 
-       return true;
+void CameraBehaviorVehicleCineCam::deactivate(const 
CameraManager::cameraContext_t &ctx)
+{
+       ctx.mCurrTruck->prepareInside(false);
+
+       if ( ctx.mOverlayWrapper )
+       {
+               ctx.mOverlayWrapper->showDashboardOverlays(true, 
ctx.mCurrTruck);
+       }
+
+       ctx.mCurrTruck->currentcamera= - 1;
+       ctx.mCurrTruck->changedCamera();
 }
 
-void CameraBehaviorVehicleCineCam::update(const CameraManager::cameraContext_t 
&ctx)
+bool CameraBehaviorVehicleCineCam::switchBehavior(const 
CameraManager::cameraContext_t &ctx)
 {
-       // TODO
+       if ( ctx.mCurrTruck->currentcamera < ctx.mCurrTruck->freecinecamera-1 )
+       {
+               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-14 
17:24:35 UTC (rev 2563)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h 2012-05-14 
19:16:35 UTC (rev 2564)
@@ -32,6 +32,9 @@
        
        void update(const CameraManager::cameraContext_t &ctx);
 
+       void activate(const CameraManager::cameraContext_t &ctx);
+       void deactivate(const CameraManager::cameraContext_t &ctx);
+
        bool switchBehavior(const CameraManager::cameraContext_t &ctx);
 };
 

Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp        
2012-05-14 17:24:35 UTC (rev 2563)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp        
2012-05-14 19:16:35 UTC (rev 2564)
@@ -36,38 +36,6 @@
 {
 }
 
-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);
-       }
-}
-
-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();
-}
-
 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;
@@ -96,6 +64,26 @@
        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;
@@ -115,3 +103,15 @@
        }
        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();
+}

Modified: trunk/source/main/gfx/camera/CameraManager.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraManager.cpp      2012-05-14 17:24:35 UTC 
(rev 2563)
+++ trunk/source/main/gfx/camera/CameraManager.cpp      2012-05-14 19:16:35 UTC 
(rev 2564)
@@ -17,22 +17,10 @@
 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 "CameraManager.h"
 
 #include "BeamFactory.h"
-#include "Console.h"
-#include "DepthOfFieldEffect.h"
-#include "envmap.h"
-#include "heightfinder.h"
 #include "InputEngine.h"
-#include "language.h"
-#include "Ogre.h"
-#include "RoRFrameListener.h"
-#include "Settings.h"
-#include "SoundScriptManager.h"
-#include "SkyManager.h"
-#include "water.h"
 
 #include "CameraBehaviorCharacter.h"
 #include "CameraBehaviorFree.h"
@@ -46,7 +34,7 @@
 
 using namespace Ogre;
 
-CameraManager::CameraManager(SceneManager *scm, Camera *cam, RoRFrameListener 
*efl, HeightFinder *hf) : 
+CameraManager::CameraManager(SceneManager *scm, Camera *cam, RoRFrameListener 
*efl, HeightFinder *hf, Character *ps, OverlayWrapper *ow) : 
          currentBehavior(0)
        , currentBehaviorID(-1)
        , mTransScale(1.0f)
@@ -59,11 +47,11 @@
        createGlobalBehaviors();
 
        ctx.mCamera = cam;
-       ctx.mCharacter = efl->person;
+       ctx.mCharacter = ps;
        ctx.mCurrTruck = 0;
        ctx.mEfl = efl;
        ctx.mHfinder = hf;
-       ctx.mLastPosition = Vector3::ZERO;
+       ctx.mOverlayWrapper = ow;
        ctx.mSceneMgr = scm;
 }
 
@@ -171,14 +159,6 @@
        {
                switchBehavior(CAMERA_BEHAVIOR_CHARACTER);
        }
-
-#ifdef USE_OPENAL
-       // update audio listener position
-       Vector3 cameraSpeed = (ctx.mCamera->getPosition() - ctx.mLastPosition) 
/ dt;
-       ctx.mLastPosition = ctx.mCamera->getPosition();
-
-       
SoundScriptManager::getSingleton().setCamera(ctx.mCamera->getPosition(), 
ctx.mCamera->getDirection(), ctx.mCamera->getUp(), cameraSpeed);
-#endif // USE_OPENAL
 }
 
 bool CameraManager::mouseMoved(const OIS::MouseEvent& _arg)

Modified: trunk/source/main/gfx/camera/CameraManager.h
===================================================================
--- trunk/source/main/gfx/camera/CameraManager.h        2012-05-14 17:24:35 UTC 
(rev 2563)
+++ trunk/source/main/gfx/camera/CameraManager.h        2012-05-14 19:16:35 UTC 
(rev 2564)
@@ -33,7 +33,7 @@
 
 public:
 
-       CameraManager(Ogre::SceneManager *scm, Ogre::Camera *cam, 
RoRFrameListener *efl,  HeightFinder *hf);
+       CameraManager(Ogre::SceneManager *scm, Ogre::Camera *cam, 
RoRFrameListener *efl,  HeightFinder *hf, Character *ps, OverlayWrapper *ow);
        ~CameraManager();
 
        typedef struct cameraContext {
@@ -43,7 +43,7 @@
                Ogre::Camera *mCamera;
                Ogre::Degree mRotScale;
                Ogre::SceneManager *mSceneMgr;
-               Ogre::Vector3 mLastPosition;
+               OverlayWrapper *mOverlayWrapper;
                RoRFrameListener *mEfl;
                float mDt;
                float mTransScale;

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