How to get started developing a new LDraw Editor?


RE: How to get started developing a new LDraw Editor?
#3
(2019-06-15, 12:11)Nathan Readioff Wrote: (...)

Why do you use a right-handed coordinate system, with negative y straight up? The two main conventions are +x to the right, +y upwards, and +z either into or out of the screen (for left or right handed). So why was this one chosen? 

1) Each brick in the library is constructed from a series of recursive primitives, so what’s the best way to manage a brick in a program? Do you consider the brick as an object with multiple child limbs (with the limb structure preserving the LDraw primitive file hierarchy)? Or is it better to combine the geometry data of all of the primitives into a single 3D mesh? And has anyone ever pursued the LDD approach of hiding studs and anti-studs once they are connected, to reduce the scene poly-count?

2) None of the bricks contain normal data for the vertices, so how do you go about computing this? I mean, I know it’s a vector cross-product for each triangle, but how do you work out if an edge should be a hard edge (like for sides of a 2x4 brick) or a soft edge (like the rounded surface of a minifig head)? How do you go about searching the vertex data for shared edges?  (And out of historical curiosity, why wasn’t the LDraw library designed to include the normal data? Was the original intention to use flat shading only?)

What is the importance of the back-face culling commands in the file format?  Polygons can be rendered as single or double sided, but single sided is the default for performance reasons, and polygons facing away from the camera can be automatically culled by the 3D render engine.  So why does this need to be such a major part of the file format specification? Is this used to help determine which way a normal vector should point when creating a triangle?

3) For the ROTSTEP command, why does it specify three Euler angles for the rotation instead of a quaternion? And what’s the rotation order (x,y,z, z,y,x, …)?  Also, am I correct in assuming that REL and ABS denote use of perspective or orthographic rendering modes?

4) When defining parts in a model, the file format specifies x,y,z positions then a 3x3 rotation matrix.  Why isn’t a full 4x4 matrix used, so that all position, scale, rotation information could be encoded in one structure?

From looking at the Bricksmith editor, steps seem to have a default rotation of x,y,z = 31,41,21 degrees.  Why is this angle chosen, does the default ever vary from program to program?

(...)

I have answers and comments for the questions highlighted.

1) In the renderer I have been working on for the past year I have seen a huge performance gain in rendering time by going from primitives within primitives to fully 'burned' meshes: one for each part in a model. However. Primitives like "stud.dat" are used so often that I believe there is an optimal solution to be found somewhere in the middle.

2) Brigl uses the conditional lines as indicators for soft edges. This strategy seems to work quite well: http://www.lugato.net/brigl/


3) You are correct regarding REL and ABS. From the abstract for the MPD file format you can get the formulas for how to get from x/y/z in the file line to a matrix. See an implementation of this in my loader, function getRotationMatrix() in the code here: LDRLoader.js

4) A word of caution. I spent 5 days of debugging due to an assertion you are making here: If you make a 4x4 matrix using the 3x3 matrix and position vector in LDraw, you will not always get a matrix that is decomposable to a quaternion, scale and position! See 11477.dat for an example. Why someone has decided to use such a matrix is beyond me, and this is currently the reason why almost no renderer computes bounding boxes correctly for parts like this.
Reply
« Next Oldest | Next Newest »



Messages In This Thread
RE: How to get started developing a new LDraw Editor? - by Lasse Deleuran - 2019-06-15, 14:51

Forum Jump:


Users browsing this thread: 1 Guest(s)