Cleaning LDraw Files for Export: Difference between revisions

From LDraw.org Wiki
Jump to navigation Jump to search
(edits)
 
(2 intermediate revisions by the same user not shown)
Line 9: Line 9:


==Coincident surfaces==
==Coincident surfaces==
The third issue is redundancy: Let's take for example a model composed of two identical bricks stacked on top of each other. The bricks are flush with each other such that the bottom surface of the top object is pressed against the top surface of the bottom object. You could say that the surface details where the two objects meet occupy the same place, or are coincident. In reality, there's a tiny gap between these surfaces where a small amount of air can pass through. In computer modeling, however, it is often useful to disregard these differences and simply make all points and surfaces mathematically perfect. While this is trivial to do and can lead to pleasing results, it introduces a problem. Each part has a set of matching surfaces and vertices shared by the other part. Some of these surfaces and vertices are in fact duplicates. The duplicate elements no longer serve a useful purpose, and end up merely taking up much needed space in the model file. There's a strong need to get rid of these redundant, wasteful elements.
The third issue is redundancy: Let's take for example a model composed of two identical bricks stacked on top of each other. The bricks are flush with each other such that the bottom surface of the top object is pressed against the top surface of the bottom object. You could say that many of the surface details where the two objects meet occupy the same place, or are coincident. In reality, there's a tiny gap (the seam width) between these surfaces where a small amount of air can pass through. In computer modeling, however, it is often desirable to disregard the seam width and simply make all points and surfaces mathematically perfect. While this is trivial to do and can lead to pleasing results, it introduces a problem: each part has a set of matching surfaces and vertices shared by the other part. Some of these surfaces and vertices are in fact duplicates. The duplicate elements no longer serve a useful purpose, and end up merely taking up much needed space in the model file. There's a strong need to get rid of these redundant, wasteful elements.


==Surface reduction==
==Surface reduction==
Line 16: Line 16:
Note that there is an additional issue related to MeshLab's internal face reduction approach: back-face culling (BFC). When cleaning parts from a model, Meshlab requires that the vertices of the triangles be "wound" properly. Winding is what allows the program (and other programs that use 3D models) to determine the surface normal when not specifically defined, and thus (roughly) the "outside" and "inside" of the model. If the vertices are not wound properly, the program will get confused and behave improperly. Unfortunately, in the case of LDraw models not all parts have been validated as "BFC certified", and thus wound properly. This fact peculiar to LDraw models will likely make the approach untenable in the majority cases.
Note that there is an additional issue related to MeshLab's internal face reduction approach: back-face culling (BFC). When cleaning parts from a model, Meshlab requires that the vertices of the triangles be "wound" properly. Winding is what allows the program (and other programs that use 3D models) to determine the surface normal when not specifically defined, and thus (roughly) the "outside" and "inside" of the model. If the vertices are not wound properly, the program will get confused and behave improperly. Unfortunately, in the case of LDraw models not all parts have been validated as "BFC certified", and thus wound properly. This fact peculiar to LDraw models will likely make the approach untenable in the majority cases.


==Links:==
==Links==


* [http://meshlabstuff.blogspot.com/search/label/mesh%20cleaning How to remove internal faces with MeshLab]
* [http://meshlabstuff.blogspot.com/search/label/mesh%20cleaning How to remove internal faces with MeshLab]

Latest revision as of 21:08, 23 January 2016

Introduction

LDraw models are great to look at, but are generally inappropriate for real-time rendering tasks such as video games. Here's why.

Level of detail

The main issue is detail. LDraw models are highly accurate representations of real Lego parts. Each part can have lots of minute details, and the number of parts in a single large model can be quite huge! This amount of detail translates into lots and lots of polygons, which is the main limiter of how well a real-time rendering application will run.

Hidden objects

The second issue is hidden objects: LDraw models are made up of multiple smaller parts. These parts are assembled as they are, with no modification. Thus, all the inner bits and pieces (such as studs) that are visible when viewing the part by itself but invisible when viewing the entire model are still there. That means there's lots of detail (and thus polygons) in the model that will never see the light of day!

Coincident surfaces

The third issue is redundancy: Let's take for example a model composed of two identical bricks stacked on top of each other. The bricks are flush with each other such that the bottom surface of the top object is pressed against the top surface of the bottom object. You could say that many of the surface details where the two objects meet occupy the same place, or are coincident. In reality, there's a tiny gap (the seam width) between these surfaces where a small amount of air can pass through. In computer modeling, however, it is often desirable to disregard the seam width and simply make all points and surfaces mathematically perfect. While this is trivial to do and can lead to pleasing results, it introduces a problem: each part has a set of matching surfaces and vertices shared by the other part. Some of these surfaces and vertices are in fact duplicates. The duplicate elements no longer serve a useful purpose, and end up merely taking up much needed space in the model file. There's a strong need to get rid of these redundant, wasteful elements.

Surface reduction

I know of two tentative, partially automated ways of addressing these issues that, when used in conjunction with each other, might eliminate the above problems: removing internal faces using MeshLab and using LDBoxer to convert parts to simpler, lighter versions. I will not discuss these in detail. They are, however, addressed in the links at the end of this article. Simple poly-reduction techniques such as Blender's "Decimate" operation will not work, as they choose polygons more or less randomly, and don't differentiate between the "inside" and "outside" of a model.

Note that there is an additional issue related to MeshLab's internal face reduction approach: back-face culling (BFC). When cleaning parts from a model, Meshlab requires that the vertices of the triangles be "wound" properly. Winding is what allows the program (and other programs that use 3D models) to determine the surface normal when not specifically defined, and thus (roughly) the "outside" and "inside" of the model. If the vertices are not wound properly, the program will get confused and behave improperly. Unfortunately, in the case of LDraw models not all parts have been validated as "BFC certified", and thus wound properly. This fact peculiar to LDraw models will likely make the approach untenable in the majority cases.

Links