LDraw.org Discussion Forums
Questions about license and conversion of rotation matrix - Printable Version

+- LDraw.org Discussion Forums (https://forums.ldraw.org)
+-- Forum: General (https://forums.ldraw.org/forum-12.html)
+--- Forum: Help (https://forums.ldraw.org/forum-13.html)
+--- Thread: Questions about license and conversion of rotation matrix (/thread-16404.html)



Questions about license and conversion of rotation matrix - Matthias Deinert - 2015-05-13

Hello everyone!

Are you allowed to create a software application that uses the LDR file format (the sets, not the parts) without asking or do I have to register my software somewhere? Because I am working on a game in which you build official and custom sets from the point of view of a minifig and it uses the LDR format to place all the bricks at the right position and players can import their own LDR files as long as they only use the parts that I have modeled for the game (it doesn't use any LDraw parts).

My second question is related to the first as I have a problem with the game. To be more precise, I have trouble converting the LDraw coordinate system to the game engine's system (Unreal Engine 4):
   

In the engine's visual scripting component I hooked up the values like this:
   

On the left you see the index of a line that starts with "1" and all the green 1s in the center column of the image can either be 1 or -1. I would have done it the brute force method and try all combinations but there are 1024 of them which would take too long. Most parts are placed correctly, it's just the angled pieces such as these flowers:
   

They are correctly placed inside the LDR file as well as in my modeling software. If someone with a sharper mind than mine could tell me which values I have to change to convert the axes correctly, I'd be very grateful.

Thank you in advance!

PS: I hope this is the right place for this question.


Re: Questions about license and conversion of rotation matrix - Willy Tschager - 2015-05-13

Matthias Deinert Wrote:Hello everyone!

Are you allowed to create a software application that uses the LDR file format (the sets, not the parts) without asking or do I have to register my software somewhere? Because I am working on a game in which you build official and custom sets from the point of view of a minifig and it uses the LDR format to place all the bricks at the right position and players can import their own LDR files as long as they only use the parts that I have modeled for the game (it doesn't use any LDraw parts).

Short answer, yes. The licence stuff can be found here:

http://www.ldraw.org/article/227.html

while LDraw.org policies and procedures are here:

http://www.ldraw.org/article/281.html

w.


Re: Questions about license and conversion of rotation matrix - Travis Cobbs - 2015-05-13

I can't specifically answer your coordinate question, but I'm pretty sure that LDraw uses a left-handed coordinate system, with "up" being along the -Y axis in that system. OpenGL and Direct3D use a right-handed coordinate system, and "up" is usually along the +Z axis, although that's up to you.


Re: Questions about license and conversion of rotation matrix - Matthias Deinert - 2015-05-14

Willy Tschager Wrote:Short answer, yes.
Thanks for linking the articles. Unfortunatey I cannot access them right now (too many connections). By "yes" do you mean yes to using it without asking or yes to registering my software?


Re: Questions about license and conversion of rotation matrix - Matthias Deinert - 2015-05-14

I googled "left handed to right handed coordinate conversion" and found some useful answers but I'm afraid it's too complicated for me.


Re: Questions about license and conversion of rotation matrix - Willy Tschager - 2015-05-14

Yes means using without registration ... but:

You are free:
* to copy - distribute, display, and use the CA approved LDraw Parts Library
* to make derivative works
* to make commercial use of the CA approved LDraw Parts Library

Under the following conditions:
Attribution - You must give the original author credit.
The LDraw Steering Committee (SteerCo) also holds an attribution to 'The LDraw Parts Library' in such Derivative Works to be sufficient in lieu of a full list of authors.
For any reuse or distribution, you must make clear to others the licence terms of this library.
Any of these conditions can be waived if you get permission from the copyright holder.
Your fair use and other rights are in no way affected by the above.

Hope this helps,

w.


Re: Questions about license and conversion of rotation matrix - Matthias Deinert - 2015-05-14

This really helps. Thank you!


Re: Questions about license and conversion of rotation matrix - Travis Cobbs - 2015-05-14

I would try setting each of the 1s in fields 5 through 13 to -1, one at a time. It's possible that only one of them needs to be negative, and that's a short enough list to try. Also, if I had to guess, I would guess that either field 9 or 12 is the one that needs to be -1.


Re: Questions about license and conversion of rotation matrix - Matthias Deinert - 2015-05-14

I tried to set each one to -1 one after the other. But it only made it worse in some cases. Since I can't release it in this state, I will probably try to create a function which will automatically go through each of the 1024 combinations and I pause it when everything is right.


Re: Questions about license and conversion of rotation matrix - Roland Melkert - 2015-05-14

If i understand the problem correctly I think you need a 90 deg (clockwise) rotation around X and a mirror on Y

1 0 0 0 0 -1 0 -1 0


Re: Questions about license and conversion of rotation matrix - Matthias Deinert - 2015-05-14

I tried that but zeros would neglect the information from the file. The 5, 6, 7, 8, 9 ... are equal to a, b, c, d, e ... in this article: http://www.ldraw.org/article/218.html#lt1

Since I tried most combinations and I didn't get satisfying results, I think I have to start over at the point where I made the connections from the column with the 1s to the "Make Rotation from Axes"-node.


Re: Questions about license and conversion of rotation matrix - Roland Melkert - 2015-05-14

You need to multiply the two matrices.

1 0 0 0 0 -1 0 -1 0 will translate the LDraw orientation into your game engine's orientation. But it must be applied on top of the original type 1 line matrix.

I'm not families with the unreal 4 backend but I would be surprised if there isn't some matrix component block you connect the 'f' rotation block to.


Re: Questions about license and conversion of rotation matrix - Matthias Deinert - 2015-05-14

That sound like it makes more sense. My setup looks like this now: http://forums.ldraw.org/file.php/13/1613/Untitled-2.jpg

The result is the same. I played around with the most values but nothing looked right. Sad This is frustating but I really appreciate your help!


Re: Questions about license and conversion of rotation matrix - Roland Melkert - 2015-05-14

Isn't that ''combine rotations' block a matrix multiply function?

So maybe if you feed the custom vectors to a 2nd 'make rotation' block, remove the dot products and feed it directly to the 'b' input of 'combine rotations' block while the original ldraw values go to 'a' like before.


Re: Questions about license and conversion of rotation matrix - Matthias Deinert - 2015-05-14

It appears to do that. But even after playing around with the values again, the best result I could get is this:
   
The hinge pieces on the truck as well as the sign in the front are still wrong.

In another forum, someone wrote me the code for a "Make transform from matrix"-node but that didn't work any better.


Re: Questions about license and conversion of rotation matrix - Roland Melkert - 2015-05-14

Is that model a MPD ? if so you need to recursively multiply the type 1 line matrices.

You also need to combine the rotation and position vectors into one 4x4 matrix otherwise placement will go wrong sooner or later when working with mpd's (which seems to be the issue in your picture).


Re: Questions about license and conversion of rotation matrix - Matthias Deinert - 2015-05-15

So far I'm only using LDR files.


Re: Questions about license and conversion of rotation matrix - Roland Melkert - 2015-05-15

ldr files can hold multiple models too.

On second thought I think the thing going wrong in your above picture is the transformation to 'unreal space' is only applied on the rotation. You need to apply it to the full 4x4 (pos+ori) type 1 line matrix.


Re: Questions about license and conversion of rotation matrix - Matthias Deinert - 2015-05-17

The LDR files I use are as simple as can be - they only have lines that start with 1 and "0 Step"-lines. Everything else is ignored.

I tried doing what you said by additionally rotating the location vector with the rotation that comes from the

1 0 0
0 0 -1
0 -1 0

matrix but that didn't end well. I now used only two of the three axes (there are nodes for each combination of the X, Y and Z axes) and recieved a result that is fine for now (only flowers and the two-finger-hinge pieces from the previous pictures are wrong).

Again, thank you for your help! And thank you for your great LDCAD Software! Since I use it to create the LDR files for my game, I mentioned you on the credits page.


Re: Questions about license and conversion of rotation matrix - Matthias Deinert - 2015-05-17

I understand the license but I am not great at repeating what I have understood. Therefore I'd appreciate it if someone can give me a hint at what would be the optimal text for these two menus from the game:
   
^ This is the screen that appears for a few seconds when you start the game. I just placed that text about LDraw as a placeholder. I'm not sure what to put there because it's not the parts that I'm using, only the LDR format.

   
^ This is the menu that you can reach from the main menu.


Re: Questions about license and conversion of rotation matrix - Roland Melkert - 2015-05-17

Thanks,

I still think the 4x4 way is the way to go but not knowing the unreal specifics I can't be sure. The biggest pointer is the wrong position of the ramp parts. The reason they end up at the wrong place is because one of the world axis is mirrored (so 50 should become -50 etc)

if the mirroring is only done on the orientation it will look kinda ok except for parts which use the mirrored axis (after rotation in LDraw space) in their positional information those will end up at their original non mirrored location because the positional information wasn't (correctly) transformed.

Things go fine, most of the time, when you only do two axis' because those are the two non mirrored ones.


Re: Questions about license and conversion of rotation matrix - Willy Tschager - 2015-05-19

For the exact wording it would be good to know if you're using the library, build your own converting the library, used the file format,... In short in which way your prog is connected to LDraw.

w.