Interactive Rubiks Cube
Interactive Rubiks Cube written in OpenGL.
HERE IS THE CODE
1 Project Summary
1. The Rubik’s Cube (27 individual cubes has been drawn on the screen)
2. The entire Rubik’s cube can be easily rotated
3. The user can select any of the 9 faces of the cube and rotate that face in
any direction
4. A timer has been implemented that starts at 0:00
5. Texture mapping has been added to each cube face
6. Texture mapping has been added to the background
7. Two light sources have been placed at infinity, the properties of the light
have been set
8. The material properties of the cube have been set
9. Shading has been implemented by using the normal from each cube face.
2 Directions
2.1 Rotate the Cube
1. CLICK and DRAG with mouse button. The Rubik’s cube rotates on the
screen
Implementation: The cube appears to rotate around a fixed axis.
In the actual implementation, the observer is moved in a spherical shape
around the origin. To the user, the cube appears to be rotating because
the background always remains fixed.
2.2 Rotate a Face
- PRESS any number from 1-9. Select the appropriate number that corresponds to the face you desire to rotate
- PRESS ENTER to rotate the face in the positive direction OR PRESS - SPACE BAR to rotate the cube in the opposite direction
Implementation: A single set of curved arrows was written. The
set of arrows is rotated and translated into the appropriate position. The
arrows are drawn using line loops and a triangle. Also the coordinates
are fixed in space and appear to be rotating because the observes position
moves in a spherical shape. The 9 cubes that make up the face are rotated
by directly manipulating their homogeneous coordinates, see below.
2.3 Change the Cube’s Texture
1. PRESS ’t’ for texture - This changes the surface of every face in the rubiks
cube to be one of 3 different textures.
2.4 Change Background
1. PRESS ’b’ for background - This changes the background to be one of
three different bitmap images.
2.5 Randomize
1. PRESS ’r’ - 20 random faces are rotated.
Implementation: The program randomly chooses on of the 9 possible
faces to rotate and a random direction. By calling RCube.MakeMove(move,
direction); twenty times.
2.6 Rotation Reversal
- PRESS ’s’ for solve. This simple reverses all previous moves. It wouldbe interesting to incorporate an algorithm quickly solves the cube in the fewest number of moves.
- PRESS ’u’ for undo. This undoes the previous move.
Screen Shot
