Center Of Mass

Jan 26, 2008 at 6:29 PM
I'm curious to know if there's a way to manually set the position of the center of mass for a primitive (without actually modifying the engine.) It looks like the "com" is calculated automatically in CollisionSkin.GetMassProperties() based on the primitives in the collision skin. In my example, I'm trying to create a dynamic bowling pin using a capsule as the main body, and then with several small boxes on the bottom (each rotated a little bit) to simulate the bottom of a cylinder. However, with the extra primitives at the bottom, the overall object has a very low center of mass. In fact, the whole thing acts like a weeble, and just keeps popping back up! Players of my game will get pretty frustrated if they can't knock any of the pins down! Any quick suggestions would be greatly appreciated.

Overall I'm extremely satisfied with the JigLibX engine. It's amazingly easy to use and has some great features. If this is just your alpha release, I'm really looking forward to seeing all future revisions!

Stu
Coordinator
Jan 26, 2008 at 7:10 PM
uhh, combined skins. Iam not sure that they work 100% yet. I did only one or two tests. The com and the inertia tensor should be calculated correct, so that you get the expected effect. To set the intertia/center of mass you can use the body.BodyInertia property.

You added several skins to one body, correct? Have your tried to let the debug drawer draw the bouding boxes? (To make sure the primitves are where you expect them to be) Change the draw code in PhysicObject to

if (this.collision != null)
{
int count = collision.NumPrimitives;
for (int i = 0; i < count; i++)
{
AABox box = new AABox();
box.AddPrimitive(collision.GetPrimitiveOldWorld(i));
((JiggleGame)this.Game).DebugDrawer.DrawAabb(box.MinPos, box.MaxPos, Color.Red);
}
}

This should draw everys primitve bounding box. (You also have to enable the debugDrawer. In the demo its turned off with debugDrawer.Enabled = false)
Coordinator
Jan 26, 2008 at 7:18 PM
Another (temporary?) solution could be to represent a pin with a simple capsule. You add all your pins and than freeze them. So they dont fall. If the ball hits them they get automatically activated.
Coordinator
Jan 26, 2008 at 10:54 PM
- The current demo has a bowling sample.
Jan 27, 2008 at 4:26 PM
I loved the bowling pin sample in the latest demo. After a little bit more digging and experimenting, I found that my biggest problem was that my pin model's base was at (0, 0, 0), as opposed to the center. When I centered the pin model itself, the "weeble effect" went away. That being said, the the best effect I got was from just using a tall box for the pin, with a slightly shorter capsule wrapped around it to give it the rolling effect (the pins in my game are on a slight incline, so I had to be play with things a little.)

Thanks again for all your help and for such a fast response. I'm sure I'll be in touch again soon!