Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Stuck with ODE physics ... No friction with spheres in IanM's update?

Author
Message
Ric
19
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 1st Feb 2006 01:39
Using the original ode as in 5.9, a sphere moving across a surface had friction applied using 'ode set contact fdir1 object,value'. However, since updating to IanM's ODE revision (so that I could get bounce values working as well as friction), I can't get friction to apply to spheres at all, no matter how big the value. I've tried experimenting with several different contact modes but to no avail.

The relevent bit of code that's not working is:



and the whole test code is here .... it's a pool table, where the arrow keys are used to aim and space bar is used to shoot the cue ball.



Any help greatly appreciated.

Milkman
18
Years of Service
User Offline
Joined: 30th Nov 2005
Location: United States
Posted: 1st Feb 2006 01:59 Edited at: 1st Feb 2006 04:08
Try a mass of about 10, and friction about 20 for the balls. Also, make sure the gravity is on for each ball:


One more thing: setting the friction so high for the pool table might actually cause problems; a friction of 40 should be more than enough.

hope that helps

formerly xMik
Ric
19
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 1st Feb 2006 02:46
No joy unfortunately. It doesn't matter what I do to the values of mass/friction - there is still no friction whatsoever. Friction works for boxes, but not for spheres.

Nicholas Thompson
19
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 1st Feb 2006 10:22
You know what would help a GREAT deal is knowing what the hell units all this was in. I played with it last night and managed to get it working in a timer-based environment (ie not having to lock the FPS to 60), thing is, to get realistic looking gravity, I had to set gravity to -98 in the Y direction. Thats 10x more than it should be.

When you set the friction to 20, what does that mean? Friction is measure as μ (Mu) which is generally between 0.0 and 1.0 (as I recall)... Solid on Rubber is usuall between 1.0 and 4.0 - so if you had a coefficient of friction of 20 or more, you're pool ball should have more grip than Michael Schumacher!!!

The other one that confuses me is the erp and cfm values - something to do with error correction?

Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 1st Feb 2006 10:25
Use this command on the sphere

ODE SETSURFACE MODE CONTACT APPROX1 <obj>,1

Nicholas Thompson
19
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 1st Feb 2006 11:28
Ric
19
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 1st Feb 2006 11:37
That made it roll instead of sliding - but since installing IanM's update, balls seem to roll without needing it. And it still doesn't provide any friction for slowing down spheres - they just keep rolling forever.

Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 1st Feb 2006 11:45
It's supposed to change the method of calculating friction, sphere's didn't use to roll without it.

Now it sounds like something else is playing up.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st Feb 2006 14:24
Quote: "When you set the friction to 20, what does that mean"


Friction is set as an angle A setting of zero is no friction, the angle is parallel to a flat surface. A setting of 90 is maximum friction, being applied perpendicular to a flat surface.

I'm not entering the debate as to whether that's acceptable or not, I'm not qualified and I don't care

Ric
19
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 1st Feb 2006 19:58
Where's Ian when you need him?! I'm thinking he may be the only one who can figure this one out.

Tachyon
18
Years of Service
User Offline
Joined: 15th Sep 2005
Location: four-momentum imaginary proper time
Posted: 1st Feb 2006 20:08 Edited at: 1st Feb 2006 20:09
Quote: "Where's Ian when you need him?!"

...
Quote: "IanM Moderator
Location: In my moon base"


That was to fun to be left out...
Could it be possile to make "cheat" friction by adding linear velocity to opposite direction at increasing ammount until ode says that that sphere doesnt move?
Other way is to play with anglecular velocity, that shouldnt create any problems with direction, becouse that ball rotates to the direction where it is heading to. That command rotates the ball, right?

By the way, does this problem include in wrapper only, or in Ode c++ thingy?

(2b)||C!(2b) (It's C++) vs. TO B OR NOT 2B (It's DarkBasic!)
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 1st Feb 2006 20:32
It's not actually friction that is causing you a problem - it's the fact that there was a ... workaround (let's be charitable here ) in the original code that reduced the angular momentum by around 10% each call to the update command.

The workaround was there to stop a problem in ODE that sometimes causes the angular momentum of an object to increase to infinity. I replaced it with a maximum setting instead - I didn't think about how it would affect existing functionality. Anyway ...

When I changed your code to set the fdir1 of all balls to 90, everything settled down, except for the cue ball. I'll tinker a little more and see if I'm still missing something.

For free Plug-ins and source code http://www.matrix1.demon.co.uk
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 1st Feb 2006 20:34
Do you have to use ODE just for the friction? Why don't you just multiply the speed of the ball my something less than one, viola, friction

Ric
19
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 2nd Feb 2006 00:53
Yeah - that was so obvious I didn't think of it! Works as a make-do for the time being, although if the engine took care of the physics I'd hopefully have more control over how the balls roll/slide across the surface - at the moment they do a bit of both!

Login to post a reply

Server time is: 2024-05-02 01:10:35
Your offset time is: 2024-05-02 01:10:35