Primitives Reference: Difference between revisions

From LDraw.org Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 16: Line 16:
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


''1 16 0 0 40 0 0 1 0 0 20  rect.dat''
''1 16 nbsp;0 0 0nbsp;nbsp;40 0 0nbsp;nbsp;0 1 0nbsp;nbsp;0 0 20nbsp;nbsp;rect.dat''


would generate a 80LDu x 40LDu rectangle in the {x,z} plane.
would generate a 80LDu x 40LDu rectangle in the {x,z} plane.
Line 22: Line 22:
Although the default orientation of the rect.dat primitive is in the {x,z} plane the LDraw language allows for this to be transformed
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 1 40 0 0 0 20  rect.dat''
''1 16nbsp;nbsp;0 0 0nbsp;nbsp;0 1 0nbsp;nbsp;40 0 0nbsp;nbsp;0 0 20nbsp;nbsp;rect.dat''


would generate a 80LDu x 40LDu rectangle in the {y,z} plane.
would generate a 80LDu x 40LDu rectangle in the {y,z} plane.


''1 16  0 0 40 0 0 0 0 20  0 1 rect.dat''
''1 16nbsp;nbsp;0 0 0nbsp;nbsp;40 0 0nbsp;nbsp;0 0 20nbsp;nbsp;0 1 0nbsp;nbsp;rect.dat''


would generate a 80LDu x 40LDu rectangle in the {x,y} plane.
would generate a 80LDu x 40LDu rectangle in the {x,y} plane.
Line 40: Line 40:
  || This primitive represents a rectangle in the {x,z} plane and the four edges that bound it. Its origin is at its centre and by default has a size of 2LDu in each of the {x} and {z} dimensions. To avoid matrix arithmetic problems in some renderers, the third dimension ({y} in the default orientation) must be given a non-zero scaling factor.
  || This primitive represents a rectangle in the {x,z} plane and the four edges that bound it. Its origin is at its centre and by default has a size of 2LDu in each of the {x} and {z} dimensions. To avoid matrix arithmetic problems in some renderers, the third dimension ({y} in the default orientation) must be given a non-zero scaling factor.


1 16  0 0 5 0 0 1 0 0 20  rect.dat   
1 16nbsp;nbsp;0 0 0nbsp;nbsp;5 0 0nbsp;nbsp;0 1 0nbsp;nbsp;0 0 20nbsp;nbsp;rect.dat   
|-
|-


Line 46: Line 46:
| '''rect3.dat''' || '''Rectangle with 3 edges'''
| '''rect3.dat''' || '''Rectangle with 3 edges'''
|-
|-
| [[File:rect3.png|thumb|alt=Rect3|Rect]]
| [[File:rect3.png|thumb|alt=Rect3|Rect3]]
|| This primitive represents a rectangle in the {x,z} plane but excludes one edge {-z}. Its origin is at its centre and by default has a size of 2LDu in each of the {x} and {z} dimensions.  
|| This primitive represents a rectangle in the {x,z} plane but excludes one edge {-z}. Its origin is at its centre and by default has a size of 2LDu in each of the {x} and {z} dimensions.  
|-
|-

Revision as of 16:16, 24 November 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

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.

Axes
Axes

Rectilinear primitives

These rectilinear elements may be scaled in the {x}, {y} and {z} dimensions to make elements of any size. For example

1 16 nbsp;0 0 0nbsp;nbsp;40 0 0nbsp;nbsp;0 1 0nbsp;nbsp;0 0 20nbsp;nbsp;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 16nbsp;nbsp;0 0 0nbsp;nbsp;0 1 0nbsp;nbsp;40 0 0nbsp;nbsp;0 0 20nbsp;nbsp;rect.dat

would generate a 80LDu x 40LDu rectangle in the {y,z} plane.

1 16nbsp;nbsp;0 0 0nbsp;nbsp;40 0 0nbsp;nbsp;0 0 20nbsp;nbsp;0 1 0nbsp;nbsp;rect.dat

would generate a 80LDu x 40LDu rectangle in the {x,y} plane.

}
Two dimensional
rect.dat Rectangle with all edges
Rect
Rect
This primitive represents a rectangle in the {x,z} plane and the four edges that bound it. Its origin is at its centre and by default has a size of 2LDu in each of the {x} and {z} dimensions. To avoid matrix arithmetic problems in some renderers, the third dimension ({y} in the default orientation) must be given a non-zero scaling factor.

1 16nbsp;nbsp;0 0 0nbsp;nbsp;5 0 0nbsp;nbsp;0 1 0nbsp;nbsp;0 0 20nbsp;nbsp;rect.dat

rect3.dat Rectangle with 3 edges
Rect3
Rect3
This primitive represents a rectangle in the {x,z} plane but excludes one edge {-z}. Its origin is at its centre and by default has a size of 2LDu in each of the {x} and {z} dimensions.