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

Why the decision to use Meters?

Topics: Developer Forum
Feb 5, 2007 at 9:29 PM
I am just wondering why the decision to implement the Convert.cs file in the FarseerXNAGame project, specifically the Pixel to Meter conversions. It seems to me to be a needless, and unnecessary addition. If you want your objects to react or fall quicker etc, why not just increase there properties values? Why add additional code that ultimately results is slower less efficient, and more cumbersome code? I would really like a response to this inquiry as I am planning on using Farseer in a game engine I am currently developing.
Feb 6, 2007 at 1:01 PM
Edited Feb 6, 2007 at 1:38 PM
Keeping things in meters keeps me from using unrealistic values. The physics engine knows nothing about units, only in my game engine(FarseerXNAGame) did I decide to use "meters". Also, I'm not really using true "meters" The convert class just sets up a conversion between pixel and some other unit. I just decieded to call that unit meters because it's easy for me to think in meters. If, in my game I want a crate, I don't want to think about how many pixels wide/high my crate is. I want to think of it and define it in terms of meters. Also, it is much eaier to estimate a proper mass when defining things in units of "meters". I know about how much a 1x1 meter crate would weigh, but I have no idea what a 50X50 pixel crate would weigh.

Same with applying forces like gravity. If I define my whole world in terms of meters, I can use real world gravitation values and my forces are not as arbitrary.

Also when you create your geometries and other physical obejects using pixel values, it's very easy for the numbers to become too large.(Especially when using springs and joints) Keeping numbers smaller in the physics engine (ie. closer to 1)increases accuracy. (Newton Physics Engine is the same way if you read their docs)

Again, to your point. The physics engine itself knows nothing about units. The FarseerXNAGame(graphics engine) is my own little wrapper that I will be using for a game. It was/is not designed to be a genaral purpose game layer for a mass audience. You could pretty easily create your own game engine on top of the farseer physics engine that did not do conversion from pixels.

Hope this clears things up.
Feb 7, 2007 at 7:56 PM
Thanks for the insight!