By default jmonkey use coordinate grid with Y-Axis points to upwards.

How use Z-Axis points upwards grid like in CryEngine?

By default jmonkey use coordinate grid with Y-Axis points to upwards.

How use Z-Axis points upwards grid like in CryEngine?

1 Like

Why does it matter?

If you really want Z to be vertical, then rotate everything in your game to be such that Z is vertical.

By default, there will never be a way to change the coordinate system to make Z vertical as the Y being vertical is a function of OpenGL. As far as I know, Vulkan is the only renderer with Z as vertical. At the moment jme does not support Vulkan. There are some things that can be done at the shader level to facilitate the different coordinate system, but this would require large changes the the core jme shaders.

There is almost no reason anyone would want to change the coordinate system. They are functionally identical except for which axis is labeled X, Y, or Z.

I am trying to create some scenes from very-very old game. I have all need data, and objects in this game use the rotation matrix data. Since Z is the up, my models do not look right. I find it difficult to adapt the rotation matrix

1 Like

From hard-learned experienceâ€¦ (Original Mythruna is written z-up)

JME treats Z as the â€ślook directionâ€ť and generally Y as up. But itâ€™s the â€śZ is look directionâ€ť that will kill you with rotations, etcâ€¦

If you do not find a way to convert to Y-up when loading/converting your models, you will fight with this every day of development on your project. Some significant number of strange bugs will always trace back to a place where y-up and z-up are fighting again.

I did Z-up on the original Mythruna engine and fought with it all the time for two years. The new Mythruna engine is y-up like JMEâ€¦ when Iâ€™m converting code from the old engine, I still find Z-up bugs that hadnâ€™t been discovered yet.

We might be able to help you fix the matrix/rotations/etc. but we would need to know more about them, what youâ€™ve tried, and what goes wrong.

1 Like

To properly orient a Z-up, X-forward model in a Y-up, Z-forward world, one should first rotate it by -pi/2 radians around its +Z axis, then rotate it by -pi/2 radians around its +Y axis. In other words:

```
model.rotate(0f, 0f, -FastMath.HALF_PI);
model.rotate(0f, -FastMath.HALF_PI, 0f);
```

2 Likes

thanks for your help!

I have Matrix 34

If I understand correctly, this is a rotation and position matrix.

{-0.31146958, 1.0862259, 0.0

-1.0862259, -0.31146958, 0.0

0.0, 0.0, 1.13

1195.3457, 1868.0154, 246.44078}

How can I convert it for jme sdk?

It looks like that matrix has scale, tooâ€¦ by the way.

For me is easier to think Z-up so I have simple util methods to convert between game logic and jme/opengl.

Vectors (game to opengl):

```
X'=-X ; Y'=Z ; Z'=Y
```

Rotations (game to opengl):

```
X'=-X ; Y'=Z ; Z'=Y ; W'=W
```

As long as I keep well defined boundaries between the game logic and the scene, I just need to convert in a few places. I have had less bugs since I started doing it like this.

1 Like

Yes, i read about this, but I cannot apply it to my data.

CryEngine.Matrix3x4.Matrix3x4 (Vector3 scale,

Quaternion rotation,

Vector3 position)

{-0.31146958, 1.0862259, 0.0

-1.0862259, -0.31146958, 0.0

0.0, 0.0, 1.13

position thatâ€™s iâ€™am sure â†’ x = 1195.3457, y = 1868.0154, z = 246.44078}

what then is the scale and rotation i canâ€™t understand?

I donâ€™t know if they are row major or column majorâ€¦ but that 3x3 top section is the rotation and scale matrix.

If itâ€™s row major then each row is one of the orthogonal coordinate axes. If itâ€™s column major then each column is one of the orthogonal coordinate axes. Once you know this you can reverse engineer the scale by taking the length of these vectors.

â€¦it looks like the scale of that matrix is at least 1.13 no matter which way. Since in either row major or column major, the z axis is the same: 0, 0, 1.13

You will also need to worry about the handeness of the system, ie: which way the Z axis (or y axis) points relative to x. (y axis into the screen or out of the screen if x,z is right/up.)

1 Like