Here’s a little rant on left vs right handed coordinate systems.
Survivalcraft up to version 1.27 used XNA as rendering engine. If you ever did any 3D coding you probably know that XNA is hardcoded to use a right-handed coordinate system. All my previous 3D experience was with left-handed systems.
Here’s what I am talking about:
Notice how you can get the second right-handed system by rotating the first one by 180° around Y axis. They are the same systems really. You can never get a left-handed system from right-handed by rotations only. You need to flip it. That’s why there are two kinds of coordinate systems in 3D.
I thought (as most people do) that it’s purely a matter of convention and you can get used to one or the other. But after over 4 years of work on Survivalcraft, which uses right-handed coords I figured I am not and will probably never be comfortable with right-handed coordinate systems. They are counter-intuitive to me.
Here’s why, axis by axis.
Up/Down Axis (often called Y, sometimes Z):
This is the simplest one. Increasing values should go up. No questions. It’s dictated by gravity we are all used to. It would be like having an altimeter in an aircraft that shows smaller values the higher you go. Imagine being a pilot trying to get your head around it.
Near/Far Axis (often called Z, sometimes Y):
Increasing values should go far. This is less obvious, but I think most people would agree that the further something is, the bigger the coordinate value should be. It’s like a distance. The other way has an issue if the observer is at the center of the coordinate system (a very common case): you must use negative values for something that is in front of you. No doubt it is more intuitive to have negative values for something that is behind, not in front!
Left/Right Axis (pretty much always called X)
Increasing values should go right. This is the least obvious axis. The preference for right direction comes from western culture of writing. Of course there are other methods of writing that go the other way, mostly originating in Far East. But there is no doubt that when you are a programmer (Chinese, Korean, American, it does not matter) and are looking at a computer screen, you know that horizontal zero coordinate is at the left side of the screen, and increasing the coordinate will move it right. It is a convention ingrained over decades. TVs scan left to right. Even oscilloscopes scan from left to right.
Now where does this leave us? If we adopt the most intuitive axis directions as described above, we get this coordinate system:
And it is left handed. Left handed FTW!
Finally comes the biggest disadvantage of right-handed systems. If for some reason you think that right handed system is good for you, it’s not obvious which one (assuming we keep the Y axis pointing up):
Either you flip X or Z axis.
Furthermore, once you convert your right-handed coordinates to screen space, you are back at left handed system. Therefore, you need to constantly switch between left and right handedness depending with which space you are working with. Confusion!
To me, it’s a nightmare. I cannot reason in a right-handed system. I cannot visualise anything in my head. I have to draw it and mark the axes directions first. It’s much slower than having it all in my mind.
Since version 1.27, Survivalcraft uses a custom engine for rendering. When working on it I did not switch the coordinate system from XNA right-handed one. I had enough other issues to worry about :-) So sadly the game still uses a right-handed coordinate system. And don’t ask me which one, I am so confused I don’t know myself! It’s probably different systems in world space, different in view space and different still in screen space…
But one day I think I will switch the entire engine and the game to left-handed where there’s only one obvious way!
Btw. This rant is purely subjective and not entirely unbiased. For example a lot of 3D modelling programs (and top-down view games) use Z as up-down axis. The above reasoning does not apply to them.