Diffrent gravity vectors in ODE

This topic is 4449 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I've been thinking of implementing diffrent gravity vectors in my engine (like in Serius Sam or Prey). A ggod example of such thing is in SS when the player can walk on the inside of a sphere with gravity push him away from the center. My question is: How to do that in ODE? I can't use simple dWorldSetGravity().

Share on other sites
Manually apply a force to each object's center of mass?

Share on other sites
Manually apply a force that is porportional to the mass of the object to each object's center of gravity?

Share on other sites
Quote:
 Original post by EzbezManually apply a force that is porportional to the mass of the object to each object's center of gravity?

That could work. Before I apply the force to the body should I use dWorldImpulseToForce() to scale it? I'm new to ODE and I don't fully understand the meaning of this function. So if I have a gravity vecor = (0,0,-9.81) and I want to apply a force to the body should I use:

dWorldImpulseToForce(WorldID,StepSize,0,0,-9.81,Force);dBodyAddForce(BodyID,Force[0],Force[1],Force[2]);

or just:

dBodyAddForce(BodyID,0,0,-9.81);

I think the first one is correct but can you verify?

Share on other sites
dMass mass;float gravity[] = {0, 0, -9.81f}; float gforce[3];dBodyGetMass(myBody, &mass);gforce[0] = mass.mass * gravity[0];gforce[1] = mass.mass * gravity[1];gforce[2] = mass.mass * gravity[2];dBodyAddForce(myBody, gforce[0], gforce[1], gforce[2]);

Should work. This is pretty much what Ezbez said to do. You shouldn't need to scale anything.

Share on other sites
Quote:
 Original post by BradDaBugYou shouldn't need to scale anything.

But if I want to add the force every frame shouldn't it be scaled? I mean if I have a time step about 0.001s and 0.1s then adding the same force would give diffrent results.

Share on other sites
dWorldStep() and dQuickStep() should take care of that for you. That's why you pass them the step size.

Share on other sites
Ok, I'll add the same force every frame. Thanks!

1. 1
2. 2
Rutin
25
3. 3
4. 4
5. 5

• 10
• 13
• 19
• 14
• 9
• Forum Statistics

• Total Topics
632942
• Total Posts
3009339
• Who's Online (See full list)

There are no registered users currently online

×