Changing coordinate system

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
wishmaster
Posts: 3
Joined: Sun Sep 29, 2013 2:59 am

Changing coordinate system

Post by wishmaster »

Irrlicht is left-handed and Y up. I prefer right-handed and Z up, an point is that the rotation looks better for me.

There is a way of changing the coordinate system of the whole engine without changing the engine?
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: Changing coordinate system

Post by Cube_ »

um...I the right/left handedness of the system doesn't affect the rotation in any way except what name each axis has, for all the computer cares you could call the axes potato1, potato2 and potato3, it wouldn't make a difference.

If it's a matter of preference I'd say the easiest way is to write a wrapper function that essentially renames the axes.
"this is not the bottleneck you are looking for"
wishmaster
Posts: 3
Joined: Sun Sep 29, 2013 2:59 am

Re: Changing coordinate system

Post by wishmaster »

aaammmsterdddam wrote:um...I the right/left handedness of the system doesn't affect the rotation in any way except what name each axis has, for all the computer cares you could call the axes potato1, potato2 and potato3, it wouldn't make a difference.
I know that axis names are an human convention, but from what I know if you change the handness and use exactly the same rotation algorithm, clockwise rotation will become counter clockwise and vice-vera.
aaammmsterdddam wrote: If it's a matter of preference I'd say the easiest way is to write a wrapper function that essentially renames the axes.
I do it now. But I prefer changing the orientation of the whole engine, I think that this will be more practical and efficient than converting all the time. Another thing to consider is that Irrlicht rotate X and then Y and then Z, this is right for me if Z is up.
Brainsaw
Posts: 1183
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Re: Changing coordinate system

Post by Brainsaw »

You can convert the coordinate system to right handed with this:

Code: Select all

 
      // Switch rendering to right-handed
      irr::core::CMatrix4<irr::f32> l_cMatrix  = m_pCam->getProjectionMatrix(),
                                    l_cMultipy;
 
      l_cMultipy.setScale(irr::core::vector3df(1.0f, 1.0f, -1.0f));
      l_cMatrix *= l_cMultipy;
      m_pCam->setProjectionMatrix(l_cMatrix);
 
It's part of the camera, so you need to do this for every camera you use. You also need to switch all materials from backface to frontface culling. You can check my "Sky of Verdun" project in the project announcements forum where this code comes from. This project is a port of a WebGL game client that was supposed to look the same as native client, and WebGL (like OpenGL) is right handed.

For the Z-Up: You just need to modify the target and the up-vector in the way you like it (and have the appropriate models of course), then it should be no problem. It might need some more changes if you use Irrlicht's FPS camera.
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
Post Reply