**RE: coordinate-handedness confusion**

2021-09-05, 17:24 (This post was last modified: 2021-09-05, 17:36 by Roland Melkert.

*Edit Reason: Editor keeps messing with extra line breaks.*)

I've been playing around in Unreal Engine using your project and managed to get it to convert correctly (I think).

The problem is the very confusing UE4 coordinate system, it claims to be left handed using Y pointing towards the user, Z up and X to the right.

BUT then it goes on about X is front, Y is right and Z is Up.

Yes it's still left handed but why not use this orientation every where?

The solution was partially in the existing unused "ldrRotator" function (where did that come from it seems to be part of an existing ldraw importer.).

So first step is to convert LDraw positional data into this system.

You could do this by rotating and mirroring, but it is easier to just 'map' the axis'.

I made this macro for it.

That's the xyz done, but the orientation part of the LDraw data needs a conversion too.

The a-i values on a LDraw type 1 line represent the rows of the orientation matrix, but UE4 "setRelativeLocationAndRotation" wants abs space vectors. So we must be sure to use the columns of the matrix as a starting point.

The xyz of each column needs to go JUST trough the coordinate shuffle.

I'm not entirely sure why it doesn't need the sign flips, but I think it has to do with the orientation being relative to the current world space (which is visually the same as in e.g. my LDCad editor).

So I only did the xyz shuffle here, using this macro:

There is one last pitfall, the new 'front' orientation doesn't match with the loose bricks assets you used in the project, so we need to correct those by applying a 'rest orientation' before applying the LDraw orientation.

Then we pull it all together in the main blueprint, like so:

Which renders like:

I added a concave slope to make it more obvious 'up' is translated correctly.

The problem is the very confusing UE4 coordinate system, it claims to be left handed using Y pointing towards the user, Z up and X to the right.

BUT then it goes on about X is front, Y is right and Z is Up.

Yes it's still left handed but why not use this orientation every where?

The solution was partially in the existing unused "ldrRotator" function (where did that come from it seems to be part of an existing ldraw importer.).

So first step is to convert LDraw positional data into this system.

You could do this by rotating and mirroring, but it is easier to just 'map' the axis'.

I made this macro for it.

That's the xyz done, but the orientation part of the LDraw data needs a conversion too.

The a-i values on a LDraw type 1 line represent the rows of the orientation matrix, but UE4 "setRelativeLocationAndRotation" wants abs space vectors. So we must be sure to use the columns of the matrix as a starting point.

The xyz of each column needs to go JUST trough the coordinate shuffle.

I'm not entirely sure why it doesn't need the sign flips, but I think it has to do with the orientation being relative to the current world space (which is visually the same as in e.g. my LDCad editor).

So I only did the xyz shuffle here, using this macro:

There is one last pitfall, the new 'front' orientation doesn't match with the loose bricks assets you used in the project, so we need to correct those by applying a 'rest orientation' before applying the LDraw orientation.

Then we pull it all together in the main blueprint, like so:

Which renders like:

I added a concave slope to make it more obvious 'up' is translated correctly.