CPE -471 Final Project:

Lego Simulation

Mike Cook 6/6/06

The Lego simulator allows you to go back to your childhood and play with the good ole big lego blocks. No odd sizes, no missing pieces, just good quality fun. This 3d enviroment allows you to build whatever you like with unlimited blocks, save your progress, and in general have a good time.

Description

The Lego Simulator allows freedom of design to the user. Every item has a material, lighing is enabled, and each surface has a proper normal. A ghost block appears on the screen allowing the user to see where a block is going to land before placing it. If you make a mistake, a simple undo function allows you to make changes. A user can build thier own world to their liking with an array of colors, shapes and sizes of both block and board. The user controls the placement of the block on the X-Z plane. The y value of the proposed block position is calculated automatically with respect to gravity and the blocks beneith the current position.

Controls

Q for quit.

H for help.

W,A,S,D control movement of the block: Any rotations of the board or camera do not effect the keyboard controls.

SpaceBar places the block in the current location.

Mouse control is also enabled: The block follows movement of the mouse in the x-z plane. Calculations are provided to maintain proper mouse functionality so that board size, board rotation, camera zoom, and look angle do not effect the mouse gestures. Motion is limited to the constraints of the board. Simply left click to place a block.

Features

The right click menu provides an array of features.

Blocks (ghost image) will never exceed the bounds on the board.

If a current position is already occuped by a block, a pink ghost image will appear.

This condition is very rare as automatic Y detection accounts for most possibilities.

Block size can be altered: 1x1 2x2 2x4 2x6 and 2x8

Blocks can be rotated 90 degrees.

Block colors: Red, Green, Blue, Yellow

Mouse can be disabled if you wish to utilize only the keyboard for more precise block placement.

Board colors: Red, Green, Blue

Board size: 10x10 20x20 30x30

If a blocks are placed on a 20x20 board that a 10x10 board cannot support, change will not be allowed

Board can be rotated with infinite bounds.

Look angle can be changed from side vew to overhead or anywhere inbetween. Limits are provided.

Camera can be zoomed in and out. Limits are provided.

User at any time can save the project to disk.

User can restore from disk at any time as well. If the user has already placed blocks, no blocks will be erased, the restored image will be added to the current project.

The undo function undoes the previous block placement (if any), including any objects loaded from file.

The program can be closed and reopened after saving to disk, the data is not dependent on the executable.

Structures

This program utilizes two main data structures.

An STL vector stores all blocks.

A matrix of floats keeps track of the maximum y value for a given point in the x-z plane.

Links

I utilized no outside resources in the creation of this project. All code was written by myself with no guides, no downloaded textures, etc.

My Email

Inspiration of this project came from a previous implementation.

Click here to download the executable (Glut must be installed on your system).