Here's the callback code that I'm using( mostly taken from the Newton Friction SDK demo. Can you tell me how to get the box to slow down or stop when the ramp's friction is increased?
-Bird
- Code: Select all
void Newton3Engine::userContactFriction (const NewtonJoint * contactJoint,
dFloat timestep,
int threadIndex)
{
const NewtonBody* const body0 = NewtonJointGetBody0(contactJoint);
NewtonEntity* const entity0 = (NewtonEntity*) NewtonBodyGetUserData (body0);
Surface::Ptr surface0 = entity0->component->getSurface(0);
dFloat friction0 = surface0->getMaterial().friction;
const NewtonBody* const body1 = NewtonJointGetBody1(contactJoint);
NewtonEntity* const entity1 = (NewtonEntity*) NewtonBodyGetUserData (body1);
Surface::Ptr surface1 = entity1->component->getSurface(0);
dFloat friction1 = surface1->getMaterial().friction;
for (void* contact = NewtonContactJointGetFirstContact (contactJoint); contact; contact = NewtonContactJointGetNextContact (contactJoint, contact))
{
NewtonMaterial* const material = NewtonContactGetMaterial (contact);
NewtonMaterialSetContactFrictionCoef (material, friction0, friction0/2.0f, 0);
NewtonMaterialSetContactFrictionCoef (material, friction1, friction1/2.0f, 1);
}
}