Revision: 2760
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2760&view=rev
Author:   ulteq
Date:     2012-05-30 18:16:11 +0000 (Wed, 30 May 2012)
Log Message:
-----------
-Feature: Further improved spline-camera behavior.
~fixed two bugs
+autoTracking now switchable (space key)
+translation speed now adjustable (shift key (faster), alt key (slower))

Modified Paths:
--------------
    trunk/source/main/gfx/camera/CameraBehaviorOrbit.cpp
    trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp
    trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h

Modified: trunk/source/main/gfx/camera/CameraBehaviorOrbit.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorOrbit.cpp        2012-05-30 
17:58:43 UTC (rev 2759)
+++ trunk/source/main/gfx/camera/CameraBehaviorOrbit.cpp        2012-05-30 
18:16:11 UTC (rev 2760)
@@ -154,5 +154,6 @@
 void CameraBehaviorOrbit::reset(const CameraManager::cameraContext_t &ctx)
 {
        camRotX = 0.0f;
+       camRotY = 0.3f;
        gEnv->mainCamera->setFOVy(ctx.fovExternal);
 }

Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp        
2012-05-30 17:58:43 UTC (rev 2759)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp        
2012-05-30 18:16:11 UTC (rev 2760)
@@ -20,7 +20,9 @@
 #include "CameraBehaviorVehicleSpline.h"
 
 #include "Beam.h"
+#include "Console.h"
 #include "InputEngine.h"
+#include "Language.h"
 #include "Ogre.h"
 
 using namespace Ogre;
@@ -59,16 +61,32 @@
 
                camLookAt = spline->interpolate(splinePos);
 
-               if ( !INPUTENGINE.isKeyDown(OIS::KC_SPACE) )
+               if ( INPUTENGINE.isKeyDownValueBounce(OIS::KC_SPACE) )
                {
+                       autoTracking = !autoTracking;
+#ifdef USE_MYGUI
+                       if ( autoTracking )
+                       {
+                               
Console::getSingleton().putMessage(Console::CONSOLE_MSGTYPE_INFO, 
Console::CONSOLE_SYSTEM_NOTICE, _L("auto tracking") + U(" ") + _L("enabled"), 
"camera_go.png", 3000);
+                       } else
+                       {
+                               
Console::getSingleton().putMessage(Console::CONSOLE_MSGTYPE_INFO, 
Console::CONSOLE_SYSTEM_NOTICE, _L("auto tracking") + U(" ") + _L("disabled"), 
"camera_go.png", 3000);
+                       }
+#endif // USE_MYGUI
+               }
+
+               if ( autoTracking )
+               {
                        Vector3 centerDir = ctx.mCurrTruck->getPosition() - 
camLookAt;
                        if ( centerDir.length() > 1.0f )
                        {
                                centerDir.normalise();
+                               Radian oldTargetDirection = targetDirection;
                                targetDirection = 
-atan2(centerDir.dotProduct(Vector3::UNIT_X), 
centerDir.dotProduct(-Vector3::UNIT_Z));
-                       } else
-                       {
-                               targetDirection = 
-atan2(dir.dotProduct(Vector3::UNIT_X), dir.dotProduct(-Vector3::UNIT_Z));
+                               if ( (targetDirection * 
oldTargetDirection).valueRadians() < 0.0f )
+                               {
+                                       camRotX = -camRotX;
+                               }
                        }
                }
        }
@@ -82,13 +100,19 @@
 
        if ( INPUTENGINE.isKeyDown(OIS::KC_LCONTROL) && 
ms.buttonDown(OIS::MB_Right) )
        {
+               Real splinePosDiff = ms.X.rel * std::max(0.00005f, splineLength 
* 0.0000001f);
+
+               if ( INPUTENGINE.isKeyDown(OIS::KC_LSHIFT) || 
INPUTENGINE.isKeyDown(OIS::KC_RSHIFT) )
+               {
+                       splinePosDiff *= 3.0f;
+               }
+
                if ( INPUTENGINE.isKeyDown(OIS::KC_LMENU) )
                {
-                       splinePos += ms.X.rel * std::max(0.0001f, splineLength 
* 0.0000001f);
-               } else
-               {
-                       splinePos += ms.X.rel * std::max(0.00005f, splineLength 
* 0.0000005f);
+                       splinePosDiff *= 0.1f;
                }
+
+               splinePos += splinePosDiff;
                
                if ( ms.X.rel > 0 && splinePos > 0.99f )
                {
@@ -141,7 +165,7 @@
 {
        CameraBehaviorOrbit::reset(ctx);
 
-       camDist = std::min(ctx.mCurrTruck->getMinimalCameraRadius() * 2.0f, 
20.0f);
+       camDist = std::min(ctx.mCurrTruck->getMinimalCameraRadius() * 2.0f, 
33.0f);
        
        splinePos = 0.5f;
 }

Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h
===================================================================
--- trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h  2012-05-30 
17:58:43 UTC (rev 2759)
+++ trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h  2012-05-30 
18:16:11 UTC (rev 2760)
@@ -48,6 +48,7 @@
        Ogre::Real splineLength;
        Ogre::Real splinePos;
        bool splineClosed;
+       bool autoTracking;
 
        std::vector<node*> splineNodes;
        int numLinkedBeams;

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

Reply via email to