[SOLVED!] coordinate-handedness confusion


RE: coordinate-handedness confusion
#12
(2021-09-05, 17:24)Roland Melkert Wrote: 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.

Ahaha this is awesome, thank you so much! I can't wait to get this set up on my end.

Quote: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.
I think this has been part of my stumbling block. Could you link me to where you found this info, if it's still handy? All I could ever find about UE4's coordinate system was that it was left-handed, but used some right-handed import for fbx files 'for 3DS Max compatibility'.


Quote:"ldrRotator" function (where did that come from it seems to be part of an existing ldraw importer.).

That was a function I created. I disconnected it at some point, but left it in-tact in case I needed to return to it; the blueprint equivalent of just commenting out code. I'm glad I left it around if it helped.
Reply
« Next Oldest | Next Newest »



Messages In This Thread
RE: coordinate-handedness confusion - by KristyB - 2021-09-06, 16:20

Forum Jump:


Users browsing this thread: 1 Guest(s)