Primitives Reference

From LDraw.org Wiki
Revision as of 06:25, 27 November 2023 by Holly-Wood (talk | contribs)
Jump to navigation Jump to search

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

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    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.

Two dimensional

rect.dat Rectangle with all edges
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 16    0 0 0    5 0 0    0 1 0    0 0 20    rect.dat

rect3.dat Rectangle with 3 edges
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.
rect2p.dat Rectangle with 2 parallel edges
Rect2p
This primitive represents a rectangle in the {x,z} plane but excludes two parallel edges ({+x} and {-x}). Its origin is at its centre and by default has a size of 2LDu in each of the {x} and {z} dimensions.
rect2a.dat Rectangle with 2 adjacent edges
Rect2a
This primitive represents a rectangle in the {x,z} plane but excludes two adjacent edges ({-x} and {-z}). Its origin is at its centre and by default has a size of 2LDu in each of the {x} and {z} dimensions.
rect1.dat Rectangle with 1 edge
Rect1
This primitive represents a rectangle in the {x,z} plane but include only the one {+x} edge. Its origin is at its centre and by default has a size of 2LDu in each of the {x} and {z} dimensions.
recte3.dat Empty rectangle with three edges
Recte3
This primitive represents three edges of a rectangle in the {x,z} plane. Its origin is at its centre and by default has a size of 2LDu in each of the {x} and {z} dimensions.
recte4.dat Empty rectangle with all edges
Recte4
This primitive represents the four edges of a rectangle in the {x,z} plane. Its origin is at its centre and by default has a size of 2LDu in each of the {x} and {z} dimensions.

Three dimensional

box.dat Cuboid with all faces and edges
Box
This primitive is used to define a cuboid. Its origin is the centre of the cuboid and by default has a size of 2LDu in each of the three dimensions.
box5.dat Cuboid with 5 faces and all edges
Box5
This primitive represents a cuboid missing the top {-y} face. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box5-1.dat Cuboid with 5 faces without 1 edge
Box5
This primitive represents a cuboid missing the top {-y} face and one edge {-z} of that. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box5-2p.dat Cuboid with 5 faces without 2 parallel edges
Box5
This primitive represents a cuboid missing the top {-y} face and two of the four edges surrounding that. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box5-4a.dat Cuboid with 5 faces without top edges
Box5
This primitive represents a cuboid missing the top {-y} face and the four edges surrounding that. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box5-12.dat Cuboid with 5 faces missing all edges
Box5
This primitive represents a cuboid missing the top {-y} face and all edges. Its primary use is for sticker parts. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box4.dat Cuboid with 4 parallel faces and all edges
Box5
This primitive represents a cuboid missing the top {-y} and bottom {+y} faces. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box4o4a.dat Cuboid with 4 parallel faces without bottom edges
Box5
This primitive represents a cuboid missing the top {-y} and bottom {+y} faces, and missing the edges of the bottom face. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box4o8a.dat Cuboid with 4 parallel faces without top and bottom edges
Box5
This primitive represents a cuboid missing the top {-y} and bottom {+y} faces, and missing the edges of the top and bottom face. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box4t.dat Cuboid with 4 adjacent and all edges
Box5
This primitive represents a cuboid missing the top {-y} and front {-z} faces, but with all its edges. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box4-1.dat Cuboid with 4 adjacent faces missing 1 edge
Box5
This primitive represents a cuboid missing the top {-y} and front {-z} faces and the edge between those faces. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box4-2p.dat Cuboid with 4 faces without two opposite top edges
Box5
This primitive represents a cuboid missing the top {-y} and bottom {+y} faces, and missing two edges of the top face - the intersection of the two missing faces and the opposite edge. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box4-3p.dat Cuboid with 4 faces without three parallel edges
Box5
This primitive represents a cuboid missing the top {-y} and bottom {+y} faces, and missing three edges of the missing faces. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box4-4a.dat Cuboid with 4 adjacent faces missing 4 edges
Box5
This primitive represents a cuboid missing the top {-y} and front {-z} faces and all the edges of the missing front face. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box4-7a.dat Cuboid with 4 adjacent faces missing 7 edges
Box5
This primitive represents a cuboid missing the top {-y} and front {-z} faces and all the edges of both missing faces. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.