Revision: 2464 http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2464&view=rev Author: rorthomas Date: 2012-03-15 16:27:33 +0000 (Thu, 15 Mar 2012) Log Message: ----------- work+++, compiles again
Modified Paths: -------------- trunk/source/main/gameplay/RoRFrameListener.cpp trunk/source/main/gameplay/RoRFrameListener.h trunk/source/main/gfx/camera/CameraBehavior.h trunk/source/main/gfx/camera/CameraBehaviorFree.cpp trunk/source/main/gfx/camera/CameraBehaviorFree.h trunk/source/main/gfx/camera/CameraManager.cpp trunk/source/main/gfx/camera/CameraManager.h trunk/source/main/gui/Console.h trunk/source/main/physics/Beam.cpp trunk/source/main/scripting/GameScript.cpp Modified: trunk/source/main/gameplay/RoRFrameListener.cpp =================================================================== --- trunk/source/main/gameplay/RoRFrameListener.cpp 2012-03-15 13:18:31 UTC (rev 2463) +++ trunk/source/main/gameplay/RoRFrameListener.cpp 2012-03-15 16:27:33 UTC (rev 2464) @@ -761,6 +761,9 @@ net_quality_changed=false; freeTruckPosition=false; + mCamera = cam; + new CameraManager(scm, mCamera); + terrainHasTruckShop=false; terrainName = String(); @@ -990,7 +993,6 @@ //joy=new BeamJoystick(mInputManager, deadzone, useforce, &cfg); //useforce=joy->hasForce(); - mCamera = cam; gCamera = cam; mWindow = win; mStatsOn = 0; @@ -1932,11 +1934,13 @@ } #endif //USE_MYGUI + bool cameraAllowsInteraction = CameraManager::getSingleton().allowInteraction(); + // update characters if(loading_state==ALL_LOADED && net) CharacterFactory::getSingleton().updateCharacters(dt); else if(loading_state==ALL_LOADED && !net) - person->update(dt, (CAMERA_MODE == CAMERA_FREE)); + person->update(dt, cameraAllowsInteraction); if(INPUTENGINE.getEventBoolValueBounce(EV_COMMON_QUIT_GAME)) { Modified: trunk/source/main/gameplay/RoRFrameListener.h =================================================================== --- trunk/source/main/gameplay/RoRFrameListener.h 2012-03-15 13:18:31 UTC (rev 2463) +++ trunk/source/main/gameplay/RoRFrameListener.h 2012-03-15 16:27:33 UTC (rev 2464) @@ -340,7 +340,6 @@ //DotSceneLoader* mLoader; Camera* mCamera; - Vector3 cdoppler; collision_box_t *reload_box; Quaternion reload_dir; Modified: trunk/source/main/gfx/camera/CameraBehavior.h =================================================================== --- trunk/source/main/gfx/camera/CameraBehavior.h 2012-03-15 13:18:31 UTC (rev 2463) +++ trunk/source/main/gfx/camera/CameraBehavior.h 2012-03-15 16:27:33 UTC (rev 2464) @@ -21,20 +21,24 @@ #define CAMERABEHAVIOR_H__ #include "RoRPrerequisites.h" +#include <OIS.h> + class CameraBehavior { public: - void update(float dt); + virtual ~CameraBehavior() {}; - bool mouseMoved(const OIS::MouseEvent& _arg); - bool mousePressed(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id); - bool mouseReleased(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id); + virtual void update(float dt) {}; - void activate(); - void deactivate(); -}; + virtual bool mouseMoved(const OIS::MouseEvent& _arg) = 0; + virtual bool mousePressed(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id) = 0; + virtual bool mouseReleased(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id) = 0; -#endif // CAMERAMANAGER_H__ + virtual void activate() = 0; + virtual void deactivate() = 0; + virtual bool allowInteraction() = 0; +}; +#endif // CAMERABEHAVIOR_H__ Modified: trunk/source/main/gfx/camera/CameraBehaviorFree.cpp =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorFree.cpp 2012-03-15 13:18:31 UTC (rev 2463) +++ trunk/source/main/gfx/camera/CameraBehaviorFree.cpp 2012-03-15 16:27:33 UTC (rev 2464) @@ -31,24 +31,24 @@ void CameraBehaviorFree::activate() { // enter free camera mode - if(mDOF) mDOF->setFocusMode(DOFManager::Auto); - storedcameramode = cameramode; - cameramode = CAMERA_FREE; + DOFManager *dof = CameraManager::getSingleton().getDOFManager(); + if(dof) dof->setFocusMode(DOFManager::Auto); + LOG("entering free camera mode"); -#ifdef USE_MYGUI - Console::getSingleton().putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_NOTICE, _L("free camera"), "camera_go.png", 3000); -#endif // USE_MYGUI + + CONSOLE_PUTMESSAGE(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_NOTICE, _L("free camera"), "camera_go.png", 3000, false); } void CameraBehaviorFree::deactivate() { // change back to normal camera - if(mDOF) mDOF->setFocusMode(DOFManager::Manual); - cameramode = storedcameramode; + DOFManager *dof = CameraManager::getSingleton().getDOFManager(); + if(dof) dof->setFocusMode(DOFManager::Manual); + LOG("exiting free camera mode"); -#ifdef USE_MYGUI - Console::getSingleton().putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_NOTICE, _L("normal camera"), "camera.png", 3000); -#endif // USE_MYGUI + + CONSOLE_PUTMESSAGE(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_NOTICE, _L("normal camera"), "camera.png", 3000, false); + } void CameraBehaviorFree::update(float dt) @@ -109,15 +109,30 @@ if(INPUTENGINE.getEventBoolValue(EV_CHARACTER_LEFT)) mRotX += mRotScale; - mCamera->yaw(mRotX); - mCamera->pitch(mRotY); + Camera *cam = CameraManager::getSingleton().getCamera(); - Vector3 trans = mCamera->getOrientation() * mTranslateVector; - setCameraPositionWithCollision(mCamera->getPosition() + trans); + cam->yaw(mRotX); + cam->pitch(mRotY); + + Vector3 trans = cam->getOrientation() * mTranslateVector; + cam->setPosition(cam->getPosition() + trans); } bool CameraBehaviorFree::mouseMoved(const OIS::MouseEvent& _arg) { + const OIS::MouseState ms = _arg.state; + Camera *cam = CameraManager::getSingleton().getCamera(); + + if(ms.buttonDown(OIS::MB_Right)) + { + cam->yaw(Degree(-(float)ms.X.rel * 0.13f)); + cam->pitch(Degree(-(float)ms.Y.rel * 0.13f)); +#ifdef USE_MYGUI + MyGUI::PointerManager::getInstance().setPointer("hand"); +#endif // USE_MYGUI + return true; + } + return false; } Modified: trunk/source/main/gfx/camera/CameraBehaviorFree.h =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorFree.h 2012-03-15 13:18:31 UTC (rev 2463) +++ trunk/source/main/gfx/camera/CameraBehaviorFree.h 2012-03-15 16:27:33 UTC (rev 2464) @@ -17,8 +17,8 @@ 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 CAMERABEHAVIOR_H__ -#define CAMERABEHAVIOR_H__ +#ifndef CAMERABEHAVIORFREE_H__ +#define CAMERABEHAVIORFREE_H__ #include "RoRPrerequisites.h" #include "CameraBehavior.h" @@ -34,8 +34,10 @@ 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 // CAMERAMANAGER_H__ +#endif // CAMERABEHAVIORFREE_H__ Modified: trunk/source/main/gfx/camera/CameraManager.cpp =================================================================== --- trunk/source/main/gfx/camera/CameraManager.cpp 2012-03-15 13:18:31 UTC (rev 2463) +++ trunk/source/main/gfx/camera/CameraManager.cpp 2012-03-15 16:27:33 UTC (rev 2464) @@ -27,6 +27,7 @@ #include "language.h" #include "BeamFactory.h" +#include "OverlayWrapper.h" #include "CameraBehaviorFree.h" using namespace Ogre; @@ -36,6 +37,7 @@ CameraManager::CameraManager(Ogre::SceneManager *scm, Ogre::Camera *cam) : mSceneMgr(scm) , mCamera(cam) + , currentBehavior(0) // TODO: initialize other vars here { setSingleton(this); @@ -67,8 +69,9 @@ mDOF->setEnabled(true); } + //createGlobalBehaviors(); - + currentBehavior = new CameraBehaviorFree(); //globalBehaviors[CAMBEHAVIOR_FREE]; } CameraManager::~CameraManager() @@ -78,7 +81,7 @@ void CameraManager::createGlobalBehaviors() { - globalBehaviors["free"] = new CameraBehaviorFree(); + globalBehaviors.insert( std::pair<int, CameraBehavior*>(CAMBEHAVIOR_FREE, new CameraBehaviorFree()) ); } void CameraManager::updateInput() @@ -115,6 +118,7 @@ } else { + OverlayWrapper *ow = OverlayWrapper::getInstancePtrNoCreation(); if (cameramode==CAMERA_INT) { //end of internal cam @@ -217,7 +221,7 @@ if (INPUTENGINE.getEventBoolValueBounce(EV_CAMERA_FREE_MODE)) { - currentBehavior = globalBehaviors["free"]; + currentBehavior = globalBehaviors[CAMBEHAVIOR_FREE]; } } @@ -240,15 +244,17 @@ mRotScale = mRotateSpeed * dt; } - - - if(!hfinder) return; - if (loading_state!=ALL_LOADED && loading_state != EDITOR_PAUSE) return; - #ifdef MYGUI if (SceneMouse::getSingleton().isMouseGrabbed()) return; //freeze camera #endif //MYGUI + + // hacky hack + if(currentBehavior) + currentBehavior->update(dt); + + +#if 0 Beam *curr_truck = BeamFactory::getSingleton().getCurrentTruck(); bool changeCamMode = (lastcameramode != cameramode) || enforceCameraFOVUpdate; @@ -638,6 +644,7 @@ else w->moveTo(mCamera, w->getHeight()); } +#endif // 0 } @@ -666,7 +673,13 @@ return currentBehavior->mouseReleased(_arg, _id); } -void triggerFOVUpdate() +void CameraManager::triggerFOVUpdate() { enforceCameraFOVUpdate = true; } + +bool CameraManager::allowInteraction() +{ + if(!currentBehavior) return false; + return currentBehavior->allowInteraction(); +} Modified: trunk/source/main/gfx/camera/CameraManager.h =================================================================== --- trunk/source/main/gfx/camera/CameraManager.h 2012-03-15 13:18:31 UTC (rev 2463) +++ trunk/source/main/gfx/camera/CameraManager.h 2012-03-15 16:27:33 UTC (rev 2464) @@ -56,11 +56,14 @@ Ogre::Degree mRotateSpeed; DOFManager *mDOF; bool enforceCameraFOVUpdate; + Ogre::Vector3 cdoppler; CameraBehavior *currentBehavior; - std::map <Ogre::String , CameraBehavior *> globalBehaviors; + enum { CAMBEHAVIOR_FREE, CAMBEHAVIOR_TRUCK_EXT }; + std::map <int , CameraBehavior *> globalBehaviors; + bool mouseMoved(const OIS::MouseEvent& _arg); bool mousePressed(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id); bool mouseReleased(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id); @@ -87,11 +90,14 @@ bool setCameraPositionWithCollision(Ogre::Vector3 newPos); Ogre::Camera *getCamera() { return mCamera; }; int getCameraMode() { return cameramode; }; + inline DOFManager *getDOFManager() { return mDOF; } void createGlobalBehaviors(); void triggerFOVUpdate(); + + bool allowInteraction(); }; #endif // CAMERAMANAGER_H__ Modified: trunk/source/main/gui/Console.h =================================================================== --- trunk/source/main/gui/Console.h 2012-03-15 13:18:31 UTC (rev 2463) +++ trunk/source/main/gui/Console.h 2012-03-15 16:27:33 UTC (rev 2464) @@ -17,8 +17,18 @@ 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/>. */ + +// this must be outside of the other macro #ifdef USE_MYGUI +# define CONSOLE_PUTMESSAGE(a,b,c,d,e,f) Console::getSingleton().putMessage(a,b,c,d,e,f) +# define CONSOLE_PUTMESSAGE_SHORT(a,b,c) Console::getSingleton().putMessage(a,b,c) +#else +# define CONSOLE_PUTMESSAGE(a,b,c,d,e,f) +# define CONSOLE_PUTMESSAGE_SHORT(a,b,c) +#endif // USE_MYGUI +#ifdef USE_MYGUI + #ifndef __CONSOLE_H__ #define __CONSOLE_H__ @@ -31,7 +41,6 @@ #include <OgreLog.h> #include <OgreUTFString.h> - typedef struct msg_t { char type; int sender_uid; Modified: trunk/source/main/physics/Beam.cpp =================================================================== --- trunk/source/main/physics/Beam.cpp 2012-03-15 13:18:31 UTC (rev 2463) +++ trunk/source/main/physics/Beam.cpp 2012-03-15 16:27:33 UTC (rev 2464) @@ -53,6 +53,7 @@ #include "SlideNode.h" #include "turboprop.h" #include "water.h" +#include "CameraManager.h" // some gcc fixes #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX @@ -5450,7 +5451,7 @@ void Beam::updateAI(float dt) { - if(driveable != TRUCK || RoRFrameListener::eflsingleton->cameramode != CAMERA_FREE) + if(driveable != TRUCK || CAMERA_MODE != CAMERA_FREE) return; // start engine if not running Modified: trunk/source/main/scripting/GameScript.cpp =================================================================== --- trunk/source/main/scripting/GameScript.cpp 2012-03-15 13:18:31 UTC (rev 2463) +++ trunk/source/main/scripting/GameScript.cpp 2012-03-15 16:27:33 UTC (rev 2464) @@ -434,44 +434,52 @@ void GameScript::setCameraPosition(Ogre::Vector3 &pos) { - mefl->getCamera()->setPosition(Ogre::Vector3(pos.x, pos.y, pos.z)); + // TODO: TOFIX + //mefl->getCamera()->setPosition(Ogre::Vector3(pos.x, pos.y, pos.z)); } void GameScript::setCameraDirection(Ogre::Vector3 &rot) { - mefl->getCamera()->setDirection(Ogre::Vector3(rot.x, rot.y, rot.z)); + // TODO: TOFIX + //mefl->getCamera()->setDirection(Ogre::Vector3(rot.x, rot.y, rot.z)); } void GameScript::setCameraYaw(float rotX) { - mefl->getCamera()->yaw(Ogre::Degree(rotX)); + // TODO: TOFIX + //mefl->getCamera()->yaw(Ogre::Degree(rotX)); } void GameScript::setCameraPitch(float rotY) { - mefl->getCamera()->pitch(Ogre::Degree(rotY)); + // TODO: TOFIX + //mefl->getCamera()->pitch(Ogre::Degree(rotY)); } void GameScript::setCameraRoll(float rotZ) { - mefl->getCamera()->roll(Ogre::Degree(rotZ)); + // TODO: TOFIX + //mefl->getCamera()->roll(Ogre::Degree(rotZ)); } Ogre::Vector3 GameScript::getCameraPosition() { - Ogre::Vector3 pos = mefl->getCamera()->getPosition(); - return Ogre::Vector3(pos.x, pos.y, pos.z); + // TODO: TOFIX + //Ogre::Vector3 pos = mefl->getCamera()->getPosition(); + return Ogre::Vector3::ZERO; //Vector3(pos.x, pos.y, pos.z); } Ogre::Vector3 GameScript::getCameraDirection() { - Ogre::Vector3 rot = mefl->getCamera()->getDirection(); - return Ogre::Vector3(rot.x, rot.y, rot.z); + // TODO: TOFIX + //Ogre::Vector3 rot = mefl->getCamera()->getDirection(); + return Ogre::Vector3::ZERO; //(rot.x, rot.y, rot.z); } void GameScript::cameraLookAt(Ogre::Vector3 &pos) { - mefl->getCamera()->lookAt(Ogre::Vector3(pos.x, pos.y, pos.z)); + // TODO: TOFIX + //mefl->getCamera()->lookAt(Ogre::Vector3(pos.x, pos.y, pos.z)); } #ifdef USE_CURL This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure _______________________________________________ Rigsofrods-devel mailing list Rigsofrods-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel