all joints are in, yes. the material class is also impmnethed,
the only thing that that need to be complenetd is this:
dNewtonMaterial need the phsyic smareail propirtoes, liek frution, restitione etc.
this is tha class.
- Code: Select all
class dNewtonMaterial: virtual public dNewtonAlloc
{
public:
dNewtonMaterial(dLong mask = -1)
:dNewtonAlloc()
,m_collisionMask (mask)
{
}
virtual ~dNewtonMaterial()
{
}
dLong m_collisionMask;
// here we add
// float restituion,
// float staticfriction
// float keneticfriction
// etc
};
that class is a supe base class for all collision shapes.
then I nee to add soem inteface funtion to class dNewtonContactMaterial
so far I have only added this whi I use in teh forl lift demo
- Code: Select all
class dNewtonContactMaterial
{
public:
dNewtonContactMaterial(void* const materialHandle)
:m_materialHandle(materialHandle)
{
}
CNEWTON_API dNewtonBody* GetBody0 () const;
CNEWTON_API dNewtonBody* GetBody1 () const;
CNEWTON_API void* GetFirstContact() const;
CNEWTON_API void* GetNextContact(void* const contact) const;
CNEWTON_API void RotateTangentDirections (const void* contact, const dFloat* const directionVector);
// here we add funton for setting teh maniforld marterial properties
// void SetKineticFriction(const void* contact, float friction);
// void SetDynamicsFriction(const void* contact, float friction);
//...
private:
void* m_materialHandle;
};
Then is it just a matter of in the contact clllback, read the collision materials ad make the call to set the matrial properties.
here is hwo si i is now
- Code: Select all
void dNewton::OnContactProcess (const NewtonJoint* const contactJoint, dFloat timestep, int threadIndex)
{
NewtonBody* const body = NewtonJointGetBody0 (contactJoint);
dNewton* const world = (dNewton*) NewtonWorldGetUserData(NewtonBodyGetWorld (body));
// NewtonBody* const body = NewtonJointGetBody0(contactJoint);
for (void* contact = NewtonContactJointGetFirstContact (contactJoint); contact; contact = NewtonContactJointGetNextContact (contactJoint, contact)) {
// dFloat speed;
// dVector point;
// dVector normal;
// dVector dir0;
// dVector dir1;
// dVector force;
NewtonMaterial* const material = NewtonContactGetMaterial (contact);
NewtonMaterialSetContactFrictionCoef (material, 1.0f, 1.0f, 0);
NewtonMaterialSetContactFrictionCoef (material, 1.0f, 1.0f, 1);
/*
NewtonMaterialGetContactForce (material, body, &force.m_x);
NewtonMaterialGetContactPositionAndNormal (material, body, &point.m_x, &normal.m_x);
NewtonMaterialGetContactTangentDirections (material, body, &dir0.m_x, &dir1.m_x);
speed = NewtonMaterialGetContactNormalSpeed(material);
//speed = NewtonMaterialGetContactNormalSpeed(material);
// play sound base of the contact speed.
//
*/
}
dNewtonContactMaterial contactMaterial ((void*)contactJoint);
world->OnContactProcess (&contactMaterial, timestep, threadIndex);
}
bascially jsut leke in Newton the contac material is a local variable, in CNewton, dNewtonContactMaterial si also a local variable.
the funtion call teh egine OnContactCallback. and OnContactCallback call the derive On contacCallback wit teh poiet to teh bodies, and the shapes.
by adding more funtions to dNewtonContactMaterial teh highet lever can set material parameter on teh contact joint.
putting all tother is not more than a dozen line of code. I will complete so more funtionality thsi satuday.