Skip to main content
gamedev.net
🔒 Locked

ode friction

Started by Troodon 1 reply 850+ views
Original Post
Troodon
Troodon
Hello! I have a problem concerning the friction models and ODE. I have a dynamic movable box that is placed on top of an other (static) box. When I issue the static box to move in the x or y direction the dynamic box doesnt follow. Everything else seem to work fine, i.e. the gravity and the collision detection. My collision callback: void nearCallback(void *data, dGeomID o1, dGeomID o2) { // check collision between spaces if (dGeomIsSpace(o1) || dGeomIsSpace(o2)) { dSpaceCollide2(o1,o2,data,&Collide); return; } // create contact points dContact contact[MAX_CONTACTS]; int n = dCollide (o1, o2, MAX_CONTACTS, &(contact[0].geom), sizeof(dContact)); for (int i=0; i<n; i++) { contact.surface.mode = dContactMu2 | dContactSoftERP | dContactSoftCFM | dContactApprox1 | dContactSlip1 | dContactSlip2 | dContactBounce; contact.surface.slip1 = 0.0; contact.surface.slip2 = 0.7; contact.surface.mu = 0.2; contact.surface.soft_erp = 0.96; contact.surface.soft_cfm = 0.04; contact.surface.bounce = 0.1; dJointID c = dJointCreateContact (world,jointgroup,&contact); dJointAttach (c, dGeomGetBody(contact.geom.g1), dGeomGetBody(contact.geom.g2)); } } I'm very greatful for any help!
hplus0603
hplus0603
0.2 is a pretty low value for mu (similar to, say, olive oil on polished marble).

0.7 is a large value for slip2.

0.04 is a large value for soft_cfm.

If you want the box to go with it, I would first attempt to change those values to 1.0, 0.001 and 0.001 respectively, just to make sure it can be made to work.

Second, you're not actually setting an fdir, so ODE will pick a random direction as the fdir -- when you use the slip2 and mu2 value, you really want to set your own fdir to a consistent direction.

Third, if you still can't get it to work, then get the velocity of each of the points of contact (body 1 and body 2) and set the contact surface velocity to be the average of those two velocities. This will significantly smooth out the movement in the joint.
enum Bool { True, False, FileNotFound };
Troodon
Troodon
Thanks for your reply!

I have tried the fdir1 but I can't make it work. The third solution sounds good, but I dont know how to implement it. Does anyone know where I can find any code for it?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.