Adjust center of gravity?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
preen
Posts: 16
Joined: Sun Feb 20, 2011 6:10 pm

Adjust center of gravity?

Post by preen »

When a dynamic body is made, the CoG seems to be set as the center of volume of the shape. The CoG is then the same as the object's position, and the points in the object's shape are in relation to that position.

Is it possible to adjust the CoG after creating a body?

Say, if you wanted to simulate a body with a drasticly odd distribution of mass. Like an hourglass, with all the sand in one side, or a race car, with it's mass close to the floor.

If not, is it possible to use a compound body to get that result? (each half of the hourglass would be it's own entry with it's own mass. When combined, the CoG would be closer to the full side)
Last edited by preen on Sun Sep 25, 2011 3:11 am, edited 1 time in total.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Adjust center of gravity?

Post by Norbo »

Is it possible to adjust the CoG after creating a body?
Yup, by offsetting the collision shape:

Code: Select all

entity.CollisionInformation.LocalPosition = new Vector3(0,1,0);
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Adjust center of gravity?

Post by Norbo »

is it possible to use a compound body to get that result? (each half of the hourglass would be it's own entry with it's own mass. When combined, the CoG would be closer to the full side)
That approach would also work.
preen
Posts: 16
Joined: Sun Feb 20, 2011 6:10 pm

Re: Adjust center of gravity?

Post by preen »

That does the trick, thanks Norbo.
Post Reply