• Advertisement
Sign in to follow this  

Diffrent gravity vectors in ODE

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

If you intended to correct an error in the post then please contact us.

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 this post


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

Share this post


Link to post
Share on other sites
Quote:
Original post by Ezbez
Manually 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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by BradDaBug
You 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 this post


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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement