LDraw
Encyclopedia
LDraw is a popular system of free software
Free software
Free software, software libre or libre software is software that can be used, studied, and modified without restriction, and which can be copied and redistributed in modified or unmodified form either without restriction, or with restrictions that only ensure that further recipients can also do...

 tools for modeling Lego
Lego
Lego is a line of construction toys manufactured by the Lego Group, a privately held company based in Billund, Denmark. The company's flagship product, Lego, consists of colorful interlocking plastic bricks and an accompanying array of gears, minifigures and various other parts...

 creations in 3D on a computer. The LDraw file format and original program were written by James Jessiman. He also modeled many of the original parts in the parts library that is central to the programs and is under continuous maintenance and extension by the LDraw community. In 1997, Jessiman died. Since then, a variety of programs have been written that use the LDraw parts library, and file format. LDraw models are frequently rendered in POV-Ray
POV-Ray
The Persistence of Vision Raytracer, or POV-Ray, is a ray tracing program available for a variety of computer platforms. It was originally based on DKBTrace, written by David Kirk Buck and Aaron A. Collins. There are also influences from the earlier Polyray raytracer contributed by its author...

, a free 3D ray tracer.

LDraw file format

The LDraw format can divide a model into steps so that the building instructions can be incorporated into the design, and also allows for steps that rotate the camera and even move parts around in an elementary fashion. It also allows for models to be incorporated in the construction of larger models to make design easier. This also makes the file format very disk space saving: instead of specifying the polygons of every single stud of a specific brick for example, a shared stud file is included multiple times with transformation applied.

Parts, models, sub-models and polygons are all treated the same and are not specific to Lego models (only the parts library is). The format could be used to store any type of 3D model. Some have created bricks of other building systems for use with LDraw.

LDraw files specifying basic single parts or sub-primitives usually have the extension .dat, Lego models consisting of multiple bricks have the extension .ldr, models consisting of multiple parts and sub-models are called *.mpd.

The file format uses plain text data.

Example part

0 Brick 2 x 2
0 Name: 3003.dat
0 Author: James Jessiman
0 !LDRAW_ORG Part UPDATE 2002-03
0 !LICENSE Redistributable under CCAL version 2.0 : see CAreadme.txt

0 BFC CERTIFY CCW

0 !HISTORY 2001-10-26 [PTadmin] Official Update 2001-01
0 !HISTORY 2002-05-07 [unknown] BFC Certification
0 !HISTORY 2002-06-11 [PTadmin] Official Update 2002-03
0 !HISTORY 2007-05-07 [PTadmin] Header formatted for Contributor Agreement
0 !HISTORY 2008-07-01 [PTadmin] Official Update 2008-01

1 16 0 4 0 1 0 0 0 -5 0 0 0 1 stud4.dat

0 BFC INVERTNEXT
1 16 0 24 0 16 0 0 0 -20 0 0 0 16 box5.dat

4 16 20 24 20 16 24 16 -16 24 16 -20 24 20
4 16 -20 24 20 -16 24 16 -16 24 -16 -20 24 -20
4 16 -20 24 -20 -16 24 -16 16 24 -16 20 24 -20
4 16 20 24 -20 16 24 -16 16 24 16 20 24 20

1 16 0 24 0 20 0 0 0 -24 0 0 0 20 box5.dat

1 16 10 0 10 1 0 0 0 1 0 0 0 1 stud.dat
1 16 -10 0 10 1 0 0 0 1 0 0 0 1 stud.dat
1 16 10 0 -10 1 0 0 0 1 0 0 0 1 stud.dat
1 16 -10 0 -10 1 0 0 0 1 0 0 0 1 stud.dat
0

The above code defines the basic 2×2 brick. It consist of a five-sided box (box5.dat, outside) and an inverted five-sided box (inside), the connection between those two, consisting of four quads (the four lines starting with 4), the four studs on top of it (stud.dat) and the long hollow stud in the inside (stud4.dat).

All lines in an LDraw file are either empty or start with a command number, where 0 means no command (though over time, some lines starting with 0 followed by specific text in CAPITALS also got a meaning as meta commands). The command 1 for example includes a subfile. It specifies the file's path and a transformation matrix that should be applied to it, as well as its color (where 16 means "use the color that was used when including the current file"). Command 4 specifies a four-sided polygon. There are also commands that define 2D lines. Such lines give the parts a clear contour even in non-shaded orthographic renderings (see the MLCad picture below).

Example Model

The following code specifies a simple pyramid model with three layers made of 2 x 4 bricks (brick # 3001) with changing color and a 2 x 2 brick on top.
0 Pyramid
0 Name: pyramid.dat
0 Author: James Jessiman

1 1 -40 -24 60 1 0 0 0 1 0 0 0 1 3001.dat
1 1 40 -24 60 1 0 0 0 1 0 0 0 1 3001.dat
1 1 60 -24 0 0 0 1 0 1 0 -1 0 0 3001.dat
1 1 40 -24 -60 1 0 0 0 1 0 0 0 1 3001.dat
1 1 -40 -24 -60 1 0 0 0 1 0 0 0 1 3001.dat
1 1 -60 -24 0 0 0 1 0 1 0 -1 0 0 3001.dat
0 STEP
1 4 -20 -48 40 1 0 0 0 1 0 0 0 1 3001.dat
1 4 40 -48 20 0 0 1 0 1 0 -1 0 0 3001.dat
1 4 20 -48 -40 1 0 0 0 1 0 0 0 1 3001.dat
1 4 -40 -48 -20 0 0 1 0 1 0 -1 0 0 3001.dat
0 STEP
1 14 0 -72 20 1 0 0 0 1 0 0 0 1 3001.dat
1 14 0 -72 -20 1 0 0 0 1 0 0 0 1 3001.dat
0 STEP
1 0 0 -96 0 1 0 0 0 1 0 0 0 1 3003.dat
0 STEP
0

Peeron and LDraw

The Peeron Lego set and parts database lists parts that are available as 3D CAD models in the LDraw parts library with correctly colored images rendered from these models.
Also, the Peeron and LDraw team work together at unifying unclear part numbers, colors and names.

Furthermore, the Peeron website also powers the LDraw website and both sites often suffer from slow connection because the traffic turned out to be much higher than what was expected when the servers were first installed.

External links


Modeling

It is possible, but difficult, to generate a Lego creation solely by entering the piece "part numbers" and their positions. Usually, the following tools will be used to put them together.
  • MLCad, an orthographic
    Orthographic projection (geometry)
    In Euclidean geometry, an orthographic projection is an orthogonal projection. In particular, in 3D it is an affine, parallel projection of an object onto a perpendicular plane....

     editor for Microsoft Windows
    Microsoft Windows
    Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

     with wizards for generating minifigs, hoses, belts, and springs.
  • LeoCAD, an editor with a perspective
    Perspective (graphical)
    Perspective in the graphic arts, such as drawing, is an approximate representation, on a flat surface , of an image as it is seen by the eye...

     camera. It is available for Microsoft Windows and Linux.
  • ldraw and ledit are the original DOS
    DOS
    DOS, short for "Disk Operating System", is an acronym for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995, or until about 2000 if one includes the partially DOS-based Microsoft Windows versions 95, 98, and Millennium Edition.Related...

     programs that were written by James Jessiman, the originator of the standard. They have not been updated since 1997, and are considered obsolete.
  • LDraw-mode is an Emacs
    Emacs
    Emacs is a class of text editors, usually characterized by their extensibility. GNU Emacs has over 1,000 commands. It also allows the user to combine these commands into macros to automate work.Development began in the mid-1970s and continues actively...

     major mode for editing LDraw files as text.
  • Bricksmith An open source
    Open source
    The term open source describes practices in production and development that promote access to the end product's source materials. Some consider open source a philosophy, others consider it a pragmatic methodology...

     editor for Apple Macintosh
    Macintosh
    The Macintosh , or Mac, is a series of several lines of personal computers designed, developed, and marketed by Apple Inc. The first Macintosh was introduced by Apple's then-chairman Steve Jobs on January 24, 1984; it was the first commercially successful personal computer to feature a mouse and a...

     computers.

Viewing

  • L3Lab, a fast orthographic
    Orthographic projection (geometry)
    In Euclidean geometry, an orthographic projection is an orthogonal projection. In particular, in 3D it is an affine, parallel projection of an object onto a perpendicular plane....

     viewer for LDraw files, available for Microsoft Windows
    Microsoft Windows
    Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

     and Mac OS X
    Mac OS X
    Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

    .
  • LDLite, a slower perspective
    Perspective (graphical)
    Perspective in the graphic arts, such as drawing, is an approximate representation, on a flat surface , of an image as it is seen by the eye...

     viewer for LDraw files that boasts specular reflection and cutaway viewing. It runs in Microsoft Windows.
  • LDView, an OpenGL
    OpenGL
    OpenGL is a standard specification defining a cross-language, cross-platform API for writing applications that produce 2D and 3D computer graphics. The interface consists of over 250 different function calls which can be used to draw complex three-dimensional scenes from simple primitives. OpenGL...

    -accelerated program similar to LDLite, for Microsoft Windows, Linux
    Linux
    Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...

    , and Mac OS
    Mac OS
    Mac OS is a series of graphical user interface-based operating systems developed by Apple Inc. for their Macintosh line of computer systems. The Macintosh user experience is credited with popularizing the graphical user interface...

    .
  • Ldglite, an open-source, OpenGL viewer similar to LDLite, for Microsoft Windows, Linux, and Mac OS.

Converting

  • L2P and L3P, two similarly named but independent programs that convert LDraw files to files that can be rendered with POV-Ray
    POV-Ray
    The Persistence of Vision Raytracer, or POV-Ray, is a ray tracing program available for a variety of computer platforms. It was originally based on DKBTrace, written by David Kirk Buck and Aaron A. Collins. There are also influences from the earlier Polyray raytracer contributed by its author...

    . Both of these programs use Lutz Uhlmann's LGEO library, which contains LDraw parts hand-converted to POV-Ray CSG
    Constructive solid geometry
    Constructive solid geometry is a technique used in solid modeling. Constructive solid geometry allows a modeler to create a complex surface or object by using Boolean operators to combine objects...

    s for better-looking parts. They run under DOS
    DOS
    DOS, short for "Disk Operating System", is an acronym for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995, or until about 2000 if one includes the partially DOS-based Microsoft Windows versions 95, 98, and Millennium Edition.Related...

     and Command Prompt (Windows), L3P also runs under Linux
    Linux
    Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...

     and Mac OS X
    Mac OS X
    Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

    .
  • LDraw2LWS is a Microsoft Windows
    Microsoft Windows
    Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

     program that converts LDraw files to Lightwave Objects and Scenes.
  • LdrDat2Dxf, LdrDat2Obj is a pair of Microsoft Windows
    Microsoft Windows
    Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

    programs that converts LDraw files into DXF, OBJ formats respectively.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK