Revision: 2707
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2707&view=rev
Author:   ulteq
Date:     2012-05-26 18:49:59 +0000 (Sat, 26 May 2012)
Log Message:
-----------
fixed gfx/camera

Modified Paths:
--------------
    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/CameraBehaviorIsometric.cpp
    trunk/source/main/gfx/camera/CameraBehaviorIsometric.h
    trunk/source/main/gfx/camera/CameraBehaviorStatic.cpp
    trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp
    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-26 18:35:57 UTC 
(rev 2706)
+++ trunk/source/main/gfx/camera/CameraBehavior.cpp     2012-05-26 18:49:59 UTC 
(rev 2707)
@@ -113,7 +113,7 @@
                desiredPosition.y = std::max(h, desiredPosition.y);
        }
 
-       Vector3 precedingPosition = ctx.mCamera->getPosition(); 
+       Vector3 precedingPosition = gEnv->ogreCamera->getPosition(); 
        
        if ( ctx.mCurrTruck )
        {
@@ -122,8 +122,8 @@
 
        Vector3 camPosition = (1.0f / (camRatio + 1.0f)) * desiredPosition + 
(camRatio / (camRatio + 1.0f)) * precedingPosition;
 
-       ctx.mCamera->setPosition(camPosition);
-       ctx.mCamera->lookAt(camLookAt);
+       gEnv->ogreCamera->setPosition(camPosition);
+       gEnv->ogreCamera->lookAt(camLookAt);
 }
 
 bool CameraBehavior::mouseMoved(const CameraManager::cameraContext_t &ctx, 
const OIS::MouseEvent& _arg)
@@ -144,5 +144,5 @@
 void CameraBehavior::reset(const CameraManager::cameraContext_t &ctx)
 {
        camRotX = 0.0f;
-       ctx.mCamera->setFOVy(ctx.fovExternal);
+       gEnv->ogreCamera->setFOVy(ctx.fovExternal);
 }

Modified: trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp    2012-05-26 
18:35:57 UTC (rev 2706)
+++ trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp    2012-05-26 
18:49:59 UTC (rev 2707)
@@ -33,8 +33,8 @@
 
 void CameraBehaviorCharacter::update(const CameraManager::cameraContext_t &ctx)
 {
-       targetDirection = -ctx.mCharacter->getRotation() - 
Radian(Math::HALF_PI);
-       camLookAt       =  ctx.mCharacter->getPosition() + camPositionOffset;
+       targetDirection = -gEnv->player->getRotation() - Radian(Math::HALF_PI);
+       camLookAt       =  gEnv->player->getPosition() + camPositionOffset;
 
        CameraBehavior::update(ctx);
 }
@@ -44,7 +44,7 @@
        if ( camMode == CHARACTER_FIRST_PERSON )
        {
                const OIS::MouseState ms = _arg.state;
-               Radian angle = ctx.mCharacter->getRotation();
+               Radian angle = gEnv->player->getRotation();
                
                camRotY += Degree(ms.Y.rel * 0.13f);
                angle   += Degree(ms.X.rel * 0.13f);
@@ -52,7 +52,7 @@
                camRotY  = Radian(std::min(+Math::HALF_PI * 0.65f, 
camRotY.valueRadians()));
                camRotY  = Radian(std::max(camRotY.valueRadians(), 
-Math::HALF_PI * 0.9f));
 
-               ctx.mCharacter->setRotation(angle);
+               gEnv->player->setRotation(angle);
 
 #ifdef USE_MYGUI
                MyGUI::PointerManager::getInstance().setVisible(false);

Modified: trunk/source/main/gfx/camera/CameraBehaviorFree.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorFree.cpp 2012-05-26 18:35:57 UTC 
(rev 2706)
+++ trunk/source/main/gfx/camera/CameraBehaviorFree.cpp 2012-05-26 18:49:59 UTC 
(rev 2707)
@@ -95,10 +95,10 @@
                mRotY -= mRotScale;
        }
 
-       ctx.mCamera->yaw(mRotX);
-       ctx.mCamera->pitch(mRotY);
+       gEnv->ogreCamera->yaw(mRotX);
+       gEnv->ogreCamera->pitch(mRotY);
 
-       Vector3 camPosition = ctx.mCamera->getPosition() + 
ctx.mCamera->getOrientation() * mTrans.normalisedCopy() * mTransScale;
+       Vector3 camPosition = gEnv->ogreCamera->getPosition() + 
gEnv->ogreCamera->getOrientation() * mTrans.normalisedCopy() * mTransScale;
 
        if ( gEnv->heightFinder )
        {
@@ -107,15 +107,15 @@
                camPosition.y = std::max(h, camPosition.y);
        }
 
-       ctx.mCamera->setPosition(camPosition);
+       gEnv->ogreCamera->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));
+       gEnv->ogreCamera->yaw(Degree(-ms.X.rel * 0.13f));
+       gEnv->ogreCamera->pitch(Degree(-ms.Y.rel * 0.13f));
 
 #ifdef USE_MYGUI
        MyGUI::PointerManager::getInstance().setVisible(false);

Modified: trunk/source/main/gfx/camera/CameraBehaviorIsometric.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorIsometric.cpp    2012-05-26 
18:35:57 UTC (rev 2706)
+++ trunk/source/main/gfx/camera/CameraBehaviorIsometric.cpp    2012-05-26 
18:49:59 UTC (rev 2707)
@@ -21,119 +21,17 @@
 
 #include "Console.h"
 #include "DepthOfFieldEffect.h"
-#include "IHeightFinder.h"
-#include "InputEngine.h"
 #include "language.h"
-#include "mygui/BaseLayout.h"
-#include "Ogre.h"
 
 using namespace Ogre;
 
-void CameraBehaviorIsometric::update(const CameraManager::cameraContext_t &ctx)
+void CameraBehaviorIsometric::activate(const CameraManager::cameraContext_t 
&ctx, bool reset /* = true */)
 {
-       Degree mRotX(0.0f);
-       Degree mRotY(0.0f);
-       Degree mRotScale(ctx.mRotScale);
-       Vector3 mTrans(Vector3::ZERO);
-       Real mTransScale(ctx.mTransScale);
-
-       if(INPUTENGINE.isKeyDown(OIS::KC_LSHIFT) || 
INPUTENGINE.isKeyDown(OIS::KC_RSHIFT))
+       if ( ctx.mDof )
        {
-               mRotScale   *= 3.0f;
-               mTransScale *= 3.0f;
+               ctx.mDof->setFocusMode(DOFManager::Auto);
        }
-       if(INPUTENGINE.isKeyDown(OIS::KC_LCONTROL))
-       {
-               mRotScale   *= 20.0f;
-               mTransScale *= 20.0f;
-       }
-       if(INPUTENGINE.isKeyDown(OIS::KC_LMENU))
-       {
-               mRotScale   *= 0.1f;
-               mTransScale *= 0.1f;
-       }
-
-       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_SIDESTEP_LEFT) )
-       {
-               mTrans.x -= mTransScale;
-       }
-       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_SIDESTEP_RIGHT) )
-       {
-               mTrans.x += mTransScale;
-       }
-       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_FORWARD) )
-       {
-               mTrans.z -= mTransScale;
-       }
-       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_BACKWARDS) )
-       {
-               mTrans.z += mTransScale;
-       }
-       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_UP) )
-       {
-               mTrans.y += mTransScale;
-       }
-       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_DOWN) )
-       {
-               mTrans.y -= mTransScale;
-       }
-
-       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_RIGHT) )
-       {
-               mRotX -= mRotScale;
-       }
-       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_LEFT) )
-       {
-               mRotX += mRotScale;
-       }
-       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_ROT_UP) )
-       {
-               mRotY += mRotScale;
-       }
-       if ( INPUTENGINE.getEventBoolValue(EV_CHARACTER_ROT_DOWN) )
-       {
-               mRotY -= mRotScale;
-       }
-
-       ctx.mCamera->yaw(mRotX);
-       ctx.mCamera->pitch(mRotY);
-
-       Vector3 camPosition = ctx.mCamera->getPosition() + 
ctx.mCamera->getOrientation() * mTrans.normalisedCopy() * mTransScale;
-
-       if ( gEnv->heightFinder )
-       {
-               camPosition.y = gEnv->heightFinder->getHeightAt(camPosition.x, 
camPosition.z) + 20.0f;
-       }
-
-       ctx.mCamera->setPosition(camPosition);
-}
-
-bool CameraBehaviorIsometric::mouseMoved(const CameraManager::cameraContext_t 
&ctx, const OIS::MouseEvent& _arg)
-{
-       const OIS::MouseState ms = _arg.state;
-
-       if(ms.buttonDown(OIS::MB_Right))
-       {
-               ctx.mCamera->yaw(Degree(-ms.X.rel * 0.13f));
-               ctx.mCamera->pitch(Degree(-ms.Y.rel * 0.13f));
-               return true;
-       }
-
 #ifdef USE_MYGUI
-       MyGUI::PointerManager::getInstance().setVisible(true);
+       Console::getSingleton().putMessage(Console::CONSOLE_MSGTYPE_INFO, 
Console::CONSOLE_SYSTEM_NOTICE, _L("fixed free camera"), "camera_link.png", 
3000);
 #endif // USE_MYGUI
-       return false;
 }
-
-void CameraBehaviorIsometric::activate(const CameraManager::cameraContext_t 
&ctx, bool reset /* = true */)
-{
-       if ( ctx.mDof )
-               ctx.mDof->setEnabled(false);
-
-       ctx.mCamera->yaw(Degree(-45));
-       ctx.mCamera->pitch(Degree(-45));
-
-#ifdef USE_MYGUI
-       Console::getSingleton().putMessage(Console::CONSOLE_MSGTYPE_INFO, 
Console::CONSOLE_SYSTEM_NOTICE, _L("isometric camera"), "camera_go.png", 3000);
-#endif // USE_MYGUI
-}

Modified: trunk/source/main/gfx/camera/CameraBehaviorIsometric.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorIsometric.h      2012-05-26 
18:35:57 UTC (rev 2706)
+++ trunk/source/main/gfx/camera/CameraBehaviorIsometric.h      2012-05-26 
18:49:59 UTC (rev 2707)
@@ -28,9 +28,9 @@
 {
 public:
 
-       void update(const CameraManager::cameraContext_t &ctx);
+       void update(const CameraManager::cameraContext_t &ctx) {};
 
-       bool mouseMoved(const CameraManager::cameraContext_t &ctx, const 
OIS::MouseEvent& _arg);
+       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; };
 

Modified: trunk/source/main/gfx/camera/CameraBehaviorStatic.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorStatic.cpp       2012-05-26 
18:35:57 UTC (rev 2706)
+++ trunk/source/main/gfx/camera/CameraBehaviorStatic.cpp       2012-05-26 
18:49:59 UTC (rev 2707)
@@ -37,7 +37,7 @@
                lookAt = ctx.mCurrTruck->getPosition();
        } else
        {
-               lookAt = ctx.mCharacter->getPosition();
+               lookAt = gEnv->player->getPosition();
        }
 
        camPosition.x = ((int)(lookAt.x) / 100) * 100 + 50;
@@ -56,9 +56,9 @@
        float camDist = camPosition.distance(lookAt);
        float fov = atan2(20.0f, camDist);
 
-       ctx.mCamera->setPosition(camPosition);
-       ctx.mCamera->lookAt(lookAt);
-       ctx.mCamera->setFOVy(Radian(fov));
+       gEnv->ogreCamera->setPosition(camPosition);
+       gEnv->ogreCamera->lookAt(lookAt);
+       gEnv->ogreCamera->setFOVy(Radian(fov));
 
        if ( ctx.mDof )
        {
@@ -70,12 +70,12 @@
 
 void CameraBehaviorStatic::activate(const CameraManager::cameraContext_t &ctx, 
bool reset /* = true */)
 {
-       fovPreviously = ctx.mCamera->getFOVy();
+       fovPreviously = gEnv->ogreCamera->getFOVy();
 }
 
 void CameraBehaviorStatic::deactivate(const CameraManager::cameraContext_t 
&ctx)
 {
-       ctx.mCamera->setFOVy(fovPreviously);
+       gEnv->ogreCamera->setFOVy(fovPreviously);
 
        if ( ctx.mDof )
        {

Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp       
2012-05-26 18:35:57 UTC (rev 2706)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp       
2012-05-26 18:49:59 UTC (rev 2707)
@@ -52,8 +52,8 @@
 
        Quaternion orientation = Quaternion(camRotX, up) * 
Quaternion(Degree(180.0) + camRotY, roll) * Quaternion(roll, up, dir);
 
-       
ctx.mCamera->setPosition(ctx.mCurrTruck->nodes[ctx.mCurrTruck->cinecameranodepos[ctx.mCurrTruck->currentcamera]].smoothpos);
-       ctx.mCamera->setOrientation(orientation);
+       
gEnv->ogreCamera->setPosition(ctx.mCurrTruck->nodes[ctx.mCurrTruck->cinecameranodepos[ctx.mCurrTruck->currentcamera]].smoothpos);
+       gEnv->ogreCamera->setOrientation(orientation);
 }
 
 void CameraBehaviorVehicleCineCam::activate(const 
CameraManager::cameraContext_t &ctx, bool reset /* = true */)
@@ -70,7 +70,7 @@
 
        currTruck = ctx.mCurrTruck;
 
-       ctx.mCamera->setFOVy(ctx.fovInternal);
+       gEnv->ogreCamera->setFOVy(ctx.fovInternal);
 
        ctx.mCurrTruck->prepareInside(true);
 
@@ -94,7 +94,7 @@
                return;
        }
 
-       ctx.mCamera->setFOVy(ctx.fovExternal);
+       gEnv->ogreCamera->setFOVy(ctx.fovExternal);
                
        currTruck->prepareInside(false);
 
@@ -114,7 +114,7 @@
 {
        CameraBehavior::reset(ctx);
        camRotY = Degree(DEFAULT_INTERNAL_CAM_PITCH);
-       ctx.mCamera->setFOVy(ctx.fovInternal);
+       gEnv->ogreCamera->setFOVy(ctx.fovInternal);
 }
 
 bool CameraBehaviorVehicleCineCam::switchBehavior(const 
CameraManager::cameraContext_t &ctx)

Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp        
2012-05-26 18:35:57 UTC (rev 2706)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp        
2012-05-26 18:49:59 UTC (rev 2707)
@@ -75,8 +75,8 @@
 
        if ( !myManualObject )
        {
-               myManualObject =  ctx.mSceneMgr->createManualObject();
-               mySceneNode = 
ctx.mSceneMgr->getRootSceneNode()->createChildSceneNode();
+               myManualObject = gEnv->ogreSceneManager->createManualObject();
+               mySceneNode = 
gEnv->ogreSceneManager->getRootSceneNode()->createChildSceneNode();
 
                myManualObject->begin("tracks/transred", 
Ogre::RenderOperation::OT_LINE_STRIP);
                for (int i = 0; i < splineDrawResolution; i++)

Modified: trunk/source/main/gfx/camera/CameraManager.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraManager.cpp      2012-05-26 18:35:57 UTC 
(rev 2706)
+++ trunk/source/main/gfx/camera/CameraManager.cpp      2012-05-26 18:49:59 UTC 
(rev 2707)
@@ -40,7 +40,7 @@
 
 using namespace Ogre;
 
-CameraManager::CameraManager(SceneManager *scm, Camera *cam, RoRFrameListener 
*efl, Character *ps, OverlayWrapper *ow, DOFManager *dof) : 
+CameraManager::CameraManager(OverlayWrapper *ow, DOFManager *dof) : 
          currentBehavior(0)
        , currentBehaviorID(-1)
        , mTransScale(1.0f)
@@ -52,13 +52,9 @@
 
        createGlobalBehaviors();
 
-       ctx.mCamera = cam;
-       ctx.mCharacter = ps;
        ctx.mCurrTruck = 0;
        ctx.mDof = dof;
-       ctx.mEfl = efl;
        ctx.mOverlayWrapper = ow;
-       ctx.mSceneMgr = scm;
 }
 
 CameraManager::~CameraManager()

Modified: trunk/source/main/gfx/camera/CameraManager.h
===================================================================
--- trunk/source/main/gfx/camera/CameraManager.h        2012-05-26 18:35:57 UTC 
(rev 2706)
+++ trunk/source/main/gfx/camera/CameraManager.h        2012-05-26 18:49:59 UTC 
(rev 2707)
@@ -33,18 +33,14 @@
 
 public:
 
-       CameraManager(Ogre::SceneManager *scm, Ogre::Camera *cam, 
RoRFrameListener *efl, Character *ps, OverlayWrapper *ow, DOFManager *dof);
+       CameraManager(OverlayWrapper *ow, DOFManager *dof);
        ~CameraManager();
 
        typedef struct cameraContext {
                Beam *mCurrTruck;
-               Character *mCharacter;
                DOFManager *mDof;
-               Ogre::Camera *mCamera;
                Ogre::Degree mRotScale;
-               Ogre::SceneManager *mSceneMgr;
                OverlayWrapper *mOverlayWrapper;
-               RoRFrameListener *mEfl;
                Ogre::Real mDt;
                Ogre::Real mTransScale;
                Ogre::Radian fovInternal;

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