(This is going to be a little bit of a broad explanation for other people who might be reading this later, I just wanted to get it all in one spot)
In the beginning, it's good to remember that the physics has no concept of rendering. It just spits out data which some other systems will presumably make use of. Additionally, at the low level, rendering has no concept of physics.
Once the physics is updating each frame, the data it spits out (positions, orientations) will change. A graphical model is just a bunch of vertices floating out in space that doesn't care about the physics, and so you need to tell it specifically where to go to match up with the physics.
In XNA, the BasicEffect class (which is available through the Model when you're doing the rendering) has a World transform that can be set. There's nothing super special about the BasicEffect or Model class; XNA just provides them to help with setting up some basic scenes without having to write your own version of a Model class or shader.
When you set the World transform, it will render the model at that position. The simple DisplayModel class contained in the BEPUphysicsDemos updates the BasicEffect World transform each frame according to an entity's state (such as entity.worldTransform).
After you are updating the graphical world transform each frame according to the physics, you may notice that the graphics still don't quite match the physics. This is particularly noticeable if you make a graphical model that's offset from the origin; if you draw that model according to just an entity's world transform, the position of the model will be offset from the entity by the same amount it was offset from the origin.
To address this, you can move it around in the model editor, offset it in the content pipeline, or take the offset into account when setting the Effect's world transform. If the model is 5 units above the origin, you could use a matrix that translates it down 5 units before multiplying by the entity's world transform. For example:
Code: Select all
worldTransformToUse = Matrix.CreateTranslation(new Vector3(0,-5,0)) * entity.worldTransform;