again one more time.
in the SDK dCustomJoint library there is a joint named dCustomPlane
say you want to make a body moves in the x-y plane.
you make the joint with the plane equation of that plane.
a plane equation is define by a point on the plane and the normal of the plane. this is the equation.
- Code: Select all
dotProduct ((p - p0), n0) = 0;
p is any point in space
p0 is the reference point in the plane
n0 is the normal of the plane
p0 and n0 are the parameters for the joint and the joint implement the equation of the plane to force the chosen point on the body to be on that plane equation.
the body will only be allowed to move on the plane x-y and rotate around the normal n0 (the z axis) pivoted around the point p on the body. That's all there is to it.
and it is what you should be getting each time you apply that joint to a body.
if you delete the joint them the body is free to rotate and move anyway is allowed to move and rotate.
here are the software restrictions.
1-there evaluation of the plane equation is done via a numerical linear matrix solver using a numerical method and numerical integration, therefore the instant error will not be an absolute zero, however the average error should be zero at all time.
2-you only use this joint or a subclass of this joint with root a body of any hierarchy, not doing so will lead to explosions or malfunction of the joint solver. This is, if you have a rag doll of any other arrangement of connected body, you only apply the joint to one body, in the case of graphics this will be the root body.
3- to make a player body similar to the upVector in 3d of the joint library, you use a sub class of the dCustomPlane joint, this joint does not exist in the joint library, but there is a user defined joint in the Flatland demo that does the job. I will copy the code here again.
- Code: Select all
class dPlane2dUpVector: public dCustomPlane
{
public:
dPlane2dUpVector (const dVector& pivot, const dVector& normal, NewtonBody* const child)
:dCustomPlane (pivot, normal, child)
{
}
void SubmitConstraints (dFloat timestep, int threadIndex)
{
dMatrix matrix0;
dMatrix matrix1;
// add one row to prevent body from rotating on the plane of motion
CalculateGlobalMatrix(matrix0, matrix1);
dFloat pitchAngle = CalculateAngle(matrix0.m_up, matrix1.m_up, matrix1.m_front);
NewtonUserJointAddAngularRow(m_joint, pitchAngle, &matrix1.m_front[0]);
// add rows to fix matrix body the the plane
dCustomPlane::SubmitConstraints(timestep, threadIndex);
}
};
Other that this, I do not really know how else I can explain this anymore.
It has been my greatest disappointment than in 16 years going 17, most people has simply ignored the engine based on other peoples narrative, and the very few people who are still using it,
still get this trivial problems that still baffled me, but to that, there is nothing I can really do.