Revision: 2555
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2555&view=rev
Author: ulteq
Date: 2012-05-14 11:07:34 +0000 (Mon, 14 May 2012)
Log Message:
-----------
-Feature: new first-person camera mode
Modified Paths:
--------------
trunk/source/main/gfx/camera/CameraBehavior.cpp
trunk/source/main/gfx/camera/CameraBehavior.h
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/CameraBehaviorFree.h
trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp
trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h
trunk/source/main/gfx/camera/CameraBehaviorVehicleStatic.h
trunk/source/main/gfx/camera/CameraManager.cpp
trunk/source/main/gfx/camera/ICameraBehavior.h
Modified: trunk/source/main/gfx/camera/CameraBehavior.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehavior.cpp 2012-05-14 11:07:03 UTC
(rev 2554)
+++ trunk/source/main/gfx/camera/CameraBehavior.cpp 2012-05-14 11:07:34 UTC
(rev 2555)
@@ -118,7 +118,7 @@
ctx.mCamera->lookAt(camCenterPosition);
}
-bool CameraBehavior::mouseMoved(const OIS::MouseEvent& _arg)
+bool CameraBehavior::mouseMoved(const CameraManager::cameraContext_t &ctx,
const OIS::MouseEvent& _arg)
{
const OIS::MouseState ms = _arg.state;
Modified: trunk/source/main/gfx/camera/CameraBehavior.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehavior.h 2012-05-14 11:07:03 UTC
(rev 2554)
+++ trunk/source/main/gfx/camera/CameraBehavior.h 2012-05-14 11:07:34 UTC
(rev 2555)
@@ -35,9 +35,9 @@
void activate(const CameraManager::cameraContext_t &ctx) {};
void deactivate(const CameraManager::cameraContext_t &ctx) {};
- bool mouseMoved(const OIS::MouseEvent& _arg);
- bool mousePressed(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id)
{ return false; };
- bool mouseReleased(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id)
{ return false; };
+ bool mouseMoved(const CameraManager::cameraContext_t &ctx, const
OIS::MouseEvent& _arg);
+ 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; };
protected:
Modified: trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp 2012-05-14
11:07:03 UTC (rev 2554)
+++ trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp 2012-05-14
11:07:34 UTC (rev 2555)
@@ -1,64 +1,83 @@
-/*
-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"
-
-using namespace Ogre;
-
-CameraBehaviorCharacter::CameraBehaviorCharacter() :
- CameraBehavior()
- , camMode(CHARACTER_THIRD_PERSON)
-{
- camPositionOffset = Vector3(0.0f, 1.1f, 0.0f);
-}
-
-void CameraBehaviorCharacter::update(const CameraManager::cameraContext_t &ctx)
-{
- Character *person = ctx.mEfl->person;
-
- targetDirection = -person->getAngle() - Math::HALF_PI;
- camCenterPosition = person->getPosition() + camPositionOffset;
-
- CameraBehavior::update(ctx);
-}
-
-// TODO: First-person mouse interaction
-
-bool CameraBehaviorCharacter::switchBehavior(const
CameraManager::cameraContext_t &ctx)
-{
- camMode = (camMode + 1) % CHARACTER_END;
-
- if ( camMode == CHARACTER_FIRST_PERSON )
- {
- camRotY = 0.1f;
- camDist = 0.1;
- camRatio = 0.0f;
- camPositionOffset = Vector3(0.1f, 1.82f, 0.0f);
- } else if ( camMode == CHARACTER_THIRD_PERSON )
- {
- camRotY = 0.3f;
- camDist = 5.0f;
- camRatio = 11.0f;
- camPositionOffset = Vector3(0.0f, 1.1f, 0.0f);
- }
-
- return false;
-}
+/*
+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"
+
+using namespace Ogre;
+
+CameraBehaviorCharacter::CameraBehaviorCharacter() :
+ CameraBehavior()
+ , camMode(CHARACTER_THIRD_PERSON)
+{
+ camPositionOffset = Vector3(0.0f, 1.1f, 0.0f);
+}
+
+void CameraBehaviorCharacter::update(const CameraManager::cameraContext_t &ctx)
+{
+ Character *person = ctx.mEfl->person;
+
+ targetDirection = -person->getAngle() - Math::HALF_PI;
+ camCenterPosition = person->getPosition() + camPositionOffset;
+
+ CameraBehavior::update(ctx);
+}
+
+// TODO: First-person mouse interaction
+
+bool CameraBehaviorCharacter::switchBehavior(const
CameraManager::cameraContext_t &ctx)
+{
+ camMode = (camMode + 1) % CHARACTER_END;
+
+ if ( camMode == CHARACTER_FIRST_PERSON )
+ {
+ camRotY = 0.1f;
+ camDist = 0.1;
+ camRatio = 0.0f;
+ camPositionOffset = Vector3(0.1f, 1.82f, 0.0f);
+ } else if ( camMode == CHARACTER_THIRD_PERSON )
+ {
+ camRotY = 0.3f;
+ camDist = 5.0f;
+ camRatio = 11.0f;
+ camPositionOffset = Vector3(0.0f, 1.1f, 0.0f);
+ }
+
+ return false;
+}
+
+bool CameraBehaviorCharacter::mouseMoved(const CameraManager::cameraContext_t
&ctx, const OIS::MouseEvent& _arg)
+{
+ if ( camMode == CHARACTER_FIRST_PERSON )
+ {
+ const OIS::MouseState ms = _arg.state;
+ Character *person = ctx.mEfl->person;
+ float angle = person->getAngle();
+
+ camRotY += Degree((float)ms.Y.rel * 0.13f);
+ angle += ms.X.rel * 0.01f;
+
+ person->setAngle(angle);
+
+ return true;
+ }
+
+ return CameraBehavior::mouseMoved(ctx, _arg);
+}
Modified: trunk/source/main/gfx/camera/CameraBehaviorCharacter.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorCharacter.h 2012-05-14
11:07:03 UTC (rev 2554)
+++ trunk/source/main/gfx/camera/CameraBehaviorCharacter.h 2012-05-14
11:07:34 UTC (rev 2555)
@@ -32,6 +32,8 @@
void update(const CameraManager::cameraContext_t &ctx);
+ bool mouseMoved(const CameraManager::cameraContext_t &ctx, const
OIS::MouseEvent& _arg);
+
bool switchBehavior(const CameraManager::cameraContext_t &ctx);
protected:
Modified: trunk/source/main/gfx/camera/CameraBehaviorFree.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorFree.cpp 2012-05-14 11:07:03 UTC
(rev 2554)
+++ trunk/source/main/gfx/camera/CameraBehaviorFree.cpp 2012-05-14 11:07:34 UTC
(rev 2555)
@@ -93,13 +93,12 @@
ctx.mCamera->setPosition(ctx.mCamera->getPosition() + trans);
}
-bool CameraBehaviorFree::mouseMoved(const OIS::MouseEvent& _arg)
+bool CameraBehaviorFree::mouseMoved(const CameraManager::cameraContext_t &ctx,
const OIS::MouseEvent& _arg)
{
const OIS::MouseState ms = _arg.state;
- Camera *cam = CameraManager::getSingleton().getCamera();
- cam->yaw(Degree(-(float)ms.X.rel * 0.13f));
- cam->pitch(Degree(-(float)ms.Y.rel * 0.13f));
+ ctx.mCamera->yaw(Degree(-(float)ms.X.rel * 0.13f));
+ ctx.mCamera->pitch(Degree(-(float)ms.Y.rel * 0.13f));
return true;
}
Modified: trunk/source/main/gfx/camera/CameraBehaviorFree.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorFree.h 2012-05-14 11:07:03 UTC
(rev 2554)
+++ trunk/source/main/gfx/camera/CameraBehaviorFree.h 2012-05-14 11:07:34 UTC
(rev 2555)
@@ -33,9 +33,9 @@
void update(const CameraManager::cameraContext_t &ctx);
- bool mouseMoved(const OIS::MouseEvent& _arg);
- bool mousePressed(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id)
{ return false; };
- bool mouseReleased(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id)
{ return false; };
+ bool mouseMoved(const CameraManager::cameraContext_t &ctx, const
OIS::MouseEvent& _arg);
+ 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; };
bool switchBehavior(const CameraManager::cameraContext_t &ctx) { return
true; };
};
Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp
2012-05-14 11:07:03 UTC (rev 2554)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp
2012-05-14 11:07:34 UTC (rev 2555)
@@ -96,7 +96,7 @@
CameraBehavior::update(ctx);
}
-bool CameraBehaviorVehicleSpline::mouseMoved(const OIS::MouseEvent& _arg,
const CameraManager::cameraContext_t &ctx)
+bool CameraBehaviorVehicleSpline::mouseMoved(const
CameraManager::cameraContext_t &ctx, const OIS::MouseEvent& _arg)
{
const OIS::MouseState ms = _arg.state;
Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h 2012-05-14
11:07:03 UTC (rev 2554)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h 2012-05-14
11:07:34 UTC (rev 2555)
@@ -32,7 +32,7 @@
void update(const CameraManager::cameraContext_t &ctx);
- bool mouseMoved(const OIS::MouseEvent& _arg, const
CameraManager::cameraContext_t &ctx);
+ bool mouseMoved(const CameraManager::cameraContext_t &ctx, const
OIS::MouseEvent& _arg);
void activate(const CameraManager::cameraContext_t &ctx);
Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleStatic.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicleStatic.h 2012-05-14
11:07:03 UTC (rev 2554)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleStatic.h 2012-05-14
11:07:34 UTC (rev 2555)
@@ -32,9 +32,9 @@
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 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; };
void activate(const CameraManager::cameraContext_t &ctx) {};
void deactivate(const CameraManager::cameraContext_t &ctx) {};
Modified: trunk/source/main/gfx/camera/CameraManager.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraManager.cpp 2012-05-14 11:07:03 UTC
(rev 2554)
+++ trunk/source/main/gfx/camera/CameraManager.cpp 2012-05-14 11:07:34 UTC
(rev 2555)
@@ -166,17 +166,17 @@
bool CameraManager::mouseMoved(const OIS::MouseEvent& _arg)
{
if ( !currentBehavior ) return false;
- return currentBehavior->mouseMoved(_arg);
+ return currentBehavior->mouseMoved(ctx, _arg);
}
bool CameraManager::mousePressed(const OIS::MouseEvent& _arg,
OIS::MouseButtonID _id)
{
if ( !currentBehavior ) return false;
- return currentBehavior->mousePressed(_arg, _id);
+ return currentBehavior->mousePressed(ctx, _arg, _id);
}
bool CameraManager::mouseReleased(const OIS::MouseEvent& _arg,
OIS::MouseButtonID _id)
{
if ( !currentBehavior ) return false;
- return currentBehavior->mouseReleased(_arg, _id);
+ return currentBehavior->mouseReleased(ctx, _arg, _id);
}
Modified: trunk/source/main/gfx/camera/ICameraBehavior.h
===================================================================
--- trunk/source/main/gfx/camera/ICameraBehavior.h 2012-05-14 11:07:03 UTC
(rev 2554)
+++ trunk/source/main/gfx/camera/ICameraBehavior.h 2012-05-14 11:07:34 UTC
(rev 2555)
@@ -33,9 +33,9 @@
virtual void update(const CameraManager::cameraContext_t &ctx) = 0;
- 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;
+ virtual bool mouseMoved(const CameraManager::cameraContext_t &ctx,
const OIS::MouseEvent& _arg) = 0;
+ virtual bool mousePressed(const CameraManager::cameraContext_t &ctx,
const OIS::MouseEvent& _arg, OIS::MouseButtonID _id) = 0;
+ virtual bool mouseReleased(const CameraManager::cameraContext_t &ctx,
const OIS::MouseEvent& _arg, OIS::MouseButtonID _id) = 0;
virtual void activate(const CameraManager::cameraContext_t &ctx) = 0;
virtual void deactivate(const CameraManager::cameraContext_t &ctx) = 0;
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel