Primitives Reference: Difference between revisions
Holly-Wood (talk | contribs) No edit summary |
Holly-Wood (talk | contribs) No edit summary |
||
Line 20: | Line 20: | ||
==Rectilinear primitives== | ==Rectilinear primitives== | ||
'''Nomenclature''' | |||
Boxes are named boxF, with F representing the number of faces a box has. The suffix E represents the number of edges removed. | Boxes are named boxF, with F representing the number of faces a box has. The suffix E represents the number of edges removed. | ||
Line 28: | Line 28: | ||
Face modifiers: | Face modifiers: | ||
* o - faces are opposite to each other | |||
* t - faces are all touching each other (usually, it's implied, but box4t.dat is a thing) | |||
* u - missing faces form a U-shape | |||
Edge letters: | Edge letters: | ||
* p - groups of edges are parallel to each other | |||
* a - some missing faces have no adjacent edges | |||
'''Scaling and orientation''' | |||
These rectilinear elements may be scaled in the {x}, {y} and {z} dimensions to make elements of any size. For example | These rectilinear elements may be scaled in the {x}, {y} and {z} dimensions to make elements of any size. For example | ||
Line 485: | Line 485: | ||
|- | |- | ||
| '''n-fchrd.dat''' || ''' | | '''n-fchrd.dat''' || '''Circular disc segment''' | ||
|- | |- | ||
| [[File:1-4chrd.png|200px|thumb|alt=1-4chrd]] | | [[File:1-4chrd.png|200px|thumb|alt=1-4chrd]] | ||
Line 496: | Line 496: | ||
Note: The regular resolution 1-16chrd.dat and high resolution 1-48chrd are special cases, see Primitive Substitution Adapters below for more information | Note: The regular resolution 1-16chrd.dat and high resolution 1-48chrd are special cases, see Primitive Substitution Adapters below for more information | ||
|- | |- | ||
Line 697: | Line 670: | ||
r=7 : 4-4ring7<br> | r=7 : 4-4ring7<br> | ||
r=11 : 4-4ring11<br> | r=11 : 4-4ring11<br> | ||
|- | |||
| '''1-16chrd.dat'''<br>'''1-48chrd.dat'''<br>'''n-fering.dat''' || '''Primitive Substitution Adapters''' | |||
|- | |||
| [[File:4-4edge.png|200px|thumb|alt=4-4edge]] | |||
|| This suite of primitives are used correct for gaps that form between curved primitives and normal geometry in editors that utilize primitive substitution. This is a special case used on the inside of a curved primitive where it joins geometry that cannot make use of a curved primitive. The chrd files themselves are simply a reference to empty.dat, which under normal circumstances does not draw anything. However, in tools that support primitive substitution, the curved primitive it is attached to would normally in this case create a gap when rendered using more than 16 points to form a circle. In that case, the substituted version of these normally empty primitives would fill in the gap between the curve and the other geometry. | |||
To "see" these primitives, the editor in use must utilize primitive substitution. Then one of the following can be done: | |||
* set the curve quality to a level high enough to see the gaps reappear | |||
* For LDView 4.4 or later, in the Model Tree dialog, you can search for them (for example, "ering"), and if you have it set to highlight, then when you select one, it will be highlighted in the 3D view. | |||
* Manually recolor the primitive in question to a color that contrasts with the colors that surround it | |||
Note that the bounding circle in the image is for context only - there are no actual geometry producing lines contained in these files. | |||
''Currently available primitives:''<br> | |||
Regular resolution (n-f): 1-16chrd, 1-4ering, 1-8ering, 3-16ering, 2-4ering, 4-4ering<br> | |||
High resolution (n-f): 1-48chrd | |||
|- | |||
| '''n-ftang.dat''' || '''Tangential ring segment''' | |||
|- | |||
| [[File:1-4tang.png|200px|thumb|alt=1-4tang]] | |||
|| This suite of primitives are used to pad a 16-sided polygon to a circumscribing 16-sided polygon whose edges are tangential to the inner polygon. Note that the bounding circle in the image is for context only - only the grey segment is generated by the 1-4tang primitive. | |||
''Currently available primitives:''<br> | |||
Regular resolution (n-f): 1-16, 1-8, 3-16, 1-4 | |||
|- | |||
| '''n-ftndis.dat''' || '''Disc negative truncated''' | |||
|- | |||
| [[File:1-8tndis.png|200px|thumb|alt=1-8tndis]] | |||
|| This suite of primitives are used to ... | |||
''Currently available primitives:''<br> | |||
Regular resolution (n-f): 1-16, 1-8, 3-16 | |||
High resolution (n-f): 5-48, 1-24, 1-16, 1-8 | |||
|- | |- | ||
Revision as of 11:50, 2 December 2023
LDraw Primitives Reference
This page is a source of reference for the LDraw primitives in the \LDraw\p directory. Primitives are defined as highly re-usable components of LEGO parts modelled for LDraw. They serve several purposes :
- To speed up parts authoring by providing a library of components which can be incorporated into several parts
- To allow rendering software to make substitutions of curved components
Within this reference material the available primitives are categorised into:
Each section contains an overview of the characteristics common to all primitives within that category. Primitives are grouped into classes within each category - one class of primitive serving a similar purpose at different sizes or resolutions. For each class of primitive, a brief description of the purpose of the primitive is provided, with notes on its co-ordinate origin, default size and rules for scaling. A list of the available primitives is shown.
An understanding of the orientation of the co-ordinate axes is essential for authoring a part for LDraw. For reference within this page the axes and their direction is shown in this diagram.
Rectilinear primitives
Nomenclature
Boxes are named boxF, with F representing the number of faces a box has. The suffix E represents the number of edges removed.
F and E are may followed by an additional letter. The hyphen is removed if F is accompanied by a modifier.
Face modifiers:
- o - faces are opposite to each other
- t - faces are all touching each other (usually, it's implied, but box4t.dat is a thing)
- u - missing faces form a U-shape
Edge letters:
- p - groups of edges are parallel to each other
- a - some missing faces have no adjacent edges
Scaling and orientation
These rectilinear elements may be scaled in the {x}, {y} and {z} dimensions to make elements of any size. For example
1 16 0 0 0 40 0 0 0 1 0 0 0 20 rect.dat
would generate a 80LDu x 40LDu rectangle in the {x,z} plane.
Although the default orientation of the rect.dat primitive is in the {x,z} plane the LDraw language allows for this to be transformed
1 16 0 0 0 0 1 0 40 0 0 0 0 20 rect.dat
would generate a 80LDu x 40LDu rectangle in the {y,z} plane.
1 16 0 0 0 40 0 0 0 0 20 0 1 0 rect.dat
would generate a 80LDu x 40LDu rectangle in the {x,y} plane.
Curved primitives
LDraw represents curved surfaces as polygons. For circular components two series of primitives are provided.
All the circular primitives are orientated in the {x,z} plane with their origin at the centre of the circle and a default radius of 1 LDu. Primitives are provided for complete circles and for commonly used fractions of a complete circle. Where the naming convention includes a prefix of the form n-f this indicates the fraction (n/f) of the circle drawn by the primitive. Where this fraction is less than an entire circle, the primitive starts at {+x,0} and progresses in a conterclockwise direction when viewed from above {-y}.
To avoid rounding errors, it is preferable to use existing fractional circular primitives, or create a new primitive, rather than rotate an existing primitive by anything other than 90 or 180 degrees. For example, use 3-16XXXX.dat rather than combining 1-8XXXX.dat with 1-16XXXX.dat rotated by 22.5 degreees.
To avoid matrix arithmetic problems in some renderers, the third dimension ({y} in the default orientation) of two-dimensional primitives must be given a non-zero scaling factor. LDraw circles are normally formed of 16-sided polygons (hexdecagons) - the regular resolution. For larger elements, where scaling-up of hexadecagons would give too angular an appearance, a series of high resolution primitives based on a 48-sided polygon are available. These may also be used for parts not well suited to a 16-fold symmetry.
These circular elements may be scaled by the same factor in both the {x} and {z} dimensions to make circular elements of greater or less than 1LDu radius. For example
1 16 0 0 0 3 0 0 0 1 0 0 0 3 4-4edge.dat
would generate a circle in the {x,z} plane with a radius of 3LDu.
They may also be scaled asymmetrically in the x and z dimension to make ellipses.
Although the default orientation is in the {x,z} plane the LDraw language allows for these to be transformed
1 16 0 0 0 0 1 0 3 0 0 0 0 3 4-4edge.dat would generate a circle in the {y,z} plane
1 16 0 0 0 3 0 0 0 0 3 0 1 0 4-4edge.dat would generate a circle in the {x,y} plane