Primitives Reference: Difference between revisions
Holly-Wood (talk | contribs) No edit summary |
Holly-Wood (talk | contribs) No edit summary |
||
| Line 12: | Line 12: | ||
__FORCETOC__ | __FORCETOC__ | ||
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. | 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.<br> | ||
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. | [[File:XYZaxes.png|200px|middle|alt=Axes]]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.<br clear=all> | ||
==Rectilinear primitives== | ==Rectilinear primitives== | ||
| Line 704: | Line 702: | ||
|- | |- | ||
| [[File:1-8tndis.png|200px|thumb|alt=1-8tndis]] | | [[File:1-8tndis.png|200px|thumb|alt=1-8tndis]] | ||
|| This suite of primitives are used to ... | || This suite of primitives are used to used to integrate circular elements into rectilinear elements. These pad their matching n-fdisc.dat primitives out to the bounding rectangle, spanning from x = 1 to the minimal x value of the matching primitive. Note that the bounding circle in the image is for context only - only the black segment is generated by the 1-8tndis primitive. | ||
Note that the bounding circle in the image is for context only - only the black segment is generated by the 1-8tndis primitive. | |||
''Currently available primitives:''<br> | ''Currently available primitives:''<br> | ||
| Line 843: | Line 840: | ||
''Currently available primitives:''<br> | ''Currently available primitives:''<br> | ||
Regular resolution:<br> | Regular resolution (n-f)(r):<br> | ||
r=0: 1-4con0, 2-4con0, 4-4con0<br> | r=0: 1-4con0, 2-4con0, 4-4con0<br> | ||
r=1: 1-16con1, 1-8con1, 3-16con1, 1-4con1, 2-4con1, 4-4con1<br> | r=1: 1-16con1, 1-8con1, 3-16con1, 1-4con1, 2-4con1, 4-4con1<br> | ||
| Line 890: | Line 887: | ||
r=81: 4-4con81<br> | r=81: 4-4con81<br> | ||
High resolution:<br> | High resolution (n-f)(r):<br> | ||
r=0: 4-4con0<br> | r=0: 4-4con0<br> | ||
r=1: 1-4con1, 4-4con1<br> | r=1: 1-4con1, 4-4con1<br> | ||
| Line 935: | Line 932: | ||
r=64: 4-4con64<br> | r=64: 4-4con64<br> | ||
r=70: 4-4con70<br> | r=70: 4-4con70<br> | ||
|- | |||
| '''tffirrrr.dat'''<br> '''tfforrrr.dat'''<br> '''tffqrrrr.dat'''<br> <br> '''rfforrrr.dat'''<br> '''rfforrrrr.dat''' || '''Circular torus''' | |||
|- | |||
| [[File:T02i2000.png |200px|thumb|alt=T02i2000.png]] | |||
[[File:T02o2000.png |200px|thumb|alt=T02o2000.png]] | |||
[[File:T02q1765.png |200px|thumb|alt=T02q1765.png]] | |||
||This suite of primitives are used to generate circular torus sections. By default all these primitives produce a torus with a major radius of 1LDu, so typically need to be scaled up in the {x} and {z} dimensions. The first character denotes whether the minor radius is smaller than (tff primitives) or larger than the major radius (rff primitives). The latter are termed reverse ratio tori. The second and third characters of the filename ff denotes the sweep of torus, as an inverse fraction (01=1/1, 02=1/2, 04=1/4, 08=1/8, 16=1/16, 32=1/32, 48=1/48). The fourth character denotes the section of a torus (i=inner, o=outer, q=tube - the combination of 2 inner and 2 outer sections). Inner sections are not possible for reverse ratio tori. | |||
For regular tori, the last four characters of the file name rrrr denote the torus minor radius in LDu (1333=0.1333, 3333=0.3333), with the special designation 'unit' unsed to indicate a radius of 1.0000. | |||
For reverse ratio tori named like rfforrrr.dat, the last four characters of the file name rrrr represent torus minor radius with an implied decimal point after the first digit (1500=1.5, 4600=4.6). For reverse ratio tori named like rfforrrrr.dat, the last five characters of the file name rrrrr represent torus minor radius with an implied decimal point after the first two digits (11000=11.0). | |||
These diagrams (based on an idea of Paul Easter's) illustrate the relationship of the torus primitives to the major and minor radii. | |||
<gallery mode=nolines widths="200px"> | |||
torusi.png|Regular inner torus | |||
toruso.png|Regular outer torus | |||
torusro.png| Reverse ratio outer torus | |||
</gallery> | |||
''Currently available regular torus primitives:''<br> | |||
Regular resolution (ff)(rrrr):<br> | |||
Inner:<br> | |||
::t01i0702, t01i0714, t01i0769, t01i1579, t01i1667, t01i2000, t01i3261, t01i3333, t01i3600, t01i5556, t01i6000<br> | |||
::t02i1111, t02i2000, t02i2258, t02i4000<br> | |||
::t04i0462, t04i0625, t04i0857, t04i1111, t04i1304, t04i1333, t04i1429, t04i1765, t04i2000, t04i2258, t04i2500, t04i2667, t04i3333, t04i4167, t04i5000, t04i6381<br> | |||
::t08i0909, t08i2000<br> | |||
::t16i0909, t16i2000<br> | |||
<br> | |||
Outer:<br> | |||
::t01o0556, t01o0625, t01o0667, t01o0714, t01o1154, t01o1250, t01o1429, t01o1579, t01o2222, t01o2500, t01o3333, t01o3571, t01o3750, t01o3810, t01o3889, t01o4000<br> | |||
::t02o0526, t02o1111, t02o1176, t02o2000, t02o3333<br> | |||
::t04o0462, t04o0625, t04o0833, t04o0857, t04o1111, t04o1250, t04o1304, t04o1333, t04o1429, t04o1538, t04o1667, t04o1765, t04o1905, t04o2000, t04o2500, t04o2667, t04o3077, t04o3333, t04o3750, t04o4167, t04o5000, t04o6250, t04o6667, ::t04o7000, t04o7500, t04o8750, t04o8889<br> | |||
::t08o0727, t08o0909, t08o2000, t08o6250<br> | |||
::t16o0909, t16o1429, t16o2000, t16o6250<br> | |||
<br> | |||
Tube:<br> | |||
::t01q0702, t01q1429<br> | |||
::t02q3333, t02q5455<br> | |||
::t04q0625, t04q1000, t04q1316, t04q1538, t04q2500, t04q2857, t04q3030, t04q3333, t04q3529, t04q3750, t04q4000, t04q5000, t04q5455, t04q7143, t04q7500, t04q9231<br> | |||
::t08q4000, t08q5000, t08q7500<br> | |||
::t16q4000, t16q5000, t16q7500<br> | |||
<br> | |||
High resolution (ff)(rrrr):<br> | |||
Inner:<br> | |||
::t04i0455<br> | |||
::t12i8333<br> | |||
<br> | |||
Outer:<br> | |||
::t01o2000<br> | |||
::t04o0455, t04o2000<br> | |||
::t08o0625, t08o2500<br> | |||
::t12o0349, t12o0625<br> | |||
<br> | |||
Tube:<br> | |||
::t06q5000<br> | |||
<br> | |||
''Currently available reverse ratio torus primitives:''<br> | |||
Regular resolution:<br> | |||
::r04o1000, r04o1333, r04o1375, r04o1500, r04o2000, r04o3000, r04o4600<br> | |||
<br> | |||
High resolution:<br> | |||
::r04o11000<br> | |||
::r08o2000, r08o11000<br> | |||
|- | |||
| '''<s>1-4ccyli.dat</s>''' || '''<s>Circular torus</s> (obsolete)''' | |||
|- | |||
| [[File:T04q4000.png |200px|thumb|alt=T04q4000]] | |||
||This single primitive pre-dates the creation of the tffirrrr and tfforrrr suite of primitives and will not be augmented. It produces a quarter torus with a major radius of 2.5Ldu and a tube radius of 1LDu. | |||
It is superceded by t04q4000.dat. | |||
|- | |||
| '''n-fsphe.dat''' || '''Sphere section''' | |||
|- | |||
| [[File:8-8sphe.png |200px|thumb|alt=8-8sphe]] | |||
|| This primitive represents a sphere, centered at the origin {0,0,0} of radius 1 LDu. | |||
''Currently available primitives:''<br> | |||
Regular resolution (n-f): 1-8, 2-8, 4-8, 8-8<br> | |||
High resolution (n-f): 2-8, 4-8, 8-8 | |||
|- | |||
| '''1-8sphc.dat''' || '''Spherical corner''' | |||
|- | |||
| [[File:1-8sphc.png |200px|thumb|alt=1-8sphc]] | |||
||This primitive represents one octant (eighth) of a sphere, centered at the origin {0,0,0} of radius 1.414, truncated by the sides of a cube with a vertex at {1,1,1}. The boundaries of the resulting surface are circular and fit with 1-4edge.dat. | |||
|- | |||
| '''n-fedgh.dat''' || '''Cylinder Helical Edge''' | |||
|- | |||
| [[File:Placeholder.png |200px|thumb|alt=Placeholder]] | |||
||This primitive represents ... | |||
''Currently available primitives:''<br> | |||
Regular resolution (n-f): 3-16, 1-8, 1-4<br> | |||
|- | |||
| '''n-fcylh.dat''' || '''Cylinder Helical''' | |||
|- | |||
| [[File:Placeholder.png |200px|thumb|alt=Placeholder]] | |||
||This primitive represents ... | |||
''Currently available primitives:''<br> | |||
Regular resolution (n-f): 3-16, 1-8, 1-4<br> | |||
|} | |} | ||
Revision as of 08:15, 4 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















































































