Subfile References and Scaling


Subfile References and Scaling
#1
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.
Reply
Re: Subfile References and Scaling
#2
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?
Reply
Re: Subfile References and Scaling
#3
Figured it out. My idea was correct, I was just confused by some of the implementation details of the library.
Reply
Re: Subfile References and Scaling
#4
FYI

http://forums.ldraw.org/showthread.php?t...5#pid14195
Reply
« Next Oldest | Next Newest »



Forum Jump:


Users browsing this thread: 1 Guest(s)