Revision: 2591
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2591&view=rev
Author: ulteq
Date: 2012-05-18 15:27:19 +0000 (Fri, 18 May 2012)
Log Message:
-----------
-Codechange: CameraSystem WIP (nearly done)
the mode selection now thinks for itself
EV_CAMERA_FREE_MODE and EV_CAMERA_FREE_MODE_FIX are now switches
mouse pointer is now hidden in first-person and free mode
fixed behavior of CameraBehaviorFree::deactivate()
improved height calculation in CameraBehaviorStatic (more robust)
reduced CameraBehaviorVehicleSpline code (now reuses
CameraBehavior::mouseMoved())
Modified Paths:
--------------
trunk/source/main/gfx/camera/CameraBehavior.h
trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp
trunk/source/main/gfx/camera/CameraBehaviorFixed.h
trunk/source/main/gfx/camera/CameraBehaviorFree.cpp
trunk/source/main/gfx/camera/CameraBehaviorFree.h
trunk/source/main/gfx/camera/CameraBehaviorStatic.cpp
trunk/source/main/gfx/camera/CameraBehaviorStatic.h
trunk/source/main/gfx/camera/CameraBehaviorVehicle.cpp
trunk/source/main/gfx/camera/CameraBehaviorVehicle.h
trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp
trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h
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
trunk/source/main/gfx/camera/ICameraBehavior.h
Modified: trunk/source/main/gfx/camera/CameraBehavior.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehavior.h 2012-05-18 07:46:34 UTC
(rev 2590)
+++ trunk/source/main/gfx/camera/CameraBehavior.h 2012-05-18 15:27:19 UTC
(rev 2591)
@@ -32,7 +32,7 @@
void update(const CameraManager::cameraContext_t &ctx);
- void activate(const CameraManager::cameraContext_t &ctx) {};
+ void activate(const CameraManager::cameraContext_t &ctx, bool reset =
true) {};
void deactivate(const CameraManager::cameraContext_t &ctx) {};
bool mouseMoved(const CameraManager::cameraContext_t &ctx, const
OIS::MouseEvent& _arg);
Modified: trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp 2012-05-18
07:46:34 UTC (rev 2590)
+++ trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp 2012-05-18
15:27:19 UTC (rev 2591)
@@ -51,6 +51,10 @@
ctx.mCharacter->setAngle(angle);
+#ifdef USE_MYGUI
+ MyGUI::PointerManager::getInstance().setVisible(false);
+#endif // USE_MYGUI
+
return true;
}
@@ -67,18 +71,12 @@
camDist = 0.1f;
camIntertia = 0.0f;
camPositionOffset = Vector3(0.0f, 1.82f, 0.0f);
-#ifdef USE_MYGUI
- MyGUI::PointerManager::getInstance().setVisible(false);
-#endif // USE_MYGUI
} else if ( camMode == CHARACTER_THIRD_PERSON )
{
camRotY = 0.3f;
camDist = 5.0f;
camIntertia = 11.0f;
camPositionOffset = Vector3(0.0f, 1.1f, 0.0f);
-#ifdef USE_MYGUI
- MyGUI::PointerManager::getInstance().setVisible(true);
-#endif // USE_MYGUI
}
}
Modified: trunk/source/main/gfx/camera/CameraBehaviorFixed.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorFixed.h 2012-05-18 07:46:34 UTC
(rev 2590)
+++ trunk/source/main/gfx/camera/CameraBehaviorFixed.h 2012-05-18 15:27:19 UTC
(rev 2591)
@@ -34,7 +34,7 @@
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 activate(const CameraManager::cameraContext_t &ctx, bool reset =
true) {};
void deactivate(const CameraManager::cameraContext_t &ctx) {};
void reset(const CameraManager::cameraContext_t &ctx) {};
Modified: trunk/source/main/gfx/camera/CameraBehaviorFree.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorFree.cpp 2012-05-18 07:46:34 UTC
(rev 2590)
+++ trunk/source/main/gfx/camera/CameraBehaviorFree.cpp 2012-05-18 15:27:19 UTC
(rev 2591)
@@ -88,22 +88,9 @@
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);
#ifdef USE_MYGUI
MyGUI::PointerManager::getInstance().setVisible(false);
-#endif // USE_MYGUI
-}
-void CameraBehaviorFree::deactivate(const CameraManager::cameraContext_t &ctx)
-{
- ctx.mCamera->setFixedYawAxis(false);
-#ifdef USE_MYGUI
- MyGUI::PointerManager::getInstance().setVisible(true);
#endif // USE_MYGUI
+ return true;
}
-
Modified: trunk/source/main/gfx/camera/CameraBehaviorFree.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorFree.h 2012-05-18 07:46:34 UTC
(rev 2590)
+++ trunk/source/main/gfx/camera/CameraBehaviorFree.h 2012-05-18 15:27:19 UTC
(rev 2591)
@@ -34,8 +34,8 @@
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 activate(const CameraManager::cameraContext_t &ctx, bool reset =
true) {};
+ void deactivate(const CameraManager::cameraContext_t &ctx) {};
void reset(const CameraManager::cameraContext_t &ctx) {};
bool switchBehavior(const CameraManager::cameraContext_t &ctx) { return
true; };
Modified: trunk/source/main/gfx/camera/CameraBehaviorStatic.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorStatic.cpp 2012-05-18
07:46:34 UTC (rev 2590)
+++ trunk/source/main/gfx/camera/CameraBehaviorStatic.cpp 2012-05-18
15:27:19 UTC (rev 2591)
@@ -30,7 +30,7 @@
void CameraBehaviorStatic::update(const CameraManager::cameraContext_t &ctx)
{
Vector3 lookAt(Vector3::ZERO);
- Vector3 camPosition(0.0f, 0.0f, 5.0f);
+ Vector3 camPosition(Vector3::ZERO);
if ( ctx.mCurrTruck )
{
@@ -42,14 +42,16 @@
camPosition.x = ((int)(lookAt.x) / 100) * 100 + 50;
camPosition.z = ((int)(lookAt.z) / 100) * 100 + 50;
+ camPosition.y = lookAt.y;
if ( RoRFrameListener::hfinder )
{
- camPosition.y +=
RoRFrameListener::hfinder->getHeightAt(camPosition.x, camPosition.z);
- } else
- {
- camPosition.y += lookAt.y;
+ float h = RoRFrameListener::hfinder->getHeightAt(camPosition.x,
camPosition.z);
+
+ camPosition.y = std::max(h, camPosition.y);
}
+
+ camPosition.y += 5.0f;
float camDist = camPosition.distance(lookAt);
float fov = atan2(20.0f, camDist);
Modified: trunk/source/main/gfx/camera/CameraBehaviorStatic.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorStatic.h 2012-05-18 07:46:34 UTC
(rev 2590)
+++ trunk/source/main/gfx/camera/CameraBehaviorStatic.h 2012-05-18 15:27:19 UTC
(rev 2591)
@@ -34,7 +34,7 @@
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 activate(const CameraManager::cameraContext_t &ctx, bool reset =
true) {};
void deactivate(const CameraManager::cameraContext_t &ctx) {};
void reset(const CameraManager::cameraContext_t &ctx) {};
Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicle.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicle.cpp 2012-05-18
07:46:34 UTC (rev 2590)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicle.cpp 2012-05-18
15:27:19 UTC (rev 2591)
@@ -54,15 +54,18 @@
CameraBehavior::update(ctx);
}
-void CameraBehaviorVehicle::activate(const CameraManager::cameraContext_t &ctx)
+void CameraBehaviorVehicle::activate(const CameraManager::cameraContext_t
&ctx, bool reset)
{
- camDistMin = ctx.mCurrTruck->getMinimalCameraRadius() * 2.0f;
- reset(ctx);
+ if ( reset )
+ {
+ this->reset(ctx);
+ }
}
void CameraBehaviorVehicle::reset(const CameraManager::cameraContext_t &ctx)
{
camRotX = 0.0f;
camRotY = 0.5f;
- camDist = camDistMin * 1.5f;
+ camDist = ctx.mCurrTruck->getMinimalCameraRadius() * 3.0f;
+ camDistMin = ctx.mCurrTruck->getMinimalCameraRadius() * 2.0f;
}
Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicle.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicle.h 2012-05-18
07:46:34 UTC (rev 2590)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicle.h 2012-05-18
15:27:19 UTC (rev 2591)
@@ -32,7 +32,7 @@
void update(const CameraManager::cameraContext_t &ctx);
- void activate(const CameraManager::cameraContext_t &ctx);
+ void activate(const CameraManager::cameraContext_t &ctx, bool reset =
true);
void reset(const CameraManager::cameraContext_t &ctx);
bool switchBehavior(const CameraManager::cameraContext_t &ctx) { return
true; };
Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp
2012-05-18 07:46:34 UTC (rev 2590)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp
2012-05-18 15:27:19 UTC (rev 2591)
@@ -27,6 +27,7 @@
CameraBehaviorVehicleCineCam::CameraBehaviorVehicleCineCam() :
CameraBehaviorVehicle()
+ , lastCineCam(0)
{
fovInternal = FSETTING("FOV Internal", 75);
fovExternal = FSETTING("FOV External", 60);
@@ -57,7 +58,7 @@
ctx.mCamera->setOrientation(orientation);
}
-void CameraBehaviorVehicleCineCam::activate(const
CameraManager::cameraContext_t &ctx)
+void CameraBehaviorVehicleCineCam::activate(const
CameraManager::cameraContext_t &ctx, bool reset)
{
if ( ctx.mCurrTruck->freecinecamera <= 0 )
{
@@ -65,12 +66,16 @@
return;
}
+ if ( reset )
+ {
+ lastCineCam = 0;
+ this->reset(ctx);
+ }
+
currTruck = ctx.mCurrTruck;
ctx.mCamera->setFOVy(Degree(fovInternal));
- reset(ctx);
-
ctx.mCurrTruck->prepareInside(true);
if ( ctx.mOverlayWrapper )
@@ -81,7 +86,7 @@
ctx.mOverlayWrapper->showDashboardOverlays(false,
ctx.mCurrTruck);
}
- ctx.mCurrTruck->currentcamera = 0;
+ ctx.mCurrTruck->currentcamera = lastCineCam;
ctx.mCurrTruck->changedCamera();
}
@@ -97,6 +102,8 @@
ctx.mOverlayWrapper->showDashboardOverlays(true, currTruck);
}
+ lastCineCam = currTruck->currentcamera;
+
currTruck->currentcamera = -1;
currTruck->changedCamera();
}
Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h 2012-05-18
07:46:34 UTC (rev 2590)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h 2012-05-18
15:27:19 UTC (rev 2591)
@@ -32,7 +32,7 @@
void update(const CameraManager::cameraContext_t &ctx);
- void activate(const CameraManager::cameraContext_t &ctx);
+ void activate(const CameraManager::cameraContext_t &ctx, bool reset =
true);
void deactivate(const CameraManager::cameraContext_t &ctx);
void reset(const CameraManager::cameraContext_t &ctx);
@@ -41,6 +41,7 @@
protected:
Beam *currTruck;
+ int lastCineCam;
float fovInternal, fovExternal;
static const int DEFAULT_INTERNAL_CAM_PITCH = -15;
};
Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp
2012-05-18 07:46:34 UTC (rev 2590)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp
2012-05-18 15:27:19 UTC (rev 2591)
@@ -64,7 +64,7 @@
CameraBehavior::update(ctx);
}
-void CameraBehaviorVehicleSpline::activate(const
CameraManager::cameraContext_t &ctx)
+void CameraBehaviorVehicleSpline::activate(const
CameraManager::cameraContext_t &ctx, bool reset)
{
if ( ctx.mCurrTruck->free_camerarail <= 0 )
{
@@ -72,7 +72,7 @@
return;
}
- CameraBehaviorVehicle::activate(ctx);
+ CameraBehaviorVehicle::activate(ctx, reset);
if ( !myManualObject )
{
@@ -100,14 +100,10 @@
splinePos = std::max(0.0f, splinePos);
splinePos = std::min(splinePos, 1.0f);
return true;
- } else if ( ms.buttonDown(OIS::MB_Right) )
+ } else
{
- camRotX += Degree( ms.X.rel * 0.13f);
- camRotY += Degree(-ms.Y.rel * 0.13f);
- camDist += -ms.Z.rel * 0.02f;
- return true;
+ return CameraBehavior::mouseMoved(ctx, _arg);
}
- return false;
}
void CameraBehaviorVehicleSpline::updateSplineDisplay()
Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h 2012-05-18
07:46:34 UTC (rev 2590)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h 2012-05-18
15:27:19 UTC (rev 2591)
@@ -34,7 +34,7 @@
bool mouseMoved(const CameraManager::cameraContext_t &ctx, const
OIS::MouseEvent& _arg);
- void activate(const CameraManager::cameraContext_t &ctx);
+ void activate(const CameraManager::cameraContext_t &ctx, bool reset =
true);
void updateSplineDisplay();
Modified: trunk/source/main/gfx/camera/CameraManager.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraManager.cpp 2012-05-18 07:46:34 UTC
(rev 2590)
+++ trunk/source/main/gfx/camera/CameraManager.cpp 2012-05-18 15:27:19 UTC
(rev 2591)
@@ -33,6 +33,8 @@
#include "ICameraBehavior.h"
+#include <stack>
+
using namespace Ogre;
CameraManager::CameraManager(SceneManager *scm, Camera *cam, RoRFrameListener
*efl, Character *ps, OverlayWrapper *ow, DOFManager *dof) :
@@ -86,7 +88,7 @@
}
}
-void CameraManager::switchBehavior(int newBehaviorID)
+void CameraManager::switchBehavior(int newBehaviorID, bool reset)
{
if (newBehaviorID == currentBehaviorID)
{
@@ -109,9 +111,30 @@
currentBehaviorID = newBehaviorID;
// activate new
- currentBehavior->activate(ctx);
+ currentBehavior->activate(ctx, reset);
}
+void CameraManager::toggleBehavior(int behavior)
+{
+ static std::stack<int> precedingBehaviors;
+
+ if ( behavior != currentBehaviorID && (precedingBehaviors.empty() ||
precedingBehaviors.top() != behavior))
+ {
+ if ( currentBehaviorID >= 0 )
+ {
+ precedingBehaviors.push(currentBehaviorID);
+ }
+ switchBehavior(behavior);
+ } else if ( !precedingBehaviors.empty() )
+ {
+ switchBehavior(precedingBehaviors.top(), false);
+ precedingBehaviors.pop();
+ } else
+ {
+ switchToNextBehavior();
+ }
+}
+
void CameraManager::update(float dt)
{
if ( dt == 0 ) return;
@@ -124,19 +147,19 @@
ctx.mRotScale = Degree(mRotScale);
ctx.mTransScale = mTransScale;
- if ( INPUTENGINE.getEventBoolValueBounce(EV_CAMERA_CHANGE) )
+ if ( currentBehaviorID < CAMERA_BEHAVIOR_END &&
INPUTENGINE.getEventBoolValueBounce(EV_CAMERA_CHANGE) )
{
switchToNextBehavior();
}
if ( INPUTENGINE.getEventBoolValueBounce(EV_CAMERA_FREE_MODE_FIX) )
{
- switchBehavior(CAMERA_BEHAVIOR_FIXED);
+ toggleBehavior(CAMERA_BEHAVIOR_FIXED);
}
if ( !ctx.mCurrTruck &&
INPUTENGINE.getEventBoolValueBounce(EV_CAMERA_FREE_MODE) )
{
- switchBehavior(CAMERA_BEHAVIOR_FREE);
+ toggleBehavior(CAMERA_BEHAVIOR_FREE);
}
if ( !ctx.mCurrTruck &&
dynamic_cast<CameraBehaviorVehicle*>(currentBehavior) )
Modified: trunk/source/main/gfx/camera/CameraManager.h
===================================================================
--- trunk/source/main/gfx/camera/CameraManager.h 2012-05-18 07:46:34 UTC
(rev 2590)
+++ trunk/source/main/gfx/camera/CameraManager.h 2012-05-18 15:27:19 UTC
(rev 2591)
@@ -62,8 +62,9 @@
void update(float dt);
- void switchBehavior(int newBehavior);
+ void switchBehavior(int newBehavior, bool reset = true);
void switchToNextBehavior();
+ void toggleBehavior(int behavior);
bool hasActiveBehavior() { return currentBehavior!=0; };
int getCameraBehavior() { return currentBehaviorID; };
Modified: trunk/source/main/gfx/camera/ICameraBehavior.h
===================================================================
--- trunk/source/main/gfx/camera/ICameraBehavior.h 2012-05-18 07:46:34 UTC
(rev 2590)
+++ trunk/source/main/gfx/camera/ICameraBehavior.h 2012-05-18 15:27:19 UTC
(rev 2591)
@@ -37,7 +37,7 @@
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 activate(const CameraManager::cameraContext_t &ctx, bool
reset = true) = 0;
virtual void deactivate(const CameraManager::cameraContext_t &ctx) = 0;
virtual void reset(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