Need help swapping the Y axis with the Z axis.

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
windows_x_seven
Posts: 3
Joined: Fri Nov 16, 2018 4:24 am

Need help swapping the Y axis with the Z axis.

Post by windows_x_seven »

Hello there!

I'd like to request help on swapping the Y axis with the Z axis (Z as height).

I can't stand using Y as height, since I've been using Z for most of my coding now, it really bothers me to set something to the Y axis and then find it going up or down instead of sideways and then have to recompile with the vectors swapped.

Do I need to modify the engine itself or is there another way?

Thanks for the assistance.
oh god do I despise the y axis
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Re: Need help swapping the Y axis with the Z axis.

Post by devsh »

if you want to use right handed coordinate system its easy.

You just need to patch all of the cameras+CMatrix class to swap Y with Z.

Also make sure to change backface culling to front-face or change the order of triangle indices in all meshes.
CuteAlien
Admin
Posts: 9647
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Need help swapping the Y axis with the Z axis.

Post by CuteAlien »

You can set the up-vector of your camera to 0,0,1. Be aware as long as you don't change to right handed coordinate system (which I wouldn't recommend really...) it means y is coming towards you now (or x to the left).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
windows_x_seven
Posts: 3
Joined: Fri Nov 16, 2018 4:24 am

Re: Need help swapping the Y axis with the Z axis.

Post by windows_x_seven »

CuteAlien wrote:You can set the up-vector of your camera to 0,0,1. Be aware as long as you don't change to right handed coordinate system (which I wouldn't recommend really...) it means y is coming towards you now (or x to the left).
I'm currently using the FPS camera, and this produces a really weird movement when moving the mouse: the world flips midway when moving the mouse up or down, and moving it left or right makes a spiral-like motion (right spirals down, left spirals up).

The only code involving the camera is this:

Code: Select all

SKeyMap keyMap[4];
    keyMap[0].Action=EKA_MOVE_FORWARD;   keyMap[0].KeyCode=KEY_KEY_W;
    keyMap[1].Action=EKA_MOVE_BACKWARD;  keyMap[1].KeyCode=KEY_KEY_S;
    keyMap[2].Action=EKA_STRAFE_LEFT;    keyMap[2].KeyCode=KEY_KEY_A;
    keyMap[3].Action=EKA_STRAFE_RIGHT;   keyMap[3].KeyCode=KEY_KEY_D;
 
    ICameraSceneNode* camnode = smgr->addCameraSceneNodeFPS(0, 50, 0.7, -1, keyMap, 4, false, 3);
 
    camnode->setUpVector(core::vector3df(0, 0, 1));
oh god do I despise the y axis
CuteAlien
Admin
Posts: 9647
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Need help swapping the Y axis with the Z axis.

Post by CuteAlien »

I got an idea why, but will have to check. But yeah, could be some stuff does not work then as expected - Irrlicht really is coded to have Y up.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
CuteAlien
Admin
Posts: 9647
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Need help swapping the Y axis with the Z axis.

Post by CuteAlien »

Sorry, it won't work with FPS-Camera. You will have to write your own for that. Going against the defaults of a library is always hard...
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
windows_x_seven
Posts: 3
Joined: Fri Nov 16, 2018 4:24 am

Re: Need help swapping the Y axis with the Z axis.

Post by windows_x_seven »

CuteAlien wrote:Sorry, it won't work with FPS-Camera. You will have to write your own for that. Going against the defaults of a library is always hard...
Ok, thanks for the help!
oh god do I despise the y axis
Post Reply