Revision: 2494 http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2494&view=rev Author: ulteq Date: 2012-05-02 09:08:21 +0000 (Wed, 02 May 2012) Log Message: ----------- -Codechange: CameraSystem WIP
Modified Paths: -------------- trunk/source/main/gameplay/RoRFrameListener.cpp trunk/source/main/gfx/camera/CameraBehavior.h trunk/source/main/gfx/camera/CameraBehaviorOrbit.cpp trunk/source/main/gfx/camera/CameraBehaviorOrbit.h trunk/source/main/gfx/camera/CameraBehaviorVehicleOrbit.h trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h trunk/source/main/gfx/camera/CameraManager.cpp trunk/source/main/gfx/camera/CameraManager.h Added Paths: ----------- trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp trunk/source/main/gfx/camera/CameraBehaviorCharacter.h trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h Removed Paths: ------------- trunk/source/main/gfx/camera/CameraBehaviorCharacterOrbit.cpp trunk/source/main/gfx/camera/CameraBehaviorCharacterOrbit.h trunk/source/main/gfx/camera/CameraBehaviorVehicleInternal.cpp trunk/source/main/gfx/camera/CameraBehaviorVehicleInternal.h trunk/source/main/gfx/camera/CameraBehaviorWheelChase.cpp trunk/source/main/gfx/camera/CameraBehaviorWheelChase.h Modified: trunk/source/main/gameplay/RoRFrameListener.cpp =================================================================== --- trunk/source/main/gameplay/RoRFrameListener.cpp 2012-05-02 07:11:31 UTC (rev 2493) +++ trunk/source/main/gameplay/RoRFrameListener.cpp 2012-05-02 09:08:21 UTC (rev 2494) @@ -5086,8 +5086,6 @@ { if (CAMERA_MODE == CameraManager::CAMERA_FREE) return; - CameraManager::getSingleton().triggerFOVUpdate(); - // hide any old dashes if(previousTruck && previousTruck->dash) previousTruck->dash->setVisible3d(false); Modified: trunk/source/main/gfx/camera/CameraBehavior.h =================================================================== --- trunk/source/main/gfx/camera/CameraBehavior.h 2012-05-02 07:11:31 UTC (rev 2493) +++ trunk/source/main/gfx/camera/CameraBehavior.h 2012-05-02 09:08:21 UTC (rev 2494) @@ -33,10 +33,6 @@ class CameraBehavior { -protected: - - float mMoveScale, mRotScale, mMoveSpeed, mRotateSpeed; - public: virtual ~CameraBehavior() {}; @@ -51,6 +47,10 @@ virtual void deactivate(cameraContext_t &ctx) = 0; virtual bool allowInteraction() = 0; + +protected: + + float mMoveScale, mRotScale, mMoveSpeed, mRotateSpeed; }; #endif // __CAMERA_BEHAVIOR_H_ Copied: trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp (from rev 2488, trunk/source/main/gfx/camera/CameraBehaviorCharacterOrbit.cpp) =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp (rev 0) +++ trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp 2012-05-02 09:08:21 UTC (rev 2494) @@ -0,0 +1,32 @@ +/* +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 "CameraBehaviorCharacter.h" + +#include "RoRFrameListener.h" + +void CameraBehaviorCharacter::update(cameraContext_t &ctx) +{ + Character *person = RoRFrameListener::eflsingleton->person; + + targetDirection = -person->getAngle() - Math::HALF_PI; + camCenterPosition = person->getPosition() + Vector3(0.0f, 1.1f, 0.0f); + + CameraBehaviorOrbit::update(ctx); +} Copied: trunk/source/main/gfx/camera/CameraBehaviorCharacter.h (from rev 2488, trunk/source/main/gfx/camera/CameraBehaviorCharacterOrbit.h) =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorCharacter.h (rev 0) +++ trunk/source/main/gfx/camera/CameraBehaviorCharacter.h 2012-05-02 09:08:21 UTC (rev 2494) @@ -0,0 +1,33 @@ +/* +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_CHARACTER_ORBIT_H_ +#define __CAMERA_BEHAVIOR_CHARACTER_ORBIT_H_ + +#include "RoRPrerequisites.h" +#include "CameraBehaviorOrbit.h" + +class CameraBehaviorCharacter : public CameraBehaviorOrbit +{ +public: + + void update(cameraContext_t &ctx); +}; + +#endif // __CAMERA_BEHAVIOR_CHARACTER_ORBIT_H_ Deleted: trunk/source/main/gfx/camera/CameraBehaviorCharacterOrbit.cpp =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorCharacterOrbit.cpp 2012-05-02 07:11:31 UTC (rev 2493) +++ trunk/source/main/gfx/camera/CameraBehaviorCharacterOrbit.cpp 2012-05-02 09:08:21 UTC (rev 2494) @@ -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 "CameraBehaviorCharacterOrbit.h" - -#include "RoRFrameListener.h" - -void CameraBehaviorCharacterOrbit::update(cameraContext_t &ctx) -{ - Character *person = RoRFrameListener::eflsingleton->person; - - targetDirection = -person->getAngle() - Math::HALF_PI; - camCenterPosition = person->getPosition() + Vector3(0.0f, 1.1f, 0.0f); - - CameraBehaviorOrbit::update(ctx); -} Deleted: trunk/source/main/gfx/camera/CameraBehaviorCharacterOrbit.h =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorCharacterOrbit.h 2012-05-02 07:11:31 UTC (rev 2493) +++ trunk/source/main/gfx/camera/CameraBehaviorCharacterOrbit.h 2012-05-02 09:08:21 UTC (rev 2494) @@ -1,33 +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_CHARACTER_ORBIT_H_ -#define __CAMERA_BEHAVIOR_CHARACTER_ORBIT_H_ - -#include "RoRPrerequisites.h" -#include "CameraBehaviorOrbit.h" - -class CameraBehaviorCharacterOrbit : public CameraBehaviorOrbit -{ -public: - - void update(cameraContext_t &ctx); -}; - -#endif // __CAMERA_BEHAVIOR_CHARACTER_ORBIT_H_ Modified: trunk/source/main/gfx/camera/CameraBehaviorOrbit.cpp =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorOrbit.cpp 2012-05-02 07:11:31 UTC (rev 2493) +++ trunk/source/main/gfx/camera/CameraBehaviorOrbit.cpp 2012-05-02 09:08:21 UTC (rev 2494) @@ -30,7 +30,7 @@ CameraBehaviorOrbit::CameraBehaviorOrbit() : camRotX(0.0f) - , camRotY(0.4f) + , camRotY(0.06f) , camDist(5.0f) , minCamDist(3.0f) , camRatio(11.0f) Modified: trunk/source/main/gfx/camera/CameraBehaviorOrbit.h =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorOrbit.h 2012-05-02 07:11:31 UTC (rev 2493) +++ trunk/source/main/gfx/camera/CameraBehaviorOrbit.h 2012-05-02 09:08:21 UTC (rev 2494) @@ -25,13 +25,6 @@ class CameraBehaviorOrbit : public CameraBehavior { -protected: - - Ogre::Radian camRotX, camRotY; - Ogre::Vector3 camIdealPosition, camCenterPosition, camTranslation; - float camDist, minCamDist, camRatio; - float targetDirection, targetPitch; - public: CameraBehaviorOrbit(); @@ -46,6 +39,13 @@ bool mouseReleased(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id) { return false; }; bool allowInteraction() { return false; }; + +protected: + + Ogre::Radian camRotX, camRotY; + Ogre::Vector3 camIdealPosition, camCenterPosition, camTranslation; + float camDist, minCamDist, camRatio; + float targetDirection, targetPitch; }; #endif // __CAMERA_BEHAVIOR_ORBIT_H_ Copied: trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp (from rev 2488, trunk/source/main/gfx/camera/CameraBehaviorVehicleInternal.cpp) =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp (rev 0) +++ trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp 2012-05-02 09:08:21 UTC (rev 2494) @@ -0,0 +1,49 @@ +/* +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 "CameraBehaviorVehicleCineCam.h" + +#include "BeamFactory.h" +#include "CameraManager.h" +#include "Settings.h" + +using namespace Ogre; + +void CameraBehaviorVehicleCineCam::activate(cameraContext_t &ctx) +{ + float fov = FSETTING("FOV Internal", 75); + + DOFManager *dof = CameraManager::getSingleton().getDOFManager(); + if ( dof ) + { + dof->setFocusMode(DOFManager::Manual); + dof->setLensFOV(Degree(fov)); + } + + Camera *cam = CameraManager::getSingleton().getCamera(); + cam->setFOVy(Degree(fov)); +} + +void CameraBehaviorVehicleCineCam::deactivate(cameraContext_t &ctx) +{ +} + +void CameraBehaviorVehicleCineCam::update(cameraContext_t &ctx) +{ +} Copied: trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h (from rev 2488, trunk/source/main/gfx/camera/CameraBehaviorVehicleInternal.h) =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h (rev 0) +++ trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h 2012-05-02 09:08:21 UTC (rev 2494) @@ -0,0 +1,36 @@ +/* +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_VEHICLE_INTERNAL_H_ +#define __CAMERA_BEHAVIOR_VEHICLE_INTERNAL_H_ + +#include "RoRPrerequisites.h" +#include "CameraBehaviorVehicleOrbit.h" + +class CameraBehaviorVehicleCineCam : public CameraBehaviorVehicleOrbit +{ +public: + + void activate(cameraContext_t &ctx); + void deactivate(cameraContext_t &ctx); + + void update(cameraContext_t &ctx); +}; + +#endif // __CAMERA_BEHAVIOR_VEHICLE_INTERNAL_H_ Deleted: trunk/source/main/gfx/camera/CameraBehaviorVehicleInternal.cpp =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorVehicleInternal.cpp 2012-05-02 07:11:31 UTC (rev 2493) +++ trunk/source/main/gfx/camera/CameraBehaviorVehicleInternal.cpp 2012-05-02 09:08:21 UTC (rev 2494) @@ -1,48 +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 "CameraBehaviorVehicleInternal.h" - -#include "CameraManager.h" -#include "Settings.h" - -using namespace Ogre; - -void CameraBehaviorVehicleInternal::activate(cameraContext_t &ctx) -{ - float fov = FSETTING("FOV Internal", 75); - - DOFManager *dof = CameraManager::getSingleton().getDOFManager(); - if ( dof ) - { - dof->setFocusMode(DOFManager::Manual); - dof->setLensFOV(Degree(fov)); - } - - Camera *cam = CameraManager::getSingleton().getCamera(); - cam->setFOVy(Degree(fov)); -} - -void CameraBehaviorVehicleInternal::deactivate(cameraContext_t &ctx) -{ -} - -void CameraBehaviorVehicleInternal::update(cameraContext_t &ctx) -{ -} Deleted: trunk/source/main/gfx/camera/CameraBehaviorVehicleInternal.h =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorVehicleInternal.h 2012-05-02 07:11:31 UTC (rev 2493) +++ trunk/source/main/gfx/camera/CameraBehaviorVehicleInternal.h 2012-05-02 09:08:21 UTC (rev 2494) @@ -1,36 +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_VEHICLE_INTERNAL_H_ -#define __CAMERA_BEHAVIOR_VEHICLE_INTERNAL_H_ - -#include "RoRPrerequisites.h" -#include "CameraBehaviorVehicleOrbit.h" - -class CameraBehaviorVehicleInternal : public CameraBehaviorVehicleOrbit -{ -public: - - void activate(cameraContext_t &ctx); - void deactivate(cameraContext_t &ctx); - - void update(cameraContext_t &ctx); -}; - -#endif // __CAMERA_BEHAVIOR_VEHICLE_INTERNAL_H_ Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleOrbit.h =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorVehicleOrbit.h 2012-05-02 07:11:31 UTC (rev 2493) +++ trunk/source/main/gfx/camera/CameraBehaviorVehicleOrbit.h 2012-05-02 09:08:21 UTC (rev 2494) @@ -25,14 +25,14 @@ class CameraBehaviorVehicleOrbit : public CameraBehaviorOrbit { -protected: - - bool externalCameraMode; - public: CameraBehaviorVehicleOrbit(); void update(cameraContext_t &ctx); + +protected: + + bool externalCameraMode; }; #endif // __CAMERA_BEHAVIOR_VEHICLE_ORBIT_H_ Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h 2012-05-02 07:11:31 UTC (rev 2493) +++ trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h 2012-05-02 09:08:21 UTC (rev 2494) @@ -25,14 +25,6 @@ class CameraBehaviorVehicleSpline : public CameraBehaviorOrbit { -protected: - - Ogre::ManualObject *myManualObject; - Ogre::SceneNode* myManualObjectNode; - Ogre::SimpleSpline *spline; - float splinePos; - static const int splineDrawResolution = 20; - public: CameraBehaviorVehicleSpline(); @@ -43,6 +35,14 @@ void updateSplineDisplay(); bool mouseMoved(const OIS::MouseEvent& _arg); + +protected: + + Ogre::ManualObject *myManualObject; + Ogre::SceneNode* myManualObjectNode; + Ogre::SimpleSpline *spline; + float splinePos; + static const int splineDrawResolution = 20; }; #endif // __CAMERA_BEHAVIOR_VEHICLE_SPLINE_H_ Deleted: trunk/source/main/gfx/camera/CameraBehaviorWheelChase.cpp =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorWheelChase.cpp 2012-05-02 07:11:31 UTC (rev 2493) +++ trunk/source/main/gfx/camera/CameraBehaviorWheelChase.cpp 2012-05-02 09:08:21 UTC (rev 2494) @@ -1,87 +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 "CameraBehaviorWheelChase.h" - -#include "BeamFactory.h" -#include "CameraManager.h" -#include "Console.h" -#include "InputEngine.h" -#include "Settings.h" -#include "language.h" -#include <Ogre.h> - -using namespace Ogre; - -void CameraBehaviorWheelChase::activate(cameraContext_t &ctx) -{ - float fov = FSETTING("FOV External", 60); - - DOFManager *dof = CameraManager::getSingleton().getDOFManager(); - if ( dof ) - { - dof->setFocusMode(DOFManager::Manual); - dof->setLensFOV(Degree(fov)); - } - - Camera *cam = CameraManager::getSingleton().getCamera(); - cam->setFOVy(Degree(fov)); -} - -void CameraBehaviorWheelChase::deactivate(cameraContext_t &ctx) -{ -} - -void CameraBehaviorWheelChase::update(cameraContext_t &ctx) -{ - Beam *curr_truck = BeamFactory::getSingleton().getCurrentTruck(); - if(!curr_truck) return; - - //ctx.cam->setFixedYawAxis(false); - - int i = 0; - - Vector3 axis = curr_truck->wheels[i].refnode1->smoothpos - curr_truck->wheels[i].refnode0->smoothpos; - Vector3 cpos = curr_truck->wheels[i].refnode0->smoothpos - axis * 3; - Vector3 clook = curr_truck->wheels[i].refnode1->smoothpos; - - //ctx.cam->setFixedYawAxis(false); - - ctx.cam->lookAt(clook); - - // TODO: FIX - //ctx.cam->roll(Ogre::Degree(-curr_truck->wheels[i].speed)); - - ctx.cam->setPosition(cpos); -} - -bool CameraBehaviorWheelChase::mouseMoved(const OIS::MouseEvent& _arg) -{ - return false; -} - -bool CameraBehaviorWheelChase::mousePressed(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id) -{ - return false; -} - -bool CameraBehaviorWheelChase::mouseReleased(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id) -{ - return false; -} Deleted: trunk/source/main/gfx/camera/CameraBehaviorWheelChase.h =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorWheelChase.h 2012-05-02 07:11:31 UTC (rev 2493) +++ trunk/source/main/gfx/camera/CameraBehaviorWheelChase.h 2012-05-02 09:08:21 UTC (rev 2494) @@ -1,42 +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_WHEELCHASE_H_ -#define __CAMERA_BEHAVIOR_WHEELCHASE_H_ - -#include "RoRPrerequisites.h" -#include "CameraBehavior.h" - -class CameraBehaviorWheelChase : public CameraBehavior -{ -public: - - void activate(cameraContext_t &ctx); - void deactivate(cameraContext_t &ctx); - - void update(cameraContext_t &ctx); - - bool mouseMoved(const OIS::MouseEvent& _arg); - bool mousePressed(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id); - bool mouseReleased(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id); - - bool allowInteraction() { return false; }; -}; - -#endif // __CAMERA_BEHAVIOR_WHEELCHASE_H_ Modified: trunk/source/main/gfx/camera/CameraManager.cpp =================================================================== --- trunk/source/main/gfx/camera/CameraManager.cpp 2012-05-02 07:11:31 UTC (rev 2493) +++ trunk/source/main/gfx/camera/CameraManager.cpp 2012-05-02 09:08:21 UTC (rev 2494) @@ -29,11 +29,11 @@ #include "SoundScriptManager.h" #include "language.h" -#include "CameraBehaviorCharacterOrbit.h" +#include "CameraBehaviorCharacter.h" #include "CameraBehaviorFixed.h" #include "CameraBehaviorFree.h" #include "CameraBehaviorOrbit.h" -#include "CameraBehaviorVehicleInternal.h" +#include "CameraBehaviorVehicleCineCam.h" #include "CameraBehaviorVehicleOrbit.h" #include "CameraBehaviorVehicleSpline.h" #include "OverlayWrapper.h" @@ -47,9 +47,9 @@ , mDOF(0) , mLastPosition(Vector3::ZERO) , mMoveScale(1.0f) - , mMoveSpeed(50) + , mMoveSpeed(50.0f) , mRotScale(0.1f) - , mRotateSpeed(100) + , mRotateSpeed(100.0f) , mSceneMgr(scm) { setSingleton(this); @@ -64,7 +64,7 @@ ctx.cam = mCamera; ctx.scm = mSceneMgr; - switchBehavior(CAMERA_CHARACTER_ORBIT); + switchBehavior(CAMERA_CHARACTER); switchBehavior(CAMERA_VEHICLE_ORBIT); //switchBehavior(CAMERA_VEHICLE_SPLINE); } @@ -76,8 +76,8 @@ void CameraManager::createGlobalBehaviors() { - globalBehaviors.insert( std::pair<int, CameraBehavior*>(CAMERA_CHARACTER_ORBIT, new CameraBehaviorCharacterOrbit()) ); - globalBehaviors.insert( std::pair<int, CameraBehavior*>(CAMERA_VEHICLE_INTERNAL, new CameraBehaviorVehicleInternal()) ); + globalBehaviors.insert( std::pair<int, CameraBehavior*>(CAMERA_CHARACTER, new CameraBehaviorCharacter()) ); + globalBehaviors.insert( std::pair<int, CameraBehavior*>(CAMERA_VEHICLE_INTERNAL, new CameraBehaviorVehicleCineCam()) ); globalBehaviors.insert( std::pair<int, CameraBehavior*>(CAMERA_VEHICLE_ORBIT, new CameraBehaviorVehicleOrbit()) ); globalBehaviors.insert( std::pair<int, CameraBehavior*>(CAMERA_VEHICLE_SPLINE, new CameraBehaviorVehicleSpline()) ); globalBehaviors.insert( std::pair<int, CameraBehavior*>(CAMERA_FIXED, new CameraBehaviorFixed()) ); @@ -230,11 +230,16 @@ void CameraManager::switchBehavior(int newBehavior) { - if(globalBehaviors.find(newBehavior) == globalBehaviors.end()) return; + if ( globalBehaviors.find(newBehavior) == globalBehaviors.end() ) + { + return; + } // deactivate old - if(currentBehavior) + if ( currentBehavior ) + { currentBehavior->deactivate(ctx); + } // set new currentBehavior = globalBehaviors[newBehavior]; @@ -580,24 +585,24 @@ bool CameraManager::mouseMoved(const OIS::MouseEvent& _arg) { - if(!currentBehavior) return false; + if ( !currentBehavior ) return false; return currentBehavior->mouseMoved(_arg); } bool CameraManager::mousePressed(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id) { - if(!currentBehavior) return false; + if ( !currentBehavior ) return false; return currentBehavior->mousePressed(_arg, _id); } bool CameraManager::mouseReleased(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id) { - if(!currentBehavior) return false; + if ( !currentBehavior ) return false; return currentBehavior->mouseReleased(_arg, _id); } bool CameraManager::allowInteraction() { - if(!currentBehavior) return false; + if ( !currentBehavior ) return false; return currentBehavior->allowInteraction(); } Modified: trunk/source/main/gfx/camera/CameraManager.h =================================================================== --- trunk/source/main/gfx/camera/CameraManager.h 2012-05-02 07:11:31 UTC (rev 2493) +++ trunk/source/main/gfx/camera/CameraManager.h 2012-05-02 09:08:21 UTC (rev 2494) @@ -37,38 +37,14 @@ { friend class SceneMouse; -protected: - - DOFManager *mDOF; - Ogre::Camera *mCamera; - Ogre::Radian pushcamRotX, pushcamRotY; - Ogre::SceneManager *mSceneMgr; - Ogre::Vector3 mLastPosition; - cameraContext_t ctx; - float mMoveScale, mRotScale; - float mMoveSpeed, mRotateSpeed; - - CameraBehavior *currentBehavior; - int currentBehaviorID; - - std::map <int , CameraBehavior *> globalBehaviors; - - void switchBehavior(int newBehavior); - void switchToNextBehavior(); - void createGlobalBehaviors(); - - bool mouseMoved(const OIS::MouseEvent& _arg); - bool mousePressed(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id); - bool mouseReleased(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id); - public: CameraManager(Ogre::SceneManager *scm, Ogre::Camera *cam); ~CameraManager(); - enum + enum CameraBehaviors { - CAMERA_CHARACTER_ORBIT=0 + CAMERA_CHARACTER=0 , CAMERA_VEHICLE_INTERNAL , CAMERA_VEHICLE_ORBIT , CAMERA_VEHICLE_SPLINE @@ -77,7 +53,8 @@ , CAMERA_FREE }; - void triggerFOVUpdate() { /*TODO: Think about this*/ }; + void switchBehavior(int newBehavior); + void switchToNextBehavior(); void update(float dt); bool allowInteraction(); @@ -85,6 +62,28 @@ Ogre::Camera *getCamera() { return mCamera; }; int getCameraMode() { return mCamera->getPolygonMode(); }; inline DOFManager *getDOFManager() { return mDOF; } + +protected: + + DOFManager *mDOF; + Ogre::Camera *mCamera; + Ogre::Radian pushcamRotX, pushcamRotY; + Ogre::SceneManager *mSceneMgr; + Ogre::Vector3 mLastPosition; + cameraContext_t ctx; + float mMoveScale, mRotScale; + float mMoveSpeed, mRotateSpeed; + + CameraBehavior *currentBehavior; + int currentBehaviorID; + + std::map <int , CameraBehavior *> globalBehaviors; + + void createGlobalBehaviors(); + + bool mouseMoved(const OIS::MouseEvent& _arg); + bool mousePressed(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id); + bool mouseReleased(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id); }; #endif // __CAMERA_MANAGER_H_ 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