DĂ©c 052013
 

Farseer has one specific not always easy to deal with : your world is meant in KMS (kilo meter second) whereas your rendering is in pixel.
Added to that, your world and rendering are two complete different things which does not make it easy to debug.

This where the DebugViewXNA class kicks in : it will render your world 🙂
This and a few other things like stats, datas, etc.

The how to use the DebugViewXNA class is rather easy :

add the project reference to debugview.xna.dll
add an imports to FarseerPhysics.DebugView
declare a _debugView As DebugViewXNA
set it up in loadcontent (for instance) :

_debugView = New DebugViewXNA(world)
_debugView.AppendFlags(DebugViewFlags.DebugPanel)
_debugView.DebugPanelPosition = New Vector2(15, 15)
_debugView.DefaultShapeColor = Color.White
_debugView.SleepingShapeColor = Color.LightGray
_debugView.LoadContent(GraphicsDevice, Content)

-use it in your draw method (after your spritebatch.end) :

Dim projection As Matrix = Matrix.CreateOrthographicOffCenter(0.0F, graphics.GraphicsDevice.Viewport.Width * DrawablePhysicsObject.pixelToUnit, graphics.GraphicsDevice.Viewport.Height * DrawablePhysicsObject.pixelToUnit, 0.0F, 0.0F, 1.0F)
_debugView.RenderDebugDataVB(projection)

A video to illustrate switching between rendering and debugging.

 Posted by at 22 h 35 min

Poster un Commentaire

avatar
  Subscribe  
Me notifier des