Cannot get a box to fall

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Sabo
Posts: 4
Joined: Sat May 14, 2011 3:17 am

Cannot get a box to fall

Post by Sabo »

Just getting started with BEPU. On a deadline, and BEPU seems to be a solid solution. I have two questions (for now, pretty sure more will follow).

1: I've created a space and set the gravity. Also created a Box and added it together with a XNA Model to a DynamicModel class I created. Finally add the box to the space.

Code: Select all

Space space = new Space();
space.ForceUpdater.Gravity = new Vector(0, -9.82f, 0);

Box box = new Box(new Vector3(85, 10, 0), 5, 3, 10, 10);
cube = new DynamicModel(content.Load<Model>(@"cube"), new Vector3(85, 10, 0), box);
space.Add(cube);
I call space.Update() in one of my update methods. So why isn't this box of mine falling. Or is it, just that the model isn't moving?

2: How are the entites linked to models? I haven't been able to figure that out from the samples. It may be that the answer to this question is also an answer to the first question.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Cannot get a box to fall

Post by Norbo »

To verify that it is indeed just a graphical issue, you can check the entity's position and other properties to see if it's moving as expected after updates.

The easiest/most direct way to control graphics with the physics is to use the entity's WorldTransform property. It contains the position and orientation in a 4x4 XNA matrix, so it's easy to transform a model with it. The BasicSetupDemo/GettingStartedDemo shows a simple approach: http://bepuphysics.codeplex.com/wikipag ... umentation
Sabo
Posts: 4
Joined: Sat May 14, 2011 3:17 am

Re: Cannot get a box to fall

Post by Sabo »

Thanks for a quick reply. The box does indeed fall according to the numbers. And I just found out why it didn't "move the box". And yes, it is related to "how the entity and the model are connected".

This little line right here, "Matrix worldMatrix = Transform * entity.WorldTransform;" is the answer I was looking for. I sure feel like a newbie right now. That's what I guess for taking long breaks from coding. :)
Post Reply