ODE Problem

Blitz3D Forums/Blitz3D Userlibs/ODE Problem

jfk EO-11110(Posted 2007) [#1]
I'm just beginning with ODE, currently using DC's wrapper/samples release. In my scene there's some kind of pendulum that may be pushed. This works well so far, there's only one problem: The pendulum is swinging way too long time. What I needed was some kind of soft brake that would stop it earlier. Probably it has something to do with axial friction ?

The function is using ODE_dJointCreateBall() and ODE_dJointAttach to link the parts of the pendulum. How to make this stop swinging earlier?

Thanks.


Danny(Posted 2007) [#2]
I'm not familiar with "DC's wrapper", but I can imagine you can GET the current angular force on the pendulum as well as SET the angular force. With that you can add your own sort of dampening like this:

dampfactor# = 0.99 ; the lower the value, the more/quicker it will slow down
force# = GetangularForce#(pendulum)
force# = force# * dampfactor#
SetAngularForce pendulum, force#

if you drift my catch...

d.


jfk EO-11110(Posted 2007) [#3]
Thanks. I see there's ODE_dBodyGetForceX and ODE_dBodyGetTorqueX/y/z, probably they would work for something like what you said.

Although, I would rather like a global setting command, like
ODE_dSetBounce() etc. There's a group of global settings commands, I just don't know which one and what parameters.


jfk EO-11110(Posted 2007) [#4]
ah.. right from the ode wiki thingy page FAQ:
"# 3.16 How do I stop things from rolling off into infinity, or pendulums from swinging forever?": click here

So it seems your suggestion is the only way to solve the problem :/ I just tried this with getForce as well as with GetTorque, but for some scary reason there's absolutely no reaction.

I am using in 2 nested FOR loops (x and y):

pm2.PhysicMesh = Object.PhysicMesh(towelSeg(x,y))
xforce#=-ODE_dGetBodyForceX#(pm2\body)*0.01
the same for y and z
ODE_dBodyAddForce(pm2\body, xforce, yforce, zforce)

Is there anything missing?

EDIT
Grrr! Wasted several hours now, trying to find out why it doesn't work. Code seems to be ok, simply no reaction.

EDIT2
AAH! Seems like finally it's working, kind of. But I had to use the commands:
ODE_dBodyGetAngularVelX/y/z and ODE_dBodySetAngularVel
instead. Tho, I still cannot control the swing sustaing directly, that's strange.


Danny(Posted 2007) [#5]
Yes it's a bit disapointing you can't set the friction on joints. I was trying to do the exact same thing myself last week.

Also be warned that the amount of dampening you apply should also be multiplied by some delta-time factor! Else it will behave very differently on different types of systems.

Also add mass to the bodies in your chain/pendulum to give a more realistic behaviour - else it will almost look like they're floating in zero-gravity.

AND what also seriously affects it ofcourse is how (much) you update the simulator every frame. The wrong setting would make it slow and unrealistic - OR make it way too fast and start shaking..

Using the autoDisable options in ODE you can also tweak 'when' the pendulum/chain should evently 'stop' moving (dBodySetAutoDisableLinearThreshold and dBodySetAutoDisableAngularThreshold) - since you want it to come to rest nearly 'as soon as possible' but when the pendulum is coming to a stop you want to make sure it's hanging dead-straight, in stead of at a dodgy angle.

One advantage of using the Velocity functions (angular/linearVelocity) in stead of the Force functions is that the bodies keep their internal momentum. So if an external body should collide with the chain/pendulum, it will react properly...

Hope this helps,
Danny.
d.


jfk EO-11110(Posted 2007) [#6]
Hi. Thanks for the input.
Well it's about a curtain, to be exact. A grid of 10*10 Segements. For test purposes these are Cube objects, linked in ball mode. So I guess I'd rather have to use angular functions than the "linear" ones. Unfortunately this makes the whole curtain much more sluggish, heavy. Like a grid of lead bocks.

The idea is a lightweight curtain that reacts on wind.

When I set the mass to something very low, under 1.0, then there are strange errors.

EDIT
I think I got it. I'm using a combination of dampening of ODE_dBodySetAngularVel and ODE_dBodySetLinearVel, multiplied by 0.99 each frame. That's looking pretty good. Kind of: Angular friction plus Air resistance from the LinearVel.

Again, thank you.


Danny(Posted 2007) [#7]
What you could try is to ONLY add mass to the BOTTOM row of 10 cubes in the curtain grid. And let them 'pull the others taunt' and eventually to a rest using the autodisable options. I use a similar trick on my ragdolls where for example only the hands have mass, whilst the upper/lower arms haven't. This gives me a nicer / more realistic effect when arms (or legs) are flapping about :)

But this way you might only have to deal with 10 objects in stead of 100 objects. If that works, perhaps you could even do 'every other' cube ie. only have to deal with 5 objects ???

Haven't done heavy cloth-like tricks like this before so I'm very curious how you get along and can get this to work nicely..

danny.