Jan 14, 2011 at 1:22 AM
Edited Jan 18, 2011 at 12:01 AM

How do you draw?

Jan 14, 2011 at 3:19 AM
DualOpAmp wrote:

So, in order to draw a debug view of the bodies, I have to bring in DebugViewXNA.dll, extend that abstract class (or bring in the one from your samples), and then call the .renderDebugData.  While passing in the farseerphysics camera2D, (which I have to bring in from your samples too.)  Am I right?

No. If you don't need scrolling you can just pass Matrix.Identity. There is no such thing as a Farseer physics camera. We provide a sample implementation of a camera for those who need scrolling, zooming, ect. but the DebugView just expects a view matrix, which can be created in various ways. Have a look at the newest HelloWorld XNA sample. It demonstrates drawing the DebugView aligned to a spritebatch without using Camera2D. It won't get much easier than that.

Also you can extend an abstract class as much as you want... you won't be able to create an instance of an abstract class no matter what. You could inherit from it and write your own DebugView, but I don't see any reason to do that. The DebugView is completely independent from the samples and has nothing to do with them... it is just used within the samples.

Jan 14, 2011 at 4:09 AM
Edited Jan 17, 2011 at 11:59 PM


Jan 17, 2011 at 2:24 AM

I still don't get this.  I passed in matrix.identity to the DebugViewXna, and I still didn't get any fixtures drawn.

Jan 17, 2011 at 3:49 AM

Okay, so I'm looking at the Simple Samples and I notice the constant 50 when rendering.  What's this for?  I look at the camera class, and -25 and 25 is used.  50 again?


What's with 50?

Jan 17, 2011 at 8:54 AM
Edited Jan 17, 2011 at 8:55 AM

That is an orthographic projection. It creates a custom coordinate system within the range from -25 to 25. This has the advantage of being resolution independent so that the same samples can be used on WP7 and Xbox for example. Simple samples drawing is a bit more elaborate than using spritebatch and out of scope of the engine or this discussion board really.

As stated before: For a simple drawing example using spritebatch have a look at HelloWorld XNA here: http://farseerphysics.codeplex.com/SourceControl/changeset/view/83475# (not the one from the "Downloads" tab)

It is located under: Samples\HelloWorldXNA and game1.cs contains everything you need to setup and align spritebatch drawing and the DebugView.

Use the simple samples as a reference on how to setup the physics stuff that is what they are there for. For 3.3 we'll probably switch to a "less confusing" way of drawing things. 

If you still have questions on how to use matrices and setup projections etc. I'd suggest you take a short trip to the App Hub. You can find tons of tutorials and threads with graphics related questions there.

Jan 17, 2011 at 2:13 PM
Edited Jan 17, 2011 at 11:58 PM

...  Congrats on the Hello World example.