|
From: Markus R. <rol...@us...> - 2006-01-06 13:53:46
|
Update of /cvsroot/simspark/simspark/spark/oxygen/physicsserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1518/physicsserver Modified Files: universaljoint.cpp universaljoint.h universaljoint_c.cpp Log Message: (sync with rcssserver3d cvs, thanks Joschka) - implemented ruby function calls for setAxis1 and setAxis2 - made SetParameter and GetParameter public in order to set joint velocities correctly (doesn't seem to work with the base class methods) - implemented SetAxis1 and SetAxis2 to separate setup of anchor and axis Index: universaljoint.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/universaljoint.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** universaljoint.cpp 5 Dec 2005 21:16:49 -0000 1.1 --- universaljoint.cpp 6 Jan 2006 13:53:38 -0000 1.2 *************** *** 36,43 **** { dWorldID world = GetWorldID(); if (world == 0) ! { ! return; ! } mODEJoint = dJointCreateUniversal(world, 0); --- 36,44 ---- { dWorldID world = GetWorldID(); + if (world == 0) ! { ! return; ! } mODEJoint = dJointCreateUniversal(world, 0); *************** *** 49,60 **** Vector3f gAnchor(GetWorldTransform() * anchor); dJointSetUniversalAnchor (mODEJoint, gAnchor[0], gAnchor[1], gAnchor[2]); - - // relative universal axis 1 points up - Vector3f up(GetWorldTransform().Rotate(Vector3f(0,0,1))); - dJointSetUniversalAxis1(mODEJoint,up[0],up[1],up[2]); - - // relative universal axis 2 points right - Vector3f right(GetWorldTransform().Rotate(Vector3f(1,0,0))); - dJointSetUniversalAxis2(mODEJoint,right[0],right[1],right[2]); } --- 50,53 ---- *************** *** 64,102 **** switch (idx) ! { ! case BI_FIRST: ! { ! dReal anchor[3]; ! dJointGetUniversalAnchor (mODEJoint, anchor); ! pos = Vector3f(anchor[0],anchor[1],anchor[2]); ! } ! case BI_SECOND: ! { ! dReal anchor[3]; ! dJointGetUniversalAnchor2(mODEJoint, anchor); ! pos = Vector3f(anchor[0],anchor[1],anchor[2]); ! } ! default: ! break; ! } return GetLocalPos(pos); } float UniversalJoint::GetAngle(EAxisIndex idx) { switch (idx) ! { ! case AI_FIRST: ! return gRadToDeg(dJointGetUniversalAngle1(mODEJoint)); ! case AI_SECOND: ! return gRadToDeg(dJointGetUniversalAngle2(mODEJoint)); ! default: ! return 0; ! } } --- 57,134 ---- switch (idx) ! { ! case BI_FIRST: ! { ! dReal anchor[3]; ! dJointGetUniversalAnchor (mODEJoint, anchor); ! pos = Vector3f(anchor[0],anchor[1],anchor[2]); ! } ! case BI_SECOND: ! { ! dReal anchor[3]; ! dJointGetUniversalAnchor2(mODEJoint, anchor); ! pos = Vector3f(anchor[0],anchor[1],anchor[2]); ! } ! default: ! break; ! } return GetLocalPos(pos); } + void UniversalJoint::SetAxis1(Vector3f & axis) + { + Vector3f first(GetWorldTransform().Rotate(axis)); + dJointSetUniversalAxis1(mODEJoint,first[0],first[1],first[2]); + } + + void UniversalJoint::SetAxis2(Vector3f & axis) + { + Vector3f second(GetWorldTransform().Rotate(axis)); + dJointSetUniversalAxis2(mODEJoint,second[0],second[1],second[2]); + } + + Vector3f UniversalJoint::GetAxis(EAxisIndex idx) + { + Vector3f vec(0,0,0); + + switch (idx) + { + case AI_FIRST: + { + dReal axis[3]; + dJointGetUniversalAxis1(mODEJoint, axis); + vec = Vector3f(axis[0],axis[1],axis[2]); + } + + case AI_SECOND: + { + dReal axis[3]; + dJointGetUniversalAxis2(mODEJoint, axis); + vec = Vector3f(axis[0],axis[1],axis[2]); + } + + default: + break; + } + + return GetLocalPos(vec); + } + float UniversalJoint::GetAngle(EAxisIndex idx) { switch (idx) ! { ! case AI_FIRST: ! return gRadToDeg(dJointGetUniversalAngle1(mODEJoint)); ! case AI_SECOND: ! return gRadToDeg(dJointGetUniversalAngle2(mODEJoint)); ! default: ! return 0; ! } } Index: universaljoint_c.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/universaljoint_c.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** universaljoint_c.cpp 5 Dec 2005 21:16:49 -0000 1.1 --- universaljoint_c.cpp 6 Jan 2006 13:53:38 -0000 1.2 *************** *** 43,46 **** --- 43,78 ---- } + FUNCTION(UniversalJoint,setAxis1) + { + Vector3f inAxis1; + + if ( + (in.GetSize() == 0) || + (! in.GetValue(in.begin(), inAxis1)) + ) + { + return false; + } + + obj->SetAxis1(inAxis1); + return true; + } + + FUNCTION(UniversalJoint,setAxis2) + { + Vector3f inAxis2; + + if ( + (in.GetSize() == 0) || + (! in.GetValue(in.begin(), inAxis2)) + ) + { + return false; + } + + obj->SetAxis1(inAxis2); + return true; + } + FUNCTION(UniversalJoint,getAngle) { *************** *** 79,82 **** --- 111,116 ---- DEFINE_BASECLASS(oxygen/Joint); DEFINE_FUNCTION(setAnchor); + DEFINE_FUNCTION(setAxis1); + DEFINE_FUNCTION(setAxis2); DEFINE_FUNCTION(getAngle); DEFINE_FUNCTION(getAngleRate); Index: universaljoint.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/universaljoint.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** universaljoint.h 5 Dec 2005 21:16:49 -0000 1.1 --- universaljoint.h 6 Jan 2006 13:53:38 -0000 1.2 *************** *** 45,49 **** salt::Vector3f GetAnchor (EBodyIndex idx); ! /** returns one of the hinge angles in degrees, measured between the two bodies, or between the body and the static environment. --- 45,65 ---- salt::Vector3f GetAnchor (EBodyIndex idx); ! /** This function sets up the first axis of the joint ! \param axis a vector describing the axis in relative coordinates ! */ ! void SetAxis1(salt::Vector3f & axis); ! ! /** This function sets up the second axis of the joint ! \param axis a vector describing the axis in local coordinates ! */ ! void SetAxis2(salt::Vector3f & axis); ! ! /** returns the vector describing one of the two axis ! (in local coordinates) ! \param idx index of the desired axis ! */ ! salt::Vector3f GetAxis(EAxisIndex idx); ! ! /** returns one of the axis angles in degrees, measured between the two bodies, or between the body and the static environment. *************** *** 54,61 **** float GetAngleRate(EAxisIndex idx); - protected: - /** creates a new universal joint */ - virtual void OnLink(); - /** sets a joint parameter value */ virtual void SetParameter(int parameter, float value); --- 70,73 ---- *************** *** 63,66 **** --- 75,82 ---- /** returns a joint parameter value */ virtual float GetParameter(int parameter); + + protected: + /** creates a new universal joint */ + virtual void OnLink(); }; |