3
\$\begingroup\$

I just want to be able to see all my bodies on the screen for debugging purposes and i cant think of an easy way, for example i have make some edge fixtures with curved arcs attached and i just want to see what they look like!

\$\endgroup\$
3
\$\begingroup\$

Farseer does ship a physics view, and thankfully it requires very little brain power to implement and use.

If you downloaded the "Farseer Physics Engine 3.3.1 Samples XNA" recommended package on their download page, you'd see a lot of examples included.

Navigate to (or click these convenient links to the codeplex page :P) SamplesXNA/SamplesXNA/ScreenSystem/PhysicsGameScreen.cs to see example usage of FarseerPhysics.DebugViews.DebugViewXNA.

It boils down to this:

FarseerPhysics.Dynamic.World myWorld;
// initialize myWorld...
var myDebugView = new FarseerPhysics.DebugViews.DebugViewXNA(myWorld);

And then you can set flags on it to determine what's visible:

myDebugView.RemoveFlags(DebugViewFlags.Shape);
myDebugView.RemoveFlags(DebugViewFlags.Joint);
myDebugView.DefaultShapeColor = Color.White;
myDebugView.SleepingShapeColor = Color.LightGray;
\$\endgroup\$
1
\$\begingroup\$

Farseer comes with a debugging environment. There's two ways of doing what you want to do. The first way is reproducing your situation in the test environment they ship. It will show everything of relevance. This is the technique I used for my game.

The other way is to integrate the debugging environment they made into your game, this is slightly more complex, and I haven't tried it yet, but if I understand correctly it should be possible, have a look around in the project and see what you can mix and match :)

Update: If it really is so simple as michael says then you should definitely do that, looks a lot better than what I did.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.