Thursday 2 October 2014

Rubik's cube

RUBIK’S CUBE
Introduction
In a classic Rubik’s cube, each six faces is covered by nine stickers,each one of six colours
(white, red ,blue, pink, green, yellow). There are total 18 possible moves in particular
state of cube.
Software requirement
·         Microssft visual studio 2008
·         Opengl library
·         GLUT library function
Input
·         (x , y , z)(1 , 2, 3) – selecting and rotating blocks in particular axis
·         Up-arrow and right-arrow key – seeing the current state of different faces.
Implementation
User defined point data structure for element square.
Important Variables
Description
Point ax array
ax holds all the co-ordinate points for element square along x axis.
Point ay array
ay holds all the co-ordinate points for element square along y axis.
Point az array
az holds all the co-ordinate points for element square along z axis.

Char commandline[5]
Holds the value of keys that are pressed.

Int selected_ax, selected_ay, selected_az
Holds the index of selected of selected element square.

Important functions
Description
Void initial()
Initializes data in ax,ay,az array
Void colcube()
Yhis function is used to render complete rubik cube on the screen.
Void display()
This is registered function for opengl used for rendering graphics on the screen,
Colcube() is called here.
Axes are rendered here.
Void rotate_selected(int axs)
Animates and rotate the selected cube about particular axis.
Void select_cube(int axs, int select)
Selects the cube that is to be roataed.
Index of the selected element square are saved in selected_ax,  selected_ay, selected_ay array.
Void process_input()
Processes commandline input.
Void keys(unsigned char key,int x,int y)
Registered method to take alpha-numeric input from the keyboard.
Void skeys(unsigned char key,int x,int y)
Registered method to take special input like
(up-arrow,down-arrow) from the keyboard.
Void myreshape(int w,int h)
Adjust the rendering when window size changes.
Int main()
Initialize opengl,display mode,window size,
Register callback functions.

Referencces
Interactive computer graphics – A top down approach with OpenGl

                                                -Edward Angel,5th edition,Addison-Wesley-2009



SNAPSHOT








No comments:

Post a Comment