Revision: 2466
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2466&view=rev
Author:   rorthomas
Date:     2012-03-15 18:11:33 +0000 (Thu, 15 Mar 2012)
Log Message:
-----------
character orbit cam

Modified Paths:
--------------
    trunk/source/main/gameplay/RoRFrameListener.cpp
    trunk/source/main/gfx/camera/CameraManager.cpp
    trunk/source/main/gfx/camera/CameraManager.h
    trunk/source/main/gui/Console.cpp
    trunk/source/main/gui/Console.h

Added Paths:
-----------
    trunk/source/main/gfx/camera/CameraBehaviorCharacterOrbit.cpp
    trunk/source/main/gfx/camera/CameraBehaviorCharacterOrbit.h
    trunk/source/main/gfx/camera/CameraBehaviorOrbit.cpp
    trunk/source/main/gfx/camera/CameraBehaviorOrbit.h

Modified: trunk/source/main/gameplay/RoRFrameListener.cpp
===================================================================
--- trunk/source/main/gameplay/RoRFrameListener.cpp     2012-03-15 17:10:21 UTC 
(rev 2465)
+++ trunk/source/main/gameplay/RoRFrameListener.cpp     2012-03-15 18:11:33 UTC 
(rev 2466)
@@ -788,7 +788,7 @@
        new SceneMouse(scm);
        new GUIManager(root, scm, win);
        // create console, must be done early
-       Console::getSingleton();
+       new Console();
 #endif //USE_MYGUI
 
 

Added: trunk/source/main/gfx/camera/CameraBehaviorCharacterOrbit.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorCharacterOrbit.cpp               
                (rev 0)
+++ trunk/source/main/gfx/camera/CameraBehaviorCharacterOrbit.cpp       
2012-03-15 18:11:33 UTC (rev 2466)
@@ -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/>.
+*/
+#include "CameraBehaviorCharacterOrbit.h"
+
+#include <Ogre.h>
+#include "CameraManager.h"
+#include "Console.h"
+#include "InputEngine.h"
+#include "language.h"
+#include "Settings.h"
+
+using namespace Ogre;
+
+void CameraBehaviorCharacterOrbit::update(float dt, Character *person)
+{
+       targetDirection = -person->getAngle() - Math::HALF_PI;
+       camCenterPoint  =  person->getPosition() + Vector3(0, 1.1f, 0);
+       CameraBehaviorOrbit::update(dt);
+}

Added: trunk/source/main/gfx/camera/CameraBehaviorCharacterOrbit.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorCharacterOrbit.h                 
        (rev 0)
+++ trunk/source/main/gfx/camera/CameraBehaviorCharacterOrbit.h 2012-03-15 
18:11:33 UTC (rev 2466)
@@ -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 CAMERABEHAVIORPERSONORBIT_H__
+#define CAMERABEHAVIORPERSONORBIT_H__
+
+#include "RoRPrerequisites.h"
+#include "CameraBehaviorOrbit.h"
+
+#include "Character.h"
+
+class CameraBehaviorCharacterOrbit : public CameraBehaviorOrbit
+{
+public:
+       void update(float dt, Character *chr);
+};
+
+#endif // CAMERABEHAVIORPERSONORBIT_H__
+
+

Added: trunk/source/main/gfx/camera/CameraBehaviorOrbit.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorOrbit.cpp                        
        (rev 0)
+++ trunk/source/main/gfx/camera/CameraBehaviorOrbit.cpp        2012-03-15 
18:11:33 UTC (rev 2466)
@@ -0,0 +1,127 @@
+/*
+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 "CameraBehaviorOrbit.h"
+
+#include <Ogre.h>
+#include "CameraManager.h"
+#include "Console.h"
+#include "InputEngine.h"
+#include "language.h"
+#include "Settings.h"
+
+using namespace Ogre;
+
+CameraBehaviorOrbit::CameraBehaviorOrbit() :
+         camRotX(0)
+       , camRotY(0)
+       , camDist(5)
+       , camIdealPosition(Vector3::ZERO)
+       , camCenterPoint(Vector3::ZERO)
+       , targetDirection(0)
+       , targetPitch(0)
+{
+
+
+}
+
+void CameraBehaviorOrbit::activate()
+{
+       float fov = FSETTING("FOV External", 60);
+
+       DOFManager *dof = CameraManager::getSingleton().getDOFManager();
+       if(dof)
+       {
+               dof->setFocusMode(DOFManager::Manual);
+               dof->setLensFOV(Degree(fov));
+       }
+
+       camCenterPoint = Vector3(0, 3, 0);
+
+       Camera *cam = CameraManager::getSingleton().getCamera();
+       cam->setFOVy(Degree(fov));
+}
+
+void CameraBehaviorOrbit::deactivate()
+{
+}
+
+void CameraBehaviorOrbit::update(float dt)
+{
+       Camera *cam = CameraManager::getSingleton().getCamera();
+
+       // set Minimal Cam distance
+       if(camDist < 3) camDist = 3.0f;
+
+       camIdealPosition = camDist * 0.5f * Vector3( \
+                         sin(targetDirection + camRotX.valueRadians()) * 
cos(targetPitch + camRotY.valueRadians()) \
+                       , sin(targetPitch     + camRotY.valueRadians()) \
+                       , cos(targetDirection + camRotX.valueRadians()) * 
cos(targetPitch + camRotY.valueRadians()) \
+                       );
+
+       float real_camdist = camIdealPosition.length();
+
+       camIdealPosition = camIdealPosition + camCenterPoint;
+       Vector3 newposition = ( camIdealPosition + 10.0f * cam->getPosition() ) 
/ 11.0f;
+
+       /*
+       Real h=hfinder->getHeightAt(newposition.x,newposition.z);
+
+       if (w && !w->allowUnderWater() && w->getHeightWaves(newposition) > h)
+               h=w->getHeightWaves(newposition);
+
+       h+=1.0;
+       if (newposition.y<h) newposition.y=h;
+       */
+
+       cam->setPosition(newposition);
+       cam->lookAt(camCenterPoint);
+
+       lastPosition = camCenterPoint;
+
+       DOFManager *dof = CameraManager::getSingleton().getDOFManager();
+       if(dof)
+       {
+               dof->setFocusMode(DOFManager::Manual);
+               dof->setFocus(real_camdist);
+       }
+}
+
+bool CameraBehaviorOrbit::mouseMoved(const OIS::MouseEvent& _arg)
+{
+       const OIS::MouseState ms = _arg.state;
+       Camera *cam = CameraManager::getSingleton().getCamera();
+
+
+       camRotX += Degree( (float)ms.X.rel * 0.13f);
+       camRotY += Degree(-(float)ms.Y.rel * 0.13f);
+       camDist += -(float)ms.Z.rel * 0.02f;
+
+       return true;
+}
+
+bool CameraBehaviorOrbit::mousePressed(const OIS::MouseEvent& _arg, 
OIS::MouseButtonID _id)
+{
+       return false;
+}
+
+bool CameraBehaviorOrbit::mouseReleased(const OIS::MouseEvent& _arg, 
OIS::MouseButtonID _id)
+{
+       return false;
+}

Added: trunk/source/main/gfx/camera/CameraBehaviorOrbit.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorOrbit.h                          
(rev 0)
+++ trunk/source/main/gfx/camera/CameraBehaviorOrbit.h  2012-03-15 18:11:33 UTC 
(rev 2466)
@@ -0,0 +1,52 @@
+/*
+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 CAMERABEHAVIORORBIT_H__
+#define CAMERABEHAVIORORBIT_H__
+
+#include "RoRPrerequisites.h"
+#include "CameraBehavior.h"
+
+class CameraBehaviorOrbit : public CameraBehavior
+{
+protected:
+       Ogre::Radian camRotX, camRotY;
+       float camDist;
+       Ogre::Vector3 camIdealPosition, camCenterPoint, lastPosition;
+       float targetDirection, targetPitch;
+
+public:
+
+       CameraBehaviorOrbit();
+
+       void activate();
+       void deactivate();
+
+       void update(float dt);
+
+       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 // CAMERABEHAVIORORBIT_H__
+
+

Modified: trunk/source/main/gfx/camera/CameraManager.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraManager.cpp      2012-03-15 17:10:21 UTC 
(rev 2465)
+++ trunk/source/main/gfx/camera/CameraManager.cpp      2012-03-15 18:11:33 UTC 
(rev 2466)
@@ -29,7 +29,11 @@
 
 #include "OverlayWrapper.h"
 #include "CameraBehaviorFree.h"
+#include "CameraBehaviorOrbit.h"
+#include "CameraBehaviorCharacterOrbit.h"
 
+#include "RoRFrameListener.h"
+
 using namespace Ogre;
 
 #define DEFAULT_INTERNAL_CAM_PITCH Degree(-15)
@@ -48,11 +52,11 @@
        externalCameraMode = (SSETTING("External Camera Mode", "Pitching") == 
"Static")? 1 : 0;
        mMoveScale = 0.0f;
        mRotScale = 0.0f;
-       camIdealPosition = Vector3::ZERO;
+       //camIdealPosition = Vector3::ZERO;
        lastPosition = Vector3::ZERO;
-       camRotX=0;
-       camRotY=Degree(12);
-       camDist=20;
+       //camRotX=0;
+       //camRotY=Degree(12);
+       //camDist=20;
        camCollided=false;
        camPosColl=Vector3::ZERO;
        mSceneDetailIndex = 0;
@@ -71,8 +75,8 @@
 
        //createGlobalBehaviors();
 
-       currentBehavior = new CameraBehaviorFree(); 
//globalBehaviors[CAMBEHAVIOR_FREE];
-       currentBehavior->activate();
+       //currentBehavior = globalBehaviors[CAMBEHAVIOR_FREE];
+       currentBehavior = new CameraBehaviorCharacterOrbit();
 }
 
 CameraManager::~CameraManager()
@@ -87,6 +91,7 @@
 
 void CameraManager::updateInput()
 {
+#if 0
        Beam *curr_truck = BeamFactory::getSingleton().getCurrentTruck();
 
        //camera mode
@@ -224,7 +229,7 @@
        {
                currentBehavior = globalBehaviors[CAMBEHAVIOR_FREE];
        }
-
+#endif // 0
 }
 
 void CameraManager::update(float dt)
@@ -235,6 +240,10 @@
        {
                mMoveScale = 1;
                mRotScale = 0.1;
+
+               // HACKKK
+               if(currentBehavior)
+                       currentBehavior->activate();
        }
        // Otherwise scale movement units by time passed since last frame
        else
@@ -250,9 +259,10 @@
 #endif //MYGUI
 
 
+
        // hacky hack
        if(currentBehavior)
-               currentBehavior->update(dt);
+               ((CameraBehaviorCharacterOrbit *)currentBehavior)->update(dt, 
RoRFrameListener::eflsingleton->person);
 
 
 #if 0

Modified: trunk/source/main/gfx/camera/CameraManager.h
===================================================================
--- trunk/source/main/gfx/camera/CameraManager.h        2012-03-15 17:10:21 UTC 
(rev 2465)
+++ trunk/source/main/gfx/camera/CameraManager.h        2012-03-15 18:11:33 UTC 
(rev 2466)
@@ -40,9 +40,6 @@
        Ogre::SceneManager *mSceneMgr;
        Ogre::Camera *mCamera;
        int cameramode, lastcameramode;
-       Ogre::Radian camRotX, camRotY;
-       float camDist;
-       Ogre::Vector3 camIdealPosition;
        bool camCollided;
        Ogre::Vector3 camPosColl;
        Ogre::Radian pushcamRotX, pushcamRotY;
@@ -83,8 +80,8 @@
                CAMERA_EXTERNALCONTROL=9999
        };
 
-       void setCameraRotation(Ogre::Radian x, Ogre::Radian y, Ogre::Real 
distance) { camRotX=x; camRotY=y; camDist=distance;};
-       Ogre::Radian getCameraRotationX() { return camRotX; };
+       //void setCameraRotation(Ogre::Radian x, Ogre::Radian y, Ogre::Real 
distance) { camRotX=x; camRotY=y; camDist=distance;};
+       //Ogre::Radian getCameraRotationX() { return camRotX; };
 
        void update(float dt);
        bool setCameraPositionWithCollision(Ogre::Vector3 newPos);

Modified: trunk/source/main/gui/Console.cpp
===================================================================
--- trunk/source/main/gui/Console.cpp   2012-03-15 17:10:21 UTC (rev 2465)
+++ trunk/source/main/gui/Console.cpp   2012-03-15 18:11:33 UTC (rev 2466)
@@ -55,6 +55,7 @@
 // class
 Console::Console() : net(0), netChat(0), top_border(20), bottom_border(100), 
message_counter(0), mHistory(), mHistoryPosition(0), inputMode(false), 
linesChanged(false), scrollOffset(0), autoCompleteIndex(-1), linecount(10), 
scroll_size(5), angelscriptMode(false)
 {
+       setSingleton(this);
        mMainWidget = 
MyGUI::Gui::getInstance().createWidget<MyGUI::Window>("default", 0, 0, 400, 
300,  MyGUI::Align::Center, "Back", "Console");
        mMainWidget->setCaption(_L("Console"));
        mMainWidget->setAlpha(0.9f);

Modified: trunk/source/main/gui/Console.h
===================================================================
--- trunk/source/main/gui/Console.h     2012-03-15 17:10:21 UTC (rev 2465)
+++ trunk/source/main/gui/Console.h     2012-03-15 18:11:33 UTC (rev 2466)
@@ -53,14 +53,14 @@
 } msg_t;
 
 class Console :
-       public RoRSingleton<Console>,
+       public RoRSingletonNoCreation<Console>,
        public Ogre::LogListener,
        public InterThreadStoreVector<msg_t>
 {
        friend class RoRSingleton<Console>;
+public:
        Console();
        ~Console();
-public:
        void setVisible(bool _visible);
        bool getVisible();
 

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

Reply via email to