Intro Graphics Assignment 4

Rubik's Cube
Due: Friday, 27 October 2006 by 5:00:00 a.m.


Overview

In this project, you will simulate the behavior of one of the most popular hand held puzzles of all time.  This is not a group assignment!

Getting Started

We have provided a couple of useful C++ classes to parse command line arguments and to query a high resolution timer for rate control.  There is also a little main function that shows you how to use the parser and the timer.  The main function is already set up to parse the required command line arguments for your assignment.

The skeleton is here.

A solution to this assignment is here (windows) (and you will also need glut32.dll if it's not already installed)

How Your Program Should Work

The following features are required of your simulator:

  1. The cube should be drawn in 3D using perspective

  2. The cube should start in a "solved" state

  3. The user should be able to auto-scramble the cube

  4. The solution to a scrambled cube should be animated and "rate controlled"

  5. The user should be able to specify the "dicing" of the cube --- it should not be restricted to 3x3x3

  6. The user should be able to rotate the entire cube with the mouse (even while it is animating).

If you don't know how to solve a Rubiks cube (or ones with more little cubies), don't worry, all you have to do is remember the sequence of moves you used to scramble it, and undo them.  That's very hard for a human, but not much work for a computer.

Rate Control

The turns of your cube faces should be rate controlled.  That means that it always takes the same amount of time for a face to complete a turn, regardless of the speed of the computer you're running on.  To do this, you will need to use an "idle" callback function that checks the current time and sets a turn angle for the currently turning face.

Manipulation

The mouse manipulation doesn't have to be as sophisticated as the one in the sample solution.  It's enough just to rotate the cube around one of its axes as the mouse is moved around with a button down.  Just make sure that the animation keeps going while the rotation happens.

Extra credit

The sample solution is a little nuts.  Here are some things it supports:

  1. Textured cube faces.  We will provide 54 textures (9 of each color), scanned from an original Rubiks Cube.  Place these randomly on the individual faces.  Be careful that the textures don't flip or rotate when the cube rotates.  The textures are available below.

  2. Arcball based manipulation of the cube.  This is an intuitive 3D manipulator based on Ken Shoemake's graphics gem.  See here for more information.

  3. Predefined patterns.  The user can specify (either in the command line or in a file) a set of moves to be applied to the outer faces of a solved cube, and the program will animate those moves.  The moves are specified in a semi-standard notation used to describe Rubiks Cube patterns.

  4. Cube dumps.  The user can dump the current state of the cube on the screen to a file and re-load that configuration later.

  5. Full solution algorithm.  The program can solve an arbitrary Rubiks Cube using a real solution algorithm (not by undoing moves).  There are many such algorithms available online.

You could also try to implement other sequential movement puzzle types (Skewb, Square-1, Pyraminx, Siamese cube, Rubiks Snake, etc.)

Using the sample solution

The sample solution supports several command line arguments.  Some of them are required of your submission; those are shown in red.

In addition, you can press a few keys in the window:

Textures

Enclosed in the zip file below are 54 textures, which are scans of the individual cube faces from my Rubiks cube.

Each texture is 256x256, and is in "RAW" format, meaning that there is absolutely NO header information in the file, and no compression.  The file is simply raw image data, with 8 bits per color channel.  Each pixel is contiguous, so the first three bytes of the file represent the color of the first pixel in the image, and so on.

To use these textures in the sample implementation, uncompress them to a directory called "images", and run the sample program from its parent directory.  Alternately, you can set the RUBIKS_IMAGES environment variable to point to the full path of the "images" directory you just created, and run the binary from anywhere.

Rubiks textures

Submission

You should create a web page with:

Submit hw4.zip when finished.