Revision: 2551 http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2551&view=rev Author: ulteq Date: 2012-05-13 12:31:08 +0000 (Sun, 13 May 2012) Log Message: ----------- -Codechange: CameraSystem WIP (functional)
Modified Paths: -------------- trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp trunk/source/main/gfx/camera/CameraBehaviorCharacter.h trunk/source/main/gfx/camera/CameraBehaviorFree.cpp trunk/source/main/gfx/camera/CameraBehaviorOrbit.cpp trunk/source/main/gfx/camera/CameraBehaviorVehicle.cpp trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp 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/CameraBehaviorVehicleStatic.cpp trunk/source/main/gfx/camera/CameraBehaviorVehicleStatic.h Removed Paths: ------------- trunk/source/main/gfx/camera/CameraBehaviorFixed.cpp trunk/source/main/gfx/camera/CameraBehaviorFixed.h Modified: trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp 2012-05-13 10:03:30 UTC (rev 2550) +++ trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp 2012-05-13 12:31:08 UTC (rev 2551) @@ -24,7 +24,8 @@ using namespace Ogre; CameraBehaviorCharacter::CameraBehaviorCharacter() : - camMode(THIRD_PERSON) + CameraBehaviorOrbit() + , camMode(CHARACTER_THIRD_PERSON) { } @@ -34,18 +35,16 @@ targetDirection = -person->getAngle() - Math::HALF_PI; - if ( camMode == FIRST_PERSON ) + if ( camMode == CHARACTER_FIRST_PERSON ) { camRotY = 0.1f; camRatio = 0.0f; maxCamDist = 0.2f; camCenterPosition = person->getPosition() + Vector3(0.1f, 1.82f, 0.0f); - } else if ( camMode == THIRD_PERSON ) + } else if ( camMode == CHARACTER_THIRD_PERSON ) { camRotY = 0.3f; - camDist = 5.0f; camRatio = 11.0f; - minCamDist = 3.0f; maxCamDist = 6.0f; camCenterPosition = person->getPosition() + Vector3(0.0f, 1.1f, 0.0f); } @@ -57,7 +56,7 @@ bool CameraBehaviorCharacter::switchBehavior(const CameraManager::cameraContext_t &ctx) { - camMode = !camMode; + camMode = (camMode + 1) % CHARACTER_END; return false; -} \ No newline at end of file +} Modified: trunk/source/main/gfx/camera/CameraBehaviorCharacter.h =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorCharacter.h 2012-05-13 10:03:30 UTC (rev 2550) +++ trunk/source/main/gfx/camera/CameraBehaviorCharacter.h 2012-05-13 12:31:08 UTC (rev 2551) @@ -37,11 +37,12 @@ protected: enum CameraModes { - FIRST_PERSON=0, - THIRD_PERSON=1 + CHARACTER_FIRST_PERSON=0, + CHARACTER_THIRD_PERSON, + CHARACTER_END }; - bool camMode; + int camMode; }; #endif // __CAMERA_BEHAVIOR_CHARACTER_ORBIT_H_ Deleted: trunk/source/main/gfx/camera/CameraBehaviorFixed.cpp =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorFixed.cpp 2012-05-13 10:03:30 UTC (rev 2550) +++ trunk/source/main/gfx/camera/CameraBehaviorFixed.cpp 2012-05-13 12:31:08 UTC (rev 2551) @@ -1,27 +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 "CameraBehaviorFixed.h" - -using namespace Ogre; - -void CameraBehaviorFixed::update(const CameraManager::cameraContext_t &ctx) -{ - // TODO -} Deleted: trunk/source/main/gfx/camera/CameraBehaviorFixed.h =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorFixed.h 2012-05-13 10:03:30 UTC (rev 2550) +++ trunk/source/main/gfx/camera/CameraBehaviorFixed.h 2012-05-13 12:31:08 UTC (rev 2551) @@ -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_FIXED_H_ -#define __CAMERA_BEHAVIOR_FIXED_H_ - -#include "RoRPrerequisites.h" - -#include "CameraBehaviorFree.h" - -class CameraBehaviorFixed : public CameraBehaviorFree -{ -public: - - void update(const CameraManager::cameraContext_t &ctx); - - bool mouseMoved(const OIS::MouseEvent& _arg) { return false; }; -}; - -#endif // __CAMERA_BEHAVIOR_FIXED_H_ Modified: trunk/source/main/gfx/camera/CameraBehaviorFree.cpp =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorFree.cpp 2012-05-13 10:03:30 UTC (rev 2550) +++ trunk/source/main/gfx/camera/CameraBehaviorFree.cpp 2012-05-13 12:31:08 UTC (rev 2551) @@ -32,8 +32,6 @@ { ctx.mCamera->setFixedYawAxis(true, Vector3::UNIT_Y); - LOG("entering free camera mode"); - CONSOLE_PUTMESSAGE(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_NOTICE, _L("free camera"), "camera_go.png", 3000, false); #ifdef USE_MYGUI @@ -43,7 +41,7 @@ void CameraBehaviorFree::deactivate(const CameraManager::cameraContext_t &ctx) { - LOG("exiting free camera mode"); + ctx.mCamera->setFixedYawAxis(false); CONSOLE_PUTMESSAGE(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_NOTICE, _L("normal camera"), "camera.png", 3000, false); @@ -91,8 +89,6 @@ ctx.mCamera->yaw(mRotX); ctx.mCamera->pitch(mRotY); - ctx.mCamera->setFixedYawAxis(false); - Vector3 trans = ctx.mCamera->getOrientation() * mTranslateVector; ctx.mCamera->setPosition(ctx.mCamera->getPosition() + trans); } Modified: trunk/source/main/gfx/camera/CameraBehaviorOrbit.cpp =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorOrbit.cpp 2012-05-13 10:03:30 UTC (rev 2550) +++ trunk/source/main/gfx/camera/CameraBehaviorOrbit.cpp 2012-05-13 12:31:08 UTC (rev 2551) @@ -43,7 +43,6 @@ void CameraBehaviorOrbit::activate(const CameraManager::cameraContext_t &ctx) { - camCenterPosition = Vector3(0.0f, 3.0f, 0.0f); } void CameraBehaviorOrbit::deactivate(const CameraManager::cameraContext_t &ctx) Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicle.cpp =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorVehicle.cpp 2012-05-13 10:03:30 UTC (rev 2550) +++ trunk/source/main/gfx/camera/CameraBehaviorVehicle.cpp 2012-05-13 12:31:08 UTC (rev 2551) @@ -1,56 +1,57 @@ -/* -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 "CameraBehaviorVehicle.h" - -#include "Beam.h" -#include "Settings.h" - -using namespace Ogre; - -CameraBehaviorVehicle::CameraBehaviorVehicle() : - camPitching(true) -{ - camRotY = 0.6f; - minCamDist = 8.0f; - maxCamDist = 20.0f; - - if ( SSETTING("External Camera Mode", "Pitching") == "Static" ) - camPitching = false; -} - -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(); - - targetDirection = -atan2(dir.dotProduct(Vector3::UNIT_X), dir.dotProduct(-Vector3::UNIT_Z)); - targetPitch = 0.0f; - - if ( camPitching ) - { - targetPitch = -asin(dir.dotProduct(Vector3::UNIT_Y)); - } - - camRatio = 1.0f / (ctx.mCurrTruck->tdt * 5.0f); - - camCenterPosition = ctx.mCurrTruck->getPosition(); - - CameraBehaviorOrbit::update(ctx); -} +/* +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 "CameraBehaviorVehicle.h" + +#include "Beam.h" +#include "Settings.h" + +using namespace Ogre; + +CameraBehaviorVehicle::CameraBehaviorVehicle() : + CameraBehaviorOrbit() + , camPitching(true) +{ + camRotY = 0.6f; + minCamDist = 8.0f; + maxCamDist = 20.0f; + + if ( SSETTING("External Camera Mode", "Pitching") == "Static" ) + camPitching = false; +} + +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(); + + targetDirection = -atan2(dir.dotProduct(Vector3::UNIT_X), dir.dotProduct(-Vector3::UNIT_Z)); + targetPitch = 0.0f; + + if ( camPitching ) + { + targetPitch = -asin(dir.dotProduct(Vector3::UNIT_Y)); + } + + camRatio = 1.0f / (ctx.mCurrTruck->tdt * 4.0f); + + camCenterPosition = ctx.mCurrTruck->getPosition(); + + CameraBehaviorOrbit::update(ctx); +} Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp 2012-05-13 10:03:30 UTC (rev 2550) +++ trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp 2012-05-13 12:31:08 UTC (rev 2551) @@ -32,13 +32,13 @@ bool CameraBehaviorVehicleCineCam::switchBehavior(const CameraManager::cameraContext_t &ctx) { - if ( ctx.mCurrTruck->currentcamera < ctx.mCurrTruck->freecinecamera-1 ) - { - ctx.mCurrTruck->currentcamera++; - - // TODO - - return false; + if ( ctx.mCurrTruck->currentcamera < ctx.mCurrTruck->freecinecamera-1 ) + { + ctx.mCurrTruck->currentcamera++; + + // TODO + + return false; } // TODO Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp 2012-05-13 10:03:30 UTC (rev 2550) +++ trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp 2012-05-13 12:31:08 UTC (rev 2551) @@ -30,7 +30,7 @@ CameraBehaviorVehicleSpline::CameraBehaviorVehicleSpline() : myManualObject(0) - , myManualObjectNode(0) + , mySceneNode(0) , spline(new SimpleSpline()) , splinePos(0.5f) { @@ -43,7 +43,7 @@ if ( !myManualObject ) { myManualObject = ctx.mSceneMgr->createManualObject(); - myManualObjectNode = ctx.mSceneMgr->getRootSceneNode()->createChildSceneNode(); + mySceneNode = ctx.mSceneMgr->getRootSceneNode()->createChildSceneNode(); myManualObject->begin("tracks/transred", Ogre::RenderOperation::OT_LINE_STRIP); for (int i = 0; i < splineDrawResolution; i++) @@ -52,7 +52,7 @@ } myManualObject->end(); - myManualObjectNode->attachObject(myManualObject); + mySceneNode->attachObject(myManualObject); } } Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h 2012-05-13 10:03:30 UTC (rev 2550) +++ trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h 2012-05-13 12:31:08 UTC (rev 2551) @@ -40,7 +40,7 @@ protected: Ogre::ManualObject *myManualObject; - Ogre::SceneNode* myManualObjectNode; + Ogre::SceneNode* mySceneNode; Ogre::SimpleSpline *spline; float splinePos; static const int splineDrawResolution = 20; Copied: trunk/source/main/gfx/camera/CameraBehaviorVehicleStatic.cpp (from rev 2550, trunk/source/main/gfx/camera/CameraBehaviorFixed.cpp) =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorVehicleStatic.cpp (rev 0) +++ trunk/source/main/gfx/camera/CameraBehaviorVehicleStatic.cpp 2012-05-13 12:31:08 UTC (rev 2551) @@ -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 "CameraBehaviorVehicleStatic.h" + +using namespace Ogre; + +CameraBehaviorVehicleStatic::CameraBehaviorVehicleStatic() +{ + // TODO +} + +void CameraBehaviorVehicleStatic::update(const CameraManager::cameraContext_t &ctx) +{ + // TODO +} Copied: trunk/source/main/gfx/camera/CameraBehaviorVehicleStatic.h (from rev 2549, trunk/source/main/gfx/camera/CameraBehaviorFixed.h) =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorVehicleStatic.h (rev 0) +++ trunk/source/main/gfx/camera/CameraBehaviorVehicleStatic.h 2012-05-13 12:31:08 UTC (rev 2551) @@ -0,0 +1,45 @@ +/* +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_FIXED_H_ +#define __CAMERA_BEHAVIOR_FIXED_H_ + +#include "RoRPrerequisites.h" + +#include "CameraBehaviorVehicle.h" + +class CameraBehaviorVehicleStatic : public CameraBehaviorVehicle +{ +public: + + CameraBehaviorVehicleStatic(); + + void activate(const CameraManager::cameraContext_t &ctx) {}; + void deactivate(const CameraManager::cameraContext_t &ctx) {}; + + void update(const CameraManager::cameraContext_t &ctx); + + bool mouseMoved(const OIS::MouseEvent& _arg) { return false; }; + bool mousePressed(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id) { return false; }; + bool mouseReleased(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id) { return false; }; + + bool switchBehavior(const CameraManager::cameraContext_t &ctx) { return true; }; +}; + +#endif // __CAMERA_BEHAVIOR_FIXED_H_ Modified: trunk/source/main/gfx/camera/CameraManager.cpp =================================================================== --- trunk/source/main/gfx/camera/CameraManager.cpp 2012-05-13 10:03:30 UTC (rev 2550) +++ trunk/source/main/gfx/camera/CameraManager.cpp 2012-05-13 12:31:08 UTC (rev 2551) @@ -35,12 +35,12 @@ #include "water.h" #include "CameraBehaviorCharacter.h" -#include "CameraBehaviorFixed.h" #include "CameraBehaviorFree.h" #include "CameraBehaviorOrbit.h" -#include "CameraBehaviorVehicleCineCam.h" #include "CameraBehaviorVehicle.h" +#include "CameraBehaviorVehicleCineCam.h" #include "CameraBehaviorVehicleSpline.h" +#include "CameraBehaviorVehicleStatic.h" #include "ICameraBehavior.h" @@ -82,7 +82,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_FIXED, new CameraBehaviorFixed())); + globalBehaviors.insert(std::pair<int, ICameraBehavior*>(CAMERA_BEHAVIOR_VEHICLE_STATIC, new CameraBehaviorVehicleStatic())); 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())); @@ -134,19 +134,16 @@ { switchToNextBehavior(); } -#ifdef MYGUI - if (SceneMouse::getSingleton().isMouseGrabbed()) return; // freeze camera -#endif //MYGUI ctx.mCurrTruck = BeamFactory::getSingleton().getCurrentTruck(); ctx.mDt = dt; ctx.mRotScale = Degree(mRotScale); ctx.mTransScale = mTransScale; - if ( !ctx.mCurrTruck && currentBehaviorID != CAMERA_BEHAVIOR_CHARACTER ) + if ( !ctx.mCurrTruck && dynamic_cast<CameraBehaviorVehicle*>(currentBehavior)) { switchBehavior(CAMERA_BEHAVIOR_CHARACTER); - } else if (ctx.mCurrTruck && currentBehaviorID == CAMERA_BEHAVIOR_CHARACTER) + } else if ( ctx.mCurrTruck && !dynamic_cast<CameraBehaviorVehicle*>(currentBehavior) ) { switchBehavior(CAMERA_BEHAVIOR_VEHICLE); } @@ -181,4 +178,4 @@ { if ( !currentBehavior ) return false; return currentBehavior->mouseReleased(_arg, _id); -} \ No newline at end of file +} Modified: trunk/source/main/gfx/camera/CameraManager.h =================================================================== --- trunk/source/main/gfx/camera/CameraManager.h 2012-05-13 10:03:30 UTC (rev 2550) +++ trunk/source/main/gfx/camera/CameraManager.h 2012-05-13 12:31:08 UTC (rev 2551) @@ -51,7 +51,7 @@ enum CameraBehaviors { CAMERA_BEHAVIOR_CHARACTER=0, CAMERA_BEHAVIOR_VEHICLE, - CAMERA_BEHAVIOR_VEHICLE_FIXED, + CAMERA_BEHAVIOR_VEHICLE_STATIC, CAMERA_BEHAVIOR_VEHICLE_SPLINE, CAMERA_BEHAVIOR_VEHICLE_CINECAM, CAMERA_BEHAVIOR_END, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Rigsofrods-devel mailing list Rigsofrods-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel