NewtonConstraintCreateBall is an example of the 'old' build in joints.
NewtonConstraintCreateUserJoint is the one and only new joint. You can make pretty anything out of it: hinge, ball-socket, corkscrew, whatever.
Using it is not so easy, but most if not all joints you will ever need are ready to use using the joint library ("dCustomJoints"-source folder).
All Joints from that lib are based on the UserJoint, also the kinematic joint.
The porblems are:
* There is no manual. (Correct me if i'm wrong) So we need to use the code itself for documentation.
* The lib is not part of Newton itself, but it seems it is covered by your wrapper.
We want to use kinematic controller, so we open it's header file from the dCustomJoints folder: CustomKinematicController.h:
class JOINTLIBRARY_API CustomKinematicController: public NewtonCustomJoint
{
public:
CustomKinematicController (const NewtonBody* body, const dVector& attachmentPointInGlobalSpace);
...
This is the constructor of the joint. So we create it using:
- Code: Select all
myJoint = new CustomKinematicController (myBarrel, myPickPositionPoint_usuallyBarrelCenter);
...
void SetPickMode (int mode); // mode = 1 -> constrain orientation, 0-> constrain position only
void SetMaxLinearFriction(dFloat accel); // how "strong" are the constraints?
void SetMaxAngularFriction(dFloat alpha);
...
Setup our joint:
- Code: Select all
myJoint->SetMaxLinearFriction(some scene dependent value);
myJoint->SetMaxAngularFriction(some scene dependent value);
myJoint->SetPickMode (1);
and further we see:
...
void SetTargetRotation (const dQuaternion& rotation); // Set the target stuff...
void SetTargetPosit (const dVector& posit);
void SetTargetMatrix (const dMatrix& matrix);
...
so at runtime we want to update our hand position (target):
- Code: Select all
matrix me = BodyGetMatrix (player);
me.posit += handOffsetVector;
myJoint->SetTargetMatrix (me);
wrekwired wrote:And how do i connect a child joint to a non newton body like a door and it's frame should not move with it.
Example:
joint = NewtonConstraintCreateBall ( const NewtonWorld* newtonWorld, const dFloat* pivotPoint, const NewtonBody* childBody, const NewtonBody* parentBody)
Set child body to the door, but parent body to null.