Homework2W14
Contents |
Homework Assignment 2: Packing 3D Tetris Blocks
For this assignment you can obtain 100 points, plus up to 10 points for extra credit.
This homework assignment is due on February 7th, 2014 at 1:30pm. Matteo is going to do a Q&A session on Wednesday, January 29th at 4pm in the computer lab.
The goal of this project is to create an application which uses the Razer Hydra to allow the user to pack a number of 3D tetris blocks as tightly as possible. Feel free to get inspiration from the image below, but know that the tetris blocks in it do not match those used in this project: [1]
In this project, only the following tetris blocks are valid:
The following two pictures illustrate the concept of putting a number of Tetris blocks together to form a tightly packed cube:
Razer Hydra
This homework assignment requires the use of a Razer Hydra input device. Every team is going to get to borrow one from the instructor until the end of the quarter.
To use the Hydra, you will need to first download the driver. If you use the lab computers the driver is already installed.
If the above driver doesn't work on your computer, you could try version 1.00.
There is even an open-source Linux driver for the Hydra.
The Hydra SDK can be downloaded through Steam, but it's much easier to just download it by its direct URL, which, thanks to Thinh and Arick is listed below for various operating systems:
Application (100 Points)
You need to write an application, which allows the user to tightly pack a number of 3D tetris blocks (the possible brick configurations are shown below).
Here is some starter code for this project.
Initially, all blocks are randomly distributed about the 3D space on the screen. The computer automatically calculates an axis-aligned, square bounding box around these blocks, and keeps it updated throughout the runtime of the application. The user should be able to grab and shift/rotate the world with one hand, and grab and move individual Tetris pieces with the other. The goal is to arrange the Tetris pieces in as tightly packed a cube as possible, so that the bounding box can shrink to as small a size as possible. There should be a timer to give the user 2 minutes for this task. The size of the bounding box at the end of the two minutes is the score. Lower scores are better.
Your application needs to have the following features. Each of them counts 10 points towards your score.
- Create at least two instances of each type of 3D Tetris block.
- Give each type of block a different color. If two blocks have the same exact shape, they should have the same color.
- Initially, all Tetris blocks need to get randomly distributed around the world.
- One of the Hydra controllers should be used to grab the world. The world includes all Tetris blocks, as well as the bounding box around them.
- The other Hydra controller should be used to select Tetris blocks and move them around the world. They should always remain axis-parallel and snap to an imaginary grid with a granularity of one box of the 4-box Tetris blocks.
- You need to implement a way to rotate the Tetris blocks.
- You need to implement simple collision detection to prevent the Tetris blocks from going through others.
- Update the bounding box every rendered frame. Show its size (length of one edge in atomic Tetris block units) on the screen.
- Implement a counter which counts down from 2 minutes to zero.
- Implement a function to reset the game (randomly redistribute the blocks) and the countdown timer.
Grading
On the due date, you will need to demonstrate your application with a Razer Hydra in the lab on a lab computer or your own laptop.
Extra Credit (10 Points)
You can implement one or both of the following features, but the maximum total amount of extra credit you can get is 10 points.
- Add a sky box, or another type of background to the game which is far enough away from the puzzle to never occlude it, but lends it visual pizzaz. You decide if it will rotate with the puzzle or not. (5 points)
- Add a two-player mode: each player gets one of the Hydra controllers to place blocks with. The world is rotated around its vertical axis by key presses: one player uses the z and x keys (for example), the other the cursor left/right keys. The screen is split side-by-side and the players play simultaneously. The initial blocks layout is the same for each player. (10 points)