1 / 24

Basic Parts Authoring in LDraw

Basic Parts Authoring in LDraw. Getting started on the path to create you own parts for the LDraw library By Orion Pobursky. Why Make Parts?. Not all LEGO® parts are modeled in the official library Custom part designs Basic CAD objects. What do you need?. An LDraw compatible 3D viewer

gibson
Download Presentation

Basic Parts Authoring in LDraw

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Basic Parts Authoring in LDraw • Getting started on the path to create you own parts for the LDraw library • By Orion Pobursky BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

  2. Why Make Parts? • Not all LEGO® parts are modeled in the official library • Custom part designs • Basic CAD objects BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

  3. What do you need? • An LDraw compatible 3D viewer • LDView • L3Lab • An LDraw code editor • LDraw Design Pad (LDDP) • LDraw Add On (LDAO) • MLCad • Notepad BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

  4. Part Dimensions • LDraw part are measured in LDraw Units (LDU) • 1 brick width/depth = 20 LDU • 1 brick height = 24 LDU • 1 stud width = 12 LDU • Real Life Conversion • 1 LDU = 1/64 in • 1 LDU = .397 mm BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

  5. Plan Your Process • Analyze the Part • Graph paper helps • Take Measurements • Two Techniques • Comparison to other parts • Calipers or Ruler • Generally speaking, features less than 1 LDU need not be modeled BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

  6. The LDraw File Format • All LDraw files are text based • Every line of the file is one command • The type of command for each line is determined by the first number the appears on each line • There are 5 different types of commands or linetypes BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

  7. Linetype 0: The Comment • Form: • 0 // <comment> • <comment> can be any length • Additionally, Linetype 0 is used for any meta-commands. These commands essentially tell the LDraw program to do some non-drawing action. For those with a programming background, these meta-commands are essentially like pre-processor directives • While there a few official meta-commands, there are many unofficial ones as these are added by program authors to suit their needs. • For example, LPub uses many of these custom meta-commands to allow the user to dictate page layout. BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

  8. Linetype 1: The Subfile • Form: • 1 <color> x y z a b c d e f g h i <file> • <color> is the LDraw color number • x y z is the part position • a … I is a standard 3D transformation matrix • <file> is the referenced file • Most model are completely Linetype 1. • Also used in part files for primitive and subpart references BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

  9. Linetypes 2 and 3:The Line and Triangle • Linetype 2 • Form: • 2 <color> x1 y1 z1 x2 y2 z2 • Most linetype 2’s are color 24 (edge color) • Linetype 3 • Form: • 3 <color> x1 y1 z1 x2 y2 z2 x2 y2 z2 x1 y1 z1 x2 y2 z2 x1 y1 z1 x2 y2 z2 x3 y3 z3 BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

  10. x1 y1 z1 x2 y2 z2 x4 y4 z4 x3 y3 z3 1 2 1 2 4 3 3 4 Linetype 4: The Quad • Form: • 4 <color> x1 y1 z1 x2 y2 z2 x2 y2 z2 x4 y4 z4 • Be aware of coordinate order • Avoid concave quads: Good Bad This is what is called a bowtie quad BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

  11. Linetype 5: The Optional Line • Form: • 5 <color> x1 y1 z1 x2 y2 z2 x2 y2 z2 x4 y4 z4 • <color> is the LDraw color number • x1 y1 z1 is the position of the 1st point of the line • x2 y2 z2 is the position of the 2nd point of the line • x3 y3 z3 is the position of the 1st control point • x4 y4 z4 is the position of the 2nd control point • Used to ‘highlight’ the curvature of rounded aspects of the part • Since Lintype 5’s are used on surfaces that are rounded, programs can use them to implement smooth curves. • Linetype 5 is by far the least understood linetype and is best explained with an example… BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

  12. Linetype 5: The Optional Line (cont.) • The LDraw program defines a line between the first two points. If the projections of the two control points onto the screen are on the same side of the projection of the defined line then the line is drawn, otherwise it is not • Say we have an optional line from 1 to the bottom of the cylinder. In this case the control points should be set at 8 and 2. Since points 8 and 2 are not on the same side of the line below 1 the line is not drawn • Now say we have an optional line from 2 to the bottom of the cylinder. In this case the control points should be set at 1 and 2. Since 1 and 3 are on the same side of the line below 2 the line is drawn 8 7 1 2 6 3 5 4 BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

  13. Color Definition • All colors are represented by a number • The RGB values and other characteristics of official colors are defined in a special file in the LDRAW directory name ldconfig.dat • Two color numbers (16,24) are reserved for special functions • This method of defining colors was recently adopted and currently LDView is the only widely used program to implement support • The legacy method is still the most widely supported format… BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

  14. Legacy Color Definition • Color RGB values are hard coded and defined by a number. There are 16 basic official colors (0-15) • Transparent colors are limited to transparent versions of the solid colors. (Original Color #) + 32 • Extended colors (256 – 511) are defined by dithering two of the official colors. • (Color 1) * 16 + (Color 2) + 256 BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

  15. Colors 16 and 24 • Color 16 is defined as ‘Main Color’ • This mean that if the part file is referenced by another file, all the color 16 lines are displayed using the color of the line that referenced it. • Example: • 1 4 0 0 0 1 0 0 0 1 0 0 0 1 part.dat • All the color 16 lines in part.dat will be displayed using color 4 (Red) • This is what allows one part file to be represented in many different colors in one model file • Color 24 is defined as ‘Edge Color’ • This works exactly like color 16, only the display color is the complement color. • Using the example above, all the color 24 line will display using the complement to color 4, color 12 (Light Red) • The list of complement colors can be found on LDraw.org’s color chart BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

  16. Primitives • LDraw primitives are shortcut files for commonly used structures. These are found in the P folder • Included in this are: Cylinders Rings Disks Negative Disks Other specialized primitives such as peg holes, axle holes, connect pins are also found in the P folder. Boxes Torus Studs BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

  17. Let’s examine the code for a 1x2 brick This file has 4 quads, 3 studs, and 2 references to box5.dat Box5 is a primitive found in the P folder: We’ll examine these lines one group at a time. 1 16 0 4 0 1 0 0 0 -5 0 0 0 1 stud3.dat 1 16 0 24 0 16 0 0 0 -20 0 0 0 6 box5.dat 4 16 20 24 10 16 24 6 -16 24 6 -20 24 10 4 16 -20 24 10 -16 24 6 -16 24 -6 -20 24 -10 4 16 -20 24 -10 -16 24 -6 16 24 -6 20 24 -10 4 16 20 24 -10 16 24 -6 16 24 6 20 24 10 1 16 0 24 0 20 0 0 0 -24 0 0 0 10 box5.dat 1 16 10 0 0 1 0 0 0 1 0 0 0 1 stud.dat 1 16 -10 0 0 1 0 0 0 1 0 0 0 1 stud.dat Putting it all together BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

  18. Putting it all together (cont.) • The four quads make the bottom: • The first box 5 makes up the inside: 4 16 20 24 10 16 24 6 -16 24 6 -20 24 10 4 16 -20 24 10 -16 24 6 -16 24 -6 -20 24 -10 4 16 -20 24 -10 -16 24 -6 16 24 -6 20 24 -10 4 16 20 24 -10 16 24 -6 16 24 6 20 24 10 1 16 0 24 0 16 0 0 0 -20 0 0 0 6 box5.dat BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

  19. Putting it all together (cont.) • The second box5 makes up the outside: • The 2 stud.dat add the top studs and the stud3 adds the bottom stud: 1 16 0 24 0 20 0 0 0 -24 0 0 0 10 box5.dat 1 16 0 4 0 1 0 0 0 -5 0 0 0 1 stud3.dat 1 16 10 0 0 1 0 0 0 1 0 0 0 1 stud.dat 1 16 -10 0 0 1 0 0 0 1 0 0 0 1 stud.dat BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

  20. Additional Topics • BFC (Back Face Culling) Winding Standard • File specification originally did not define a standard polygon winding. • The BFC standard was introduced to uniformly wind the polygons in a parts file. This allows for culling of unseen faces and other functions tied to winding BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

  21. I’m Done. What Now? • Create a model with you part • Make sure it fits as it should • Examine you part from all angles and ensure there are no gaps and the lines are in the position • Ensure the all the quads/triangle are color 16 and line are color 24 except those that need to be hard coded a certain color (e.g. patterns) • Run you part through L3P with the –check option set or use LDDP’s error check function. • Submit your work to LDraw.org • The LDraw.org Contributor Agreement • Agreement is required if you want to submit your work to LDraw.org for inclusion in the Official Library • Basically licenses your part under the Creative Commons Attribution License BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

  22. Additional Topics • Additional rules for Official Parts • Essentially a more stringent set of rules applied to parts in consideration for the Official Library. • Examples include: • Proper part file headings • Part numbering and pattern codes • Actions for L3P –check errors • Part Origin requirements BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

  23. BFC • BFC (Back Face Culling) Winding Standard • Most standard 3D rendering engine require uniform winding of polygons • The LDraw file specification does not define a standard polygon winding. • The BFC standard was introduced to uniformly wind the polygons in a parts file. This allows for, amongst other functions, the culling of unseen polygon which leads to faster rendering times • While conforming to the BFC standard is not currently required for Official Library parts, it is highly encouraged. BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

  24. Resources and Conclusion • Many resources can be found on LDraw.org. • These include a primitive reference, color chart, the LDraw File Specification, and download link for many utilities. • Any questions? BrickFest 2005 is a production of AMH Events LLC, all rights reserved.

More Related