Revision: 2473 http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2473&view=rev Author: rorthomas Date: 2012-03-16 11:26:47 +0000 (Fri, 16 Mar 2012) Log Message: ----------- mouse grab nodes added, added camerarail basics
Modified Paths: -------------- trunk/source/main/gameplay/SceneMouse.cpp trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h trunk/source/main/physics/Beam.cpp trunk/source/main/physics/BeamData.h trunk/source/main/physics/input_output/SerializedRig.cpp Modified: trunk/source/main/gameplay/SceneMouse.cpp =================================================================== --- trunk/source/main/gameplay/SceneMouse.cpp 2012-03-16 10:44:54 UTC (rev 2472) +++ trunk/source/main/gameplay/SceneMouse.cpp 2012-03-16 11:26:47 UTC (rev 2473) @@ -115,6 +115,9 @@ // walk all nodes for (int j = 0; j < trucks[i]->free_node; j++) { + // check if the mouse grab mode is ok + if(trucks[i]->nodes[j].mouseGrabMode == 1) continue; + // check if our ray intersects with the node std::pair<bool, Real> pair = mouseRay.intersects(Sphere(trucks[i]->nodes[j].smoothpos, 0.1f)); if (pair.first) Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp 2012-03-16 10:44:54 UTC (rev 2472) +++ trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.cpp 2012-03-16 11:26:47 UTC (rev 2473) @@ -74,30 +74,65 @@ Beam *curr_truck = BeamFactory::getSingleton().getCurrentTruck(); if(!curr_truck) return; - // create a simple spline - float x = curr_truck->minx + (curr_truck->maxx - curr_truck->minx) * 0.5f; - float y = curr_truck->miny + (curr_truck->maxy - curr_truck->miny) * 0.5f; - - Vector3 pos1 = Vector3(x, y, curr_truck->minz); - Vector3 pos2 = pos1+Vector3(10,0,0); //Vector3(x, y, curr_truck->maxz); - Vector3 pos3 = pos2+Vector3(-10,10,0); //Vector3(x, y, curr_truck->maxz); - - spline->clear(); - spline->addPoint(pos1); - spline->addPoint(pos2); - spline->addPoint(pos3); - - updateSplineDisplay(); - - // Make all the changes to the camera Vector3 dir = curr_truck->nodes[curr_truck->cameranodepos[0]].smoothpos - curr_truck->nodes[curr_truck->cameranodedir[0]].smoothpos; dir.normalise(); targetDirection = -atan2(dir.dotProduct(Vector3::UNIT_X), dir.dotProduct(-Vector3::UNIT_Z)); targetPitch = 0; - camRatio = 1.0f / (curr_truck->tdt * 4.0f); - camCenterPoint = curr_truck->getPosition(); + if(curr_truck->free_camerarail > 0) + { + spline->clear(); + for(int i = 0; i < curr_truck->free_camerarail; i++) + { + spline->addPoint(curr_truck->nodes[ curr_truck->cameraRail[i] ].AbsPosition); + } + updateSplineDisplay(); + + camCenterPoint = spline->interpolate(splinePos); + } else + { + // fallback :-/ + camCenterPoint = curr_truck->getPosition(); + } + CameraBehaviorOrbit::update(ctx); } + +bool CameraBehaviorVehicleSpline::mouseMoved(const OIS::MouseEvent& _arg) +{ + const OIS::MouseState ms = _arg.state; + Camera *cam = CameraManager::getSingleton().getCamera(); + if(ms.buttonDown(OIS::MB_Right)) + { + if(ms.X.rel < 0) + { + // move left + splinePos += (float)ms.X.rel * 0.0005f; + if(splinePos < 0) + { + splinePos = 0; + // rotate instead + camRotX += Degree( (float)ms.X.rel * 0.13f); + } + if(splinePos > 1) splinePos = 1; + } else if(ms.X.rel > 0) + { + // move right + splinePos += (float)ms.X.rel * 0.0005f; + if(splinePos > 1) + { + splinePos = 1; + // rotate instead + camRotX += Degree( (float)ms.X.rel * 0.13f); + } + } + + camRotY += Degree(-(float)ms.Y.rel * 0.13f); + camDist += -(float)ms.Z.rel * 0.02f; + return true; + } + return false; +} + Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h 2012-03-16 10:44:54 UTC (rev 2472) +++ trunk/source/main/gfx/camera/CameraBehaviorVehicleSpline.h 2012-03-16 11:26:47 UTC (rev 2473) @@ -39,6 +39,8 @@ void update(cameraContext_t &ctx); void updateSplineDisplay(); + + bool mouseMoved(const OIS::MouseEvent& _arg); }; #endif // CAMERABEHAVIORVEHICLESPLINE_H__ Modified: trunk/source/main/physics/Beam.cpp =================================================================== --- trunk/source/main/physics/Beam.cpp 2012-03-16 10:44:54 UTC (rev 2472) +++ trunk/source/main/physics/Beam.cpp 2012-03-16 11:26:47 UTC (rev 2473) @@ -437,6 +437,7 @@ free_shock=0; free_flare=0; free_prop=0; + free_camerarail=0; lastwspeed=0.0; stabcommand=0; stabratio=0.0; Modified: trunk/source/main/physics/BeamData.h =================================================================== --- trunk/source/main/physics/BeamData.h 2012-03-16 10:44:54 UTC (rev 2472) +++ trunk/source/main/physics/BeamData.h 2012-03-16 11:26:47 UTC (rev 2473) @@ -76,8 +76,8 @@ static const int MAX_WINGS = 40; //!< maximum number of wings per truck static const int MAX_CPARTICLES = 10; //!< maximum number of custom particles per truck static const int MAX_PRESSURE_BEAMS = 4000; //!< maximum number of pressure beams per truck +static const int MAX_CAMERARAIL = 50; //!< maximum number of camera rail points - static const float RAD_PER_SEC_TO_RPM = 9.54929659643f; //!< Convert radian/second to RPM (60/2*PI) /* other global static definitions */ @@ -157,6 +157,7 @@ BTS_VIDCAM, BTS_HOOKS, BTS_LOCKGROUPS, + BTS_CAMERARAIL, BTS_END, }; @@ -413,6 +414,7 @@ bool iIsSkin; bool isSkin; bool contacter; + int mouseGrabMode; int pos; float collRadius; Ogre::SceneNode *mSceneNode; //!< visual @@ -853,6 +855,9 @@ std::vector<std::string> description; + int cameraRail[MAX_CAMERARAIL]; + int free_camerarail; + char guid[128]; int hasfixes; int wingstart; Modified: trunk/source/main/physics/input_output/SerializedRig.cpp =================================================================== --- trunk/source/main/physics/input_output/SerializedRig.cpp 2012-03-16 10:44:54 UTC (rev 2472) +++ trunk/source/main/physics/input_output/SerializedRig.cpp 2012-03-16 11:26:47 UTC (rev 2473) @@ -121,6 +121,7 @@ {BTS_VIDCAM, "videocamera", false}, {BTS_HOOKS, "hooks", false}, {BTS_LOCKGROUPS, "lockgroups", false}, + {BTS_CAMERARAIL, "camerarail", false}, {BTS_END, "end", false}, }; @@ -1498,6 +1499,12 @@ case 'c': //contactless nodes[id].contactless = 1; break; + case 'm': // not able to mouse grab + nodes[id].mouseGrabMode = 1; + break; + case 'n': // mouse grab with hilight + nodes[id].mouseGrabMode = 2; + break; case 'h': //hook // emulate the old behaviour using new fancy hookgroups //id check, avoid beam n0->n0 @@ -1572,6 +1579,15 @@ continue; } + else if (c.mode == BTS_CAMERARAIL) + { + int n = parse_args(c, args, 1); + if (n>0 && free_camerarail < MAX_CAMERARAIL) + { + cameraRail[free_camerarail] = parse_node_number(c, args[0]); + free_camerarail++; + } + } else if (c.mode == BTS_LOCKGROUPS) { //parse lockgroups @@ -5491,6 +5507,7 @@ nodes[pos].isSkin=nodes[pos].iIsSkin; nodes[pos].pos=pos; nodes[pos].mSceneNode = NULL; + nodes[pos].mouseGrabMode=0; // nodes[pos].tsmooth=Vector3::ZERO; if (type==NODE_LOADED) masscount++; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure _______________________________________________ Rigsofrods-devel mailing list Rigsofrods-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel