1
\$\begingroup\$

I am programming a simple pool game in XNA. I am using Farseer for simple 2d physics but I want to use 3d graphics. My problem is I can't get the rendering to work.

I have one model for the ball and one for the table, both exported from Cinema 4D into .fbx. I am able to load them and even display them, but not on the correct position. Farseer is using standart coordinate system (X+ to the right, Y+ down) and I need to somehow convert the position from farseer and display the models on the right place on the screen and with the correct size (this should be easy to achieve using scale matrix).

I need help finding what my projection, view, and world matrices I should use?

\$\endgroup\$
  • \$\begingroup\$ Farseer is just a 2D Physics-Engine. If you're trying to add physics to those models, you'll need something like BEPUPhsyics \$\endgroup\$ – IMX May 6 '13 at 18:38
  • \$\begingroup\$ I know this, but I am making just a pool game which needs no depth, just 2D physics. However, I am using 3D models instead of just simple sprites for the graphics. \$\endgroup\$ – user30395 May 6 '13 at 20:34
0
\$\begingroup\$

You may want to consider turning on DEBUG VIEW in farseer, if you haven't already done so. I also had a difficult time lining up my Farseer objects with my 2D world objects. The following is the code I used to get the objects to line up:

Matrix proj = Matrix.CreateOrthographicOffCenter(0f, Viewport.Width, Viewport.Height, 0f, 0f, 1f);
Matrix view2 = Matrix.CreateScale(32);
view2 *= view;
_worldDebug.RenderDebugData(ref proj, ref view2);

The "view" above, is the matrix used when drawing everything else.

I suspect this may help solve your issue, it would most likely be a matter of adjusting the Scale matrix.

\$\endgroup\$
  • \$\begingroup\$ Thanks for answer, it seems like my models are displayed on the correct position. Part of the tables texture disappeared (it was there when I rendered it with perspective projection) though, but I am going to remake the models later anyway. \$\endgroup\$ – user30395 May 6 '13 at 16:14

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.