LEGO Builder

Alex Rudd

Csc 471 - Winter 2007

Dr. Wood Cal Poly San Luis Obispo

 

 

My project was to create an interactive LEGO building simulation in which the user could set blocks on a 3D plane to create a simple model. Originally the goal was to create a collection of blocks modeled after the blocks required to build an actual LEGO model and have the user be able to “flip” through the manual and build an actual model, but as I began to work on the project I realized that even the simplest, non-trivial official LEGO model has roughly 20-30 distinct pieces, and I would not have enough time to individually model all of these. This project came together rather well overall, and adding the custom model building aspects are still a goal of mine that I will have to work on more in the future.

 

 

Controls:

 

The program has several controls, in the GLUT main window the user can right-click and select from a range of actions to perform, their details are outlined below:

 

Block Width – Sets the width of the current block (in the x direction)

Block Length – Sets the Length of the current block (in the z direction)

Block Color – Sets the color of the block to be placed (defaults to Blue)

Rotate Block – Rotates the block by 90°

Base Color – Changes the color of the base (Defaults to Green)

Base Size – Change the base size to 10x10, 20x20, or 30x30

·         (Note if you place blocks outside of the allowable range for a smaller board, you cannot reduce the size of the board until clearing all bricks.)

Clear – removes all of the blocks from the simulation

Undo – Removes the most recently placed block from the board

 

The program also has controls in a right-hand sub window using the GLUI libraries, which contains all of the controls outlined above, as well as rotation and translation controls for the board itself. Usage of these additional controls is outlined below:

·         View Trackball – Simply click down on the ball and move your mouse while holding the left-click button to rotate the model about its center.

1.      To restrict rotation to the X axis hold the ALT key while dragging the mouse

2.      To restrict rotation to the Y axis hold the CTRL key while dragging the mouse

·         Board Translation (XY) – Again, click down on the button and drag your mouse while holding the left-click button to move the board around

3.      To restrict movement to the X direction, hold the ALT key and click the X component of the button only before dragging

4.      To restrict movement to the Y direction, hold the ALT key and click the Y component of the button only before dragging

·         Board Translation (Z) – The same as the XY translation, except you cannot restrict the translation because there is only one plane

·         Reset Button – This will reset all model transforms so the board returns to its default position for the current base size.

 

Keyboard Controls allow the user to interact with the block and display information about the environment.

·         WASD keys  - control the movement of the block (Remember that this movement is always relative to the original axes, so after several rotations the direction in which the blocks move can become disorienting.)

·         Space Bar – Places a block at the current position.

·         h – displays a help list of other keyboard commands, most of these are of a debugging nature, but if you want to see them you can.

 

 

Project Specifics:

 

The blocks are assembled in a rather complex hierarchical modeling fashion; each block is composed of 4 distinct pieces, some of which are repeated at regular intervals. (The bumps on the top)

A diagram of the block composition is pictured below:

 

Figure 1: How a block is born

 

 

The blocks are stored in a STL Vector so that the user can add as many blocks as they like and they will continue to be drawn on the screen. The heights are determined by a  matrix of integers, each index represents the minimum height that a block can have on that particular point and is maintained when a block is added or removed.

 

Inspiration for the project came from two past projects on Csc 471 and a lifelong obsession with LEGOs. Links to their websites are below:

Spring 2006 – Mike Cook

Winter 2004 – Mike Wilson

 

Screenshots:

 

 

 

 

Download the executable: Lego Builder

(Note that you may have to have the glut32.dll installed on your system)