Page 1 of 1

Center of gravity

Posted: Sun Sep 02, 2012 12:16 pm
by Tasaq
Hi again,
I want to see center of gravity, but I only know how to see center of mass. I attach screenshot where green ball is my center of mass and red ball is world matrix of object( this ball isn't collision model, I swapped car's convex hull with red ball in a draw call in order to see postion of green ball).

Code: Select all

            ball.setColor(Color.Green.ToVector3());
            ball.draw(Matrix.CreateTranslation( car.Body.Position));
            ball.setColor(Color.Red.ToVector3());
            ball.draw(car.Body.CollisionInformation.WorldTransform.Matrix);
I can't get my car to behave properly(or should I say, as I want it to) so I want to see CoG to give me some idea if I set certain values wrong or right (my car becomes either extremely oversteered or understeered at higher speeds with almost no acceleration).

Image

Re: Center of gravity

Posted: Sun Sep 02, 2012 4:25 pm
by Norbo
The center of gravity is the center of mass, which is the entity.Position.

You can offset the collision shape from the entity.Position by setting the entity.CollisionInformation.LocalPosition. The vehicle in the BEPUphysicsDemos uses this to make turning more stable. Here's the relevant line in the VehicleInput:

Code: Select all

            body.CollisionInformation.LocalPosition = new Vector3(0, .5f, 0);
That puts the center of the vehicle body 0.5 units above the body.Position. The result is that the center of mass is lower relative to the collision geometry and the car is less prone to flipping during turns.