LDraw.org Discussion Forums
Subfile References and Scaling - Printable Version

+- LDraw.org Discussion Forums (https://forums.ldraw.org)
+-- Forum: LDraw Programs (https://forums.ldraw.org/forum-7.html)
+--- Forum: LDraw File Processing and Conversion (https://forums.ldraw.org/forum-22.html)
+--- Thread: Subfile References and Scaling (/thread-16700.html)



Subfile References and Scaling - Nathan Friend - 2015-06-22

I'm writing an online LDraw viewer using three.js and am getting some strange results when I try and render subfile references.

Here's what I have currently - this should be a basic 2 x 4 brick: http://nathanfriend.io/ldraw-visualizer (Note that I'm randomizing the color of all surfaces so I can clearly see how each is being rendered.)

As you can see, all subfile references are being translated too much, especially along the X and Z axes.

Here's a pseudo-code representation of how I'm calculating the positions of subfile parts:

Code:
subfileGeometry.applyMatrix(matrixFromSubfileReference * matrixThatRepresentsAllParentTransforms);

You can see the relevant portion of this calculation here.

Any ideas as to what I'm doing wrong?

My current theory is that some part in the subfile chain is being scaled (for example, '4-4edge.dat' is non-uniformly scaled by a factor of 6 inside of 'stud4.dat'), and the assumption is that this scaling should not be applied to its own subfile references. This scaling would then causes exaggerations in the position of all descendent subfiles. If this is correct, I'm not sure how to go about counteracting the scaling.

Any hints would be much appreciated.


Re: Subfile References and Scaling - Roland Melkert - 2015-06-23

Your current version doesn't seem to do anything for me (on SeaMonkey 2.33)

Maybe you switched the row/col order of the matrices while parsing the type 1 lines into a matrix?


Re: Subfile References and Scaling - Nathan Friend - 2015-06-27

Figured it out. My idea was correct, I was just confused by some of the implementation details of the library.


Re: Subfile References and Scaling - Steffen - 2015-06-28

FYI

http://forums.ldraw.org/showthread.php?tid=14195&pid=14195#pid14195