This project has moved and is read-only. For the latest updates, please go here.

FP3 Debug view Reversed?

Topics: User Forum
Sep 24, 2010 at 4:33 PM

I'm working with XNA and Farseer 3.0. using the "Hello World example I was able to sucessfuly add the debug view to my project. however, I am seeing several things that seem funky to me.

First of all, why is the Y value for the gravity vector in the world a negative number as opposed to the positive number used in FP2?

I also had to reverse the direction that I applied torque to make an object rotate the right direction, is that what should be happening?

So I figured that was all weird, but i could deal with it. So I uncommeneted my objects that worked predictably in FP2 and they were HUGE compared to the Hello World objects. so my friend suggested changing the line:

Matrix proj = Matrix.CreateOrthographic(50 * _graphics.GraphicsDevice.Viewport.AspectRatio, 50, 0, 1);

to this:

Matrix proj = Matrix.CreateOrthographic(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 1);

Which made all MY objects seem the correct size. but the Hello world objects were TINY. and my objects still behave as if they are MASSIVELY Huge. (ie, it takes very high Torque to make them rotate/move.)

I thought that was rather odd, but I continued by adding the image for a circle that I was using in my project that used FP2. The image was the same size as the circle being drawn by the DebugView. but it was reversed in every conceivable way. the rotation was backwards, it falls up, etc.


If anyone has any insight into why this is happening you will make me a very happy man.

Sep 24, 2010 at 8:23 PM
Edited Sep 24, 2010 at 8:23 PM

When it comes to the object size stuff, version 3 of FP no longer uses pixels for objects, but meters. So you need to convert between graphics units and physics units. For example, you could make sure you always divide height and width values by 100. Also, try to keep the object sizes between 0.1 and 10 meters for good performance.

When it comes to the rotation stuff, I have no idea. For me it worked the same way in FP3 as in FP2. :)

Sep 24, 2010 at 10:03 PM
Edited Sep 24, 2010 at 10:31 PM

I've been working on a project that recently started using FP3 and we had the same issue with the debug draw.  I figured out it was because the debug drawing was using a 3D cooridnate system where center screen is 0, 0 and y+ goes up while XNA has 0,0 in top left and y+ goes down. 

To fix that I just added the transforms into the view when passing to the draw call.  Our call looks like this:

this.debugView.RenderDebugValue(Camera.ProjectionMatrix, Camera.ViewMatrix * Matrix.CreateRotationX(MathHelper.Pi) * Matrix.CreateTranslation(new Vector3(-Engine.GraphicsDevice.Viewport.Width / 2, Engine.GraphicsDevice.ViewPort.Height / 2, 0)) * Camera.TransformMatrix(scrollRateX, -scrollRateY));  

That puts everything in the right place for us. Hope it helps you too.