Revision: 2587
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2587&view=rev
Author: ulteq
Date: 2012-05-17 17:53:14 +0000 (Thu, 17 May 2012)
Log Message:
-----------
-Codechange: CameraSystem WIP
enabled CameraBehaviorFree (deactivate() not yet working correctly)
enabled CameraBehaviorFixed (finished)
Modified Paths:
--------------
trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp
trunk/source/main/gfx/camera/CameraBehaviorFree.cpp
trunk/source/main/gfx/camera/CameraBehaviorVehicleStatic.h
trunk/source/main/gfx/camera/CameraManager.cpp
trunk/source/main/gfx/camera/CameraManager.h
Added Paths:
-----------
trunk/source/main/gfx/camera/CameraBehaviorFixed.h
Modified: trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp 2012-05-17
16:30:32 UTC (rev 2586)
+++ trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp 2012-05-17
17:53:14 UTC (rev 2587)
@@ -47,7 +47,7 @@
float angle = ctx.mCharacter->getAngle();
camRotY += Degree(ms.Y.rel * 0.13f);
- angle += ms.X.rel * 0.01f;
+ angle += ms.X.rel * 0.13f;
ctx.mCharacter->setAngle(angle);
@@ -67,8 +67,8 @@
camDist = 0.1f;
camIntertia = 0.0f;
camPositionOffset = Vector3(0.0f, 1.82f, 0.0f);
-#ifdef USE_MYGUI
- MyGUI::PointerManager::getInstance().setVisible(false);
+#ifdef USE_MYGUI
+ MyGUI::PointerManager::getInstance().setVisible(false);
#endif // USE_MYGUI
} else if ( camMode == CHARACTER_THIRD_PERSON )
{
@@ -76,8 +76,8 @@
camDist = 5.0f;
camIntertia = 11.0f;
camPositionOffset = Vector3(0.0f, 1.1f, 0.0f);
-#ifdef USE_MYGUI
- MyGUI::PointerManager::getInstance().setVisible(true);
+#ifdef USE_MYGUI
+ MyGUI::PointerManager::getInstance().setVisible(true);
#endif // USE_MYGUI
}
}
Added: trunk/source/main/gfx/camera/CameraBehaviorFixed.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorFixed.h
(rev 0)
+++ trunk/source/main/gfx/camera/CameraBehaviorFixed.h 2012-05-17 17:53:14 UTC
(rev 2587)
@@ -0,0 +1,44 @@
+/*
+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 "ICameraBehavior.h"
+
+class CameraBehaviorFixed : public ICameraBehavior
+{
+public:
+
+ void update(const CameraManager::cameraContext_t &ctx) {};
+
+ 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) {};
+ void reset(const CameraManager::cameraContext_t &ctx) {};
+
+ bool switchBehavior(const CameraManager::cameraContext_t &ctx) { return
true; };
+};
+
+#endif // __CAMERA_BEHAVIOR_FIXED_H_
Modified: trunk/source/main/gfx/camera/CameraBehaviorFree.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorFree.cpp 2012-05-17 16:30:32 UTC
(rev 2586)
+++ trunk/source/main/gfx/camera/CameraBehaviorFree.cpp 2012-05-17 17:53:14 UTC
(rev 2587)
@@ -27,7 +27,7 @@
void CameraBehaviorFree::update(const CameraManager::cameraContext_t &ctx)
{
- Vector3 mTrans = Vector3::ZERO;
+ Vector3 mTrans(Vector3::ZERO);
Degree mRotX(0.0f);
Degree mRotY(0.0f);
@@ -81,6 +81,16 @@
ctx.mCamera->setPosition(ctx.mCamera->getPosition() +
ctx.mCamera->getOrientation() * mTrans);
}
+bool CameraBehaviorFree::mouseMoved(const CameraManager::cameraContext_t &ctx,
const OIS::MouseEvent& _arg)
+{
+ const OIS::MouseState ms = _arg.state;
+
+ ctx.mCamera->yaw(Degree(-ms.X.rel * 0.13f));
+ ctx.mCamera->pitch(Degree(-ms.Y.rel * 0.13f));
+
+ return true;
+}
+
void CameraBehaviorFree::activate(const CameraManager::cameraContext_t &ctx)
{
ctx.mCamera->setFixedYawAxis(true, Vector3::UNIT_Y);
@@ -97,12 +107,3 @@
#endif // USE_MYGUI
}
-bool CameraBehaviorFree::mouseMoved(const CameraManager::cameraContext_t &ctx,
const OIS::MouseEvent& _arg)
-{
- const OIS::MouseState ms = _arg.state;
-
- ctx.mCamera->yaw(Degree(-ms.X.rel * 0.13f));
- ctx.mCamera->pitch(Degree(-ms.Y.rel * 0.13f));
-
- return true;
-}
Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleStatic.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicleStatic.h 2012-05-17
16:30:32 UTC (rev 2586)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleStatic.h 2012-05-17
17:53:14 UTC (rev 2587)
@@ -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 __CAMERA_BEHAVIOR_FIXED_H_
-#define __CAMERA_BEHAVIOR_FIXED_H_
+#ifndef __CAMERA_BEHAVIOR_STATIC_H_
+#define __CAMERA_BEHAVIOR_STATIC_H_
#include "RoRPrerequisites.h"
@@ -42,4 +42,4 @@
bool switchBehavior(const CameraManager::cameraContext_t &ctx) { return
true; };
};
-#endif // __CAMERA_BEHAVIOR_FIXED_H_
+#endif // __CAMERA_BEHAVIOR_STATIC_H_
Modified: trunk/source/main/gfx/camera/CameraManager.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraManager.cpp 2012-05-17 16:30:32 UTC
(rev 2586)
+++ trunk/source/main/gfx/camera/CameraManager.cpp 2012-05-17 17:53:14 UTC
(rev 2587)
@@ -22,9 +22,10 @@
#include "BeamFactory.h"
#include "InputEngine.h"
+#include "CameraBehavior.h"
#include "CameraBehaviorCharacter.h"
+#include "CameraBehaviorFixed.h"
#include "CameraBehaviorFree.h"
-#include "CameraBehavior.h"
#include "CameraBehaviorVehicle.h"
#include "CameraBehaviorVehicleCineCam.h"
#include "CameraBehaviorVehicleSpline.h"
@@ -74,6 +75,7 @@
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()));
+ globalBehaviors.insert(std::pair<int,
ICameraBehavior*>(CAMERA_BEHAVIOR_FIXED, new CameraBehaviorFixed()));
}
void CameraManager::switchToNextBehavior()
@@ -118,20 +120,30 @@
mTransScale = mTransSpeed * dt;
mRotScale = mRotateSpeed * dt;
+ ctx.mCurrTruck = BeamFactory::getSingleton().getCurrentTruck();
+ ctx.mDt = dt;
+ ctx.mRotScale = Degree(mRotScale);
+ ctx.mTransScale = mTransScale;
+
if ( INPUTENGINE.getEventBoolValueBounce(EV_CAMERA_CHANGE) )
{
switchToNextBehavior();
}
- ctx.mCurrTruck = BeamFactory::getSingleton().getCurrentTruck();
- ctx.mDt = dt;
- ctx.mRotScale = Degree(mRotScale);
- ctx.mTransScale = mTransScale;
+ if ( INPUTENGINE.getEventBoolValueBounce(EV_CAMERA_FREE_MODE_FIX) )
+ {
+ switchBehavior(CAMERA_BEHAVIOR_FIXED);
+ }
+ if ( !ctx.mCurrTruck &&
INPUTENGINE.getEventBoolValueBounce(EV_CAMERA_FREE_MODE) )
+ {
+ switchBehavior(CAMERA_BEHAVIOR_FREE);
+ }
+
if ( !ctx.mCurrTruck &&
dynamic_cast<CameraBehaviorVehicle*>(currentBehavior) )
{
switchBehavior(CAMERA_BEHAVIOR_CHARACTER);
- } else if ( ctx.mCurrTruck &&
!dynamic_cast<CameraBehaviorVehicle*>(currentBehavior) )
+ } else if ( ctx.mCurrTruck && currentBehaviorID !=
CAMERA_BEHAVIOR_FIXED && !dynamic_cast<CameraBehaviorVehicle*>(currentBehavior)
)
{
switchBehavior(CAMERA_BEHAVIOR_VEHICLE);
}
Modified: trunk/source/main/gfx/camera/CameraManager.h
===================================================================
--- trunk/source/main/gfx/camera/CameraManager.h 2012-05-17 16:30:32 UTC
(rev 2586)
+++ trunk/source/main/gfx/camera/CameraManager.h 2012-05-17 17:53:14 UTC
(rev 2587)
@@ -57,7 +57,8 @@
CAMERA_BEHAVIOR_VEHICLE_SPLINE,
CAMERA_BEHAVIOR_VEHICLE_CINECAM,
CAMERA_BEHAVIOR_END,
- CAMERA_BEHAVIOR_FREE
+ CAMERA_BEHAVIOR_FREE,
+ CAMERA_BEHAVIOR_FIXED
};
void update(float dt);
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