Revision: 2763 http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2763&view=rev Author: ulteq Date: 2012-05-31 15:30:14 +0000 (Thu, 31 May 2012) Log Message: ----------- -Feature: Spline-camera behavior (now completely functional)
Modified Paths: -------------- trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp 2012-05-30 21:52:00 UTC (rev 2762) +++ trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp 2012-05-31 15:30:14 UTC (rev 2763) @@ -61,7 +61,7 @@ camLookAt = spline->interpolate(splinePos); - if ( INPUTENGINE.isKeyDownValueBounce(OIS::KC_SPACE) ) + if ( INPUTENGINE.isKeyDown(OIS::KC_LSHIFT) && INPUTENGINE.isKeyDownValueBounce(OIS::KC_SPACE) ) { autoTracking = !autoTracking; #ifdef USE_MYGUI @@ -83,7 +83,7 @@ centerDir.normalise(); Radian oldTargetDirection = targetDirection; targetDirection = -atan2(centerDir.dotProduct(Vector3::UNIT_X), centerDir.dotProduct(-Vector3::UNIT_Z)); - if ( (targetDirection * oldTargetDirection).valueRadians() < 0.0f ) + if ( targetDirection.valueRadians() * oldTargetDirection.valueRadians() < 0.0f && centerDir.length() < camDistMin) { camRotX = -camRotX; } @@ -180,7 +180,6 @@ for (int i = 0; i < ctx.mCurrTruck->free_camerarail; i++) { - spline->addPoint(ctx.mCurrTruck->nodes[ctx.mCurrTruck->cameraRail[i]].AbsPosition); splineNodes.push_back(&ctx.mCurrTruck->nodes[ctx.mCurrTruck->cameraRail[i]]); } @@ -192,22 +191,47 @@ { for (std::list<Beam*>::iterator it = linkedBeams.begin(); it != linkedBeams.end(); ++it) { - if ( (*it)->free_camerarail <= 0 ) break; + if ( (*it)->free_camerarail <= 0 ) continue; - Vector3 lastPoint = spline->getPoint(spline->getNumPoints() - 1); - Vector3 firstPoint = (*it)->nodes[(*it)->cameraRail[0]].AbsPosition; - Vector3 secondPoint = (*it)->nodes[(*it)->cameraRail[1]].AbsPosition; + Vector3 curSplineFront = splineNodes.front()->AbsPosition; + Vector3 curSplineBack = splineNodes.back() ->AbsPosition; - if ( firstPoint.distance(lastPoint) > 5.0f ) break; + Vector3 linkedSplineFront = (*it)->nodes[(*it)->cameraRail[0]].AbsPosition; + Vector3 linkedSplineBack = (*it)->nodes[(*it)->cameraRail[(*it)->free_camerarail - 1]].AbsPosition; - for (int i = 1; i < (*it)->free_camerarail; i++) + if ( curSplineBack.distance(linkedSplineFront) < 5.0f ) { - spline->addPoint((*it)->nodes[(*it)->cameraRail[i]].AbsPosition); - splineNodes.push_back(&(*it)->nodes[(*it)->cameraRail[i]]); + for (int i = 1; i < (*it)->free_camerarail; i++) + { + splineNodes.push_back(&(*it)->nodes[(*it)->cameraRail[i]]); + } + } else if ( curSplineFront.distance(linkedSplineFront) < 5.0f ) + { + for (int i = 1; i < (*it)->free_camerarail; i++) + { + splineNodes.push_front(&(*it)->nodes[(*it)->cameraRail[i]]); + } + } else if ( curSplineBack.distance(linkedSplineBack) < 5.0f ) + { + for (int i = (*it)->free_camerarail - 2; i >= 0; i++) + { + splineNodes.push_back(&(*it)->nodes[(*it)->cameraRail[i]]); + } + } else if ( curSplineFront.distance(linkedSplineBack) < 5.0f ) + { + for (int i = (*it)->free_camerarail - 2; i >= 0; i++) + { + splineNodes.push_front(&(*it)->nodes[(*it)->cameraRail[i]]); + } } } } + for (unsigned int i = 0; i < splineNodes.size(); i++) + { + spline->addPoint(splineNodes[i]->AbsPosition); + } + Vector3 firstPoint = spline->getPoint(0); Vector3 lastPoint = spline->getPoint(spline->getNumPoints() - 1); Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h 2012-05-30 21:52:00 UTC (rev 2762) +++ trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h 2012-05-31 15:30:14 UTC (rev 2763) @@ -50,7 +50,7 @@ bool splineClosed; bool autoTracking; - std::vector<node*> splineNodes; + std::deque<node*> splineNodes; int numLinkedBeams; static const int splineDrawResolution = 200; 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 Rigsofrods-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel