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

Purpose of MKS? and a way around it

May 27, 2011 at 7:21 AM

Finally after awhile figured out applying forces wasn't working because there was a unit change and now I must convert everything to something.

So I have a couple of questions.

What is the point in using these unknown size meters instead of pixels?

Is there a way to modify the engine to not use meters and go back to using pixels? (that way I wouldn't have to convert every single number I want to use)

My game is heavily based around the pixel and pixel accuracy(worked fine on the old version), if there is no way to convert it and I must waste the time and performance to convert every number what is exactly relative to one pixel?

May 27, 2011 at 3:49 PM

The only valid agrument one can make against the MKS system is that it really sould be MGS (Minutes-Grams-Seconds). 
Farseer is a physics engine and MKS comes natural.

On the other hand Pixels are not really a constant unit and comes into play only when you need to render the world.
In what scale you want to project your world into the screen is up to you.



Jun 1, 2011 at 3:02 AM

@TBbadmofo: MKS is used to increase the precision of the engine. The engine uses the type float and that type only has 32 bits of precision. By keeping items around 0.1 to 10 units (meters in Farseer 3.x) we allow the engine to use more bits for precision.

To allow Farseer 3.x to use pixels as units (highly unadvised) change Settings.MaxTranslation to something like 200+ and it should allow bodies to move in a normal manner. (untested)

A much better solution is to simply add a scaling constant, say 100 pixels per meter, and scale everything you draws position by this. Simple and easy and you get to keep the precision.

Some people don't like doing this because it can be hard to align the debug view with your shapes or vice-versa. The solution to this has been provided in other threads. (You search for them... I'm busy playing Terraria)

Also some people can't find the perfect meter size to represent their shape . The solution is to measure your shapes pixels, say a 100 pixel wide circle, and then divide by the pixels to meter constant. You will then have the perfect meter size of your shape.

I hope this helps you.


@nkast: I've never heard of MGS. Could you elaborate?

Jun 1, 2011 at 1:00 PM

MGS is the original metric system that uses grams as the mass unit.
I am not actually suggesting that farseer should be rewritten to MGS.

Just that it's be a valid debatable argument, while using 'pixels' is not even possible(!).

When  moving 'pixels' from an image into the physical world (ex. printing) we use DPI which is actually a scaling factor that says "how many cm is each pixel" (or maybe the other way around..). Similarly, in a physics engine we have to use a scaling factor to render an object into the screen.





Jun 3, 2011 at 8:49 AM

I understand it better now and see the importance of it, but its implementation doesn't seem great. Having to convert every vector for placement, convert the size of a physics object, and reconvert it back to draw it. I think I've figured out better ways of automatically doing this within the object's class, but it seems like farseer should have the same thing in creation of a physics object unless there is a purpose for it to not use mks.