Update of /cvsroot/simspark/simspark/spark/oxygen/physicsserver
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21747
Modified Files:
hingejoint.h hingejoint.cpp
Log Message:
-sync with rcssserver3d CVS
Index: hingejoint.cpp
===================================================================
RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/hingejoint.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** hingejoint.cpp 5 Dec 2005 21:16:49 -0000 1.1
--- hingejoint.cpp 2 Jan 2006 18:10:36 -0000 1.2
***************
*** 49,56 ****
Vector3f gAnchor(GetWorldTransform() * anchor);
dJointSetHingeAnchor (mODEJoint, gAnchor[0], gAnchor[1], gAnchor[2]);
-
- // calculate hinge axis (pos. z, relative to world transform)
- Vector3f up(GetWorldTransform().Rotate(Vector3f(0,0,1)));
- dJointSetHingeAxis(mODEJoint, up[0], up[1], up[2]);
}
--- 49,52 ----
***************
*** 82,85 ****
--- 78,118 ----
}
+ void HingeJoint::SetAxis(EAxisIndex idx)
+ {
+ switch(idx)
+ {
+ case AI_FIRST:
+ {
+ // calculate hinge axis (pos. x, relative to world transform)
+ Vector3f right(GetWorldTransform().Rotate(Vector3f(1,0,0)));
+ dJointSetHingeAxis(mODEJoint, right[0], right[1], right[2]);
+ break;
+ }
+ case AI_SECOND:
+ {
+ // calculate hinge axis (pos. y, relative to world transform)
+ Vector3f forward(GetWorldTransform().Rotate(Vector3f(0,1,0)));
+ dJointSetHingeAxis(mODEJoint, forward[0], forward[1], forward[2]);
+ break;
+ }
+ case AI_THIRD:
+ {
+ // calculate hinge axis (pos. z, relative to world transform)
+ Vector3f up(GetWorldTransform().Rotate(Vector3f(0,0,1)));
+ dJointSetHingeAxis(mODEJoint, up[0], up[1], up[2]);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ Vector3f HingeJoint::GetAxis()
+ {
+ dReal axis[3];
+ dJointGetHingeAxis(mODEJoint, axis);
+ return Vector3f (axis[0], axis[1], axis[2]);
+ }
+
float HingeJoint::GetAngle()
{
Index: hingejoint.h
===================================================================
RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/hingejoint.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** hingejoint.h 5 Dec 2005 21:16:49 -0000 1.1
--- hingejoint.h 2 Jan 2006 18:10:36 -0000 1.2
***************
*** 45,48 ****
--- 45,57 ----
salt::Vector3f GetAnchor(EBodyIndex idx);
+ /** Sets the joint axis. The connected bodies movements will be
+ constrained to move around this axis.
+ */
+ void SetAxis(EAxisIndex idx);
+
+ /** Returns the hinge axis in the local coordinate system
+ */
+ salt::Vector3f GetAxis();
+
/** returns the hinge angle in degrees, measured between the two
bodies, or between the body and the static environment.
***************
*** 53,60 ****
float GetAngleRate();
- protected:
- /** creates a new hingejoint joint */
- virtual void OnLink();
-
/** sets a joint parameter value */
virtual void SetParameter(int parameter, float value);
--- 62,65 ----
***************
*** 62,65 ****
--- 67,74 ----
/** returns a joint parameter value */
virtual float GetParameter(int parameter);
+
+ protected:
+ /** creates a new hingejoint joint */
+ virtual void OnLink();
};
|