[SOLVED!] coordinate-handedness confusion


RE: coordinate-handedness confusion
#8
(2021-08-31, 18:11)Roland Melkert Wrote: To go from right handed (LDraw) to left handed (UE4) you need only to flip one axis, I think flipping the Z one is best.

But you need to do that after the whole model is loaded and assembled/flattened into a mesh.

After the z flip you need to do an additional rotation to compensate for the LDraw neg Y up and Unreal's weird z is up orientation.

But the z flip alone should give you a clean model, it will just sit on its side or something without the additional rotation.

Even without the z flip it should be a solid model it will only be mirrored.

Thank you for all the help so far!

I've tried just passing the rotation and location coords straight in to setting the location and rotation of each brick, but the model it produces is still garbled beyond simply needing rotated/flipped at the end.

The ldr file I'm using for importing:
Code:
0 Untitled Model
0 Name:  UntitledModel
0 Author: 
0 CustomBrick
1 15 0.000000 -24.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 3003.dat
1 15 40.000000 -24.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 3003.dat
1 15 80.000000 -24.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 3003.dat
1 15 120.000000 -24.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 3003.dat
1 15 160.000000 -24.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 3003.dat
1 15 120.000000 -24.000000 -40.000000 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 3003.dat
1 15 80.000000 -24.000000 -80.000000 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 3003.dat
1 15 0.000000 -24.000000 90.000000 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 3039.dat
1 15 30.000000 -24.000000 80.000000 0.000000 0.000000 -1.000000 0.000000 1.000000 0.000000 1.000000 0.000000 0.000000 3039.dat
1 15 80.000010 -30.000010 70.000000 1.000000 0.000000 0.000000 0.000000 0.000000 -1.000000 0.000000 1.000000 0.000000 3039.dat
1 15 110.000000 -20.000000 70.000000 0.000000 0.000000 -1.000000 -1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 3039.dat
Image of the stud.io file I generated the ldr from: https://i.imgur.com/3L3CUqW.png
Actual stud.io file I'm using, in case there's something hinky going on with Stud.IO's ldr exporter: https://drive.google.com/file/d/1xGRxNRW...sp=sharing
The results in UE4: https://i.imgur.com/242mQB0.png
Quote:So the most important thing is to make sure you assemble the LDraw data correctly, before worrying about the coordinate system.

I'm pretty confident I'm parsing the ldr lines correctly, but I'll post my node setup and explanation, as well as a preview of the output of the first line of the above ldr here as well.

Step 1: https://i.imgur.com/0UoYYXl.png
The ldr string is parsed into an array ArtificalBrickArray01, delimiting each array entry by the newline character, i.e. each entry in the array should be one line of ldr file. The commented section removes the first four lines, 0 through 3, and stores them in it's own array SetInfo, so that ArtificialBrickArray01 is just brick color/location/rotation/brickID info.

Step 2: https://i.imgur.com/vrzfOsf.png
BrickSet is an array of a custom data structure called ldrLine that follows the line type 1 format: https://i.imgur.com/QlmJMlm.png 'file' is for 'brickID'.
Step 2 loops through ArtificialBrickArray and turns each line into it's own array delimitied by a space, ' '. Each array then has each element stored into it's appropriate spot in an ldrLine structure, and has that ldrLine structure added to the end of an array 'BrickSet', resulting in an array of ldr data that can be easily broken into it's base components.  The function that does this is pretty straightforaward: https://i.imgur.com/CUijzd9.png

Step 3: https://i.imgur.com/j5c14Ot.png
The rest of the code has already been shown. From here the array of ldrLines is iterated through, each line is broken, and sorted into it's component vectors for location, and each axis of the rotator. The code in the upper right simply uses the brickID to locate a mesh in a directory, then adds that component to the blueprintInstance, scales it, and then moves on to the brick placement, which I've shown before but will show again for completion's sake.

Step 4: https://i.imgur.com/QL3xtVl.png
Pretty straight forward. I am just plugging the Location(here poorly named 'Position') into UE4's built-in SetRelativeLocationAndRotation, using the built-in Make Rotator to make a UE4 rotator out of the ldraw rotation axis.

A line from the array of ldrLines: https://i.imgur.com/hm1SI3q.png
As far as I can tell this, and every element of the array, lines up perfectly with the lines of code in the ldr file.


And finally, the actual project zipped and uploaded to gDrive: https://drive.google.com/file/d/1zq24FAv...sp=sharing
I'm not sure if asking to look at the UE4 project is in bad-taste or not when asking for help, but I'm at the end of my ability with this project.
Reply
« Next Oldest | Next Newest »



Messages In This Thread
RE: coordinate-handedness confusion - by KristyB - 2021-09-01, 9:43

Forum Jump:


Users browsing this thread: 2 Guest(s)