#include <GL/glut.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <windows.h>
//#include "ReadBMP.h" 

typedef float vec3_t[3];

int		a;
int		mouseX = 0;
int		mouseY = 0;
int		mouseState = 0;
int		mouseButton = 0; 
int spin = 0;				// 라이트 객체를 회전할 각도
int rot = 0;				// 큐브 객체를 회전할 각도(8개 전체에 적용)
bool bCube[64] = {0};		// 회전될 큐브 객체선택 
int direct = 1;				// 회전 방향 선택
int r_x=0, r_y=0, r_z=0;	// 회전 축
int t_x=20, t_y=0, t_z=0;   // 시점 위치
char ob_ch = 0;		// 키 입력값

vec3_t rots = {0.,0.,0.}; 
vec3_t eye = {20.,0.,20.};
vec3_t center = {0.,0.,0.};

GLint		shape=1, model=2;
GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };	// 라이트  
GLfloat low_shininess[] = { 2.0 };		// 라이트

//-------------------------2x2큐브객체
GLfloat cube1[] = {-3.5, -3.5, -3.5};				// 큐브객체 1
GLfloat cube2[] = {-3.5, -3.5, 3.5};				// 큐브객체 2
GLfloat cube3[] = {-3.5, 3.5, -3.5};				// 큐브객체 3
GLfloat cube4[] = {-3.5, 3.5, 3.5};					// 큐브객체 4
GLfloat cube5[] = {3.5, -3.5, -3.5};				// 큐브객체 5
GLfloat cube6[] = {3.5, -3.5, 3.5};					// 큐브객체 6
GLfloat cube7[] = {3.5, 3.5, -3.5};					// 큐브객체 7
GLfloat cube8[] = {3.5, 3.5, 3.5};

//--------------------------3x3큐브 객체

GLfloat cube9[] = {3.5, 3.5, 0};
GLfloat cube10[] = {3.5, -3.5, 0};
GLfloat cube11[] = {-3.5, 3.5, 0};
GLfloat cube12[] = {-3.5, -3.5, 0};

//중앙 4개
GLfloat cube13[] = {0, 3.5, 3.5};
GLfloat cube14[] = {0, 3.5, -3.5};
GLfloat cube15[] = {0, -3.5, 3.5};
GLfloat cube16[] = {0, -3.5, -3.5};

//가로 4개
GLfloat cube17[] = {3.5, 0, 3.5};
GLfloat cube18[] = {3.5, 0, -3.5};
GLfloat cube19[] = {-3.5, 0, 3.5};
GLfloat cube20[] = {-3.5, 0, -3.5};

//중심 6개
GLfloat cube21[] = {3.5, 0, 0};
GLfloat cube22[] = {-3.5, 0, 0};
GLfloat cube23[] = {0, 3.5, 0};
GLfloat cube24[] = {0, -3.5, 0};
GLfloat cube25[] = {0, 0, 3.5};
GLfloat cube26[] = {0, 0, -3.5};
//------------------------------------------4x4큐브 객체

GLfloat cube27[] = {3.5, 1.2, 1.2};
GLfloat cube28[] = {3.5, -1.2, 1.2};
GLfloat cube29[] = {3.5, 1.2, -1.2};
GLfloat cube30[] = {3.5, -1.2, -1.2};

GLfloat cube31[] = {-3.5, 1.2, 1.2};
GLfloat cube32[] = {-3.5, -1.2, 1.2};
GLfloat cube33[] = {-3.5, 1.2, -1.2};
GLfloat cube34[] = {-3.5, -1.2, -1.2};

GLfloat cube35[] = {1.2, 3.5, 1.2};
GLfloat cube36[] = {-1.2, 3.5, 1.2};
GLfloat cube37[] = {1.2, 3.5, -1.2};
GLfloat cube38[] = {-1.2, 3.5, -1.2};

GLfloat cube39[] = {1.2, -3.5, 1.2};
GLfloat cube40[] = {-1.2, -3.5, 1.2};
GLfloat cube41[] = {1.2, -3.5, -1.2};
GLfloat cube42[] = {-1.2, -3.5, -1.2};

GLfloat cube43[] = {1.2, 1.2, 3.5};
GLfloat cube44[] = {-1.2, 1.2, 3.5};
GLfloat cube45[] = {1.2, -1.2, 3.5};
GLfloat cube46[] = {-1.2, -1.2, 3.5};

GLfloat cube47[] = {1.2, 1.2, -3.5};
GLfloat cube48[] = {-1.2, 1.2, -3.5};
GLfloat cube49[] = {1.2, -1.2, -3.5};
GLfloat cube50[] = {-1.2, -1.2, -3.5};

//---------

GLfloat cube51[] = {3.5, 3.5, 1.2};
GLfloat cube52[] = {3.5, 3.5, -1.2};
GLfloat cube53[] = {3.5, -3.5, 1.2};
GLfloat cube54[] = {3.5, -3.5, -1.2};

GLfloat cube55[] = {-3.5, 3.5, 1.2};
GLfloat cube56[] = {-3.5, 3.5, -1.2};
GLfloat cube57[] = {-3.5, -3.5, 1.2};
GLfloat cube58[] = {-3.5, -3.5, -1.2};

GLfloat cube59[] = {1.2, 3.5, 3.5};
GLfloat cube60[] = {-1.2, 3.5, 3.5};
GLfloat cube61[] = {1.2, -3.5, 3.5};
GLfloat cube62[] = {-1.2, -3.5, 3.5};

GLfloat cube63[] = {1.2, 3.5, -3.5};
GLfloat cube64[] = {-1.2, 3.5, -3.5};
GLfloat cube65[] = {1.2, -3.5, -3.5};
GLfloat cube66[] = {-1.2, -3.5, -3.5};

//--------------------

GLfloat cube67[] = {3.5, 1.2, 3.5};
GLfloat cube68[] = {3.5, -1.2, 3.5};
GLfloat cube69[] = {3.5, 1.2, -3.5};
GLfloat cube70[] = {3.5, -1.2, -3.5};

GLfloat cube71[] = {-3.5, 1.2, 3.5};
GLfloat cube72[] = {-3.5, -1.2, 3.5};
GLfloat cube73[] = {-3.5, 1.2, -3.5};
GLfloat cube74[] = {-3.5, -1.2, -3.5};



GLfloat position[] = { 0.0, 0.0, 7.0, 1.0 };		// 라이트 위치

// 큐브 객체 색지정을 위한 8가지 색
GLfloat cube_color[75][3] ={{0,0,0},{0,0,1},{0,1,0},{0,1,1},
							{1,0,0},{1,0,1},{1,1,0},{1,1,1},
							{0,0,0},{0,0,1},{0,1,0},{0,1,1},
							{1,0,0},{1,0,1},{1,1,0},{1,1,1},
							{0,0,0},{0,0,1},{0,1,0},{0,1,1},
							{1,0,0},{1,0,1},{1,1,0},{1,1,1},
							{0,0,0},{0,0,1},{0,1,0},{0,1,1},
							{1,0,0},{1,0,1},{1,1,0},{1,1,1},
							{0,0,0},{0,0,1},{0,1,0},{0,1,1},
							{1,0,0},{1,0,1},{1,1,0},{1,1,1},
							{0,0,0},{0,0,1},{0,1,0},{0,1,1},
							{1,0,0},{1,0,1},{1,1,0},{1,1,1}};
//MyImageStruct	myImage; 

int color_num[75] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,
					20,21,22,23,24,25,26,27,28,29,30,
					31,32,33,34,35,36,37,38,39,40,41,
					42,43,44,45,46,47,48,49,50,51,52,
					53,54,55,56,57,58,59,60,61,62,63,
					64,65,66,67,68,69,70,71,72,73,74};


void object_chang(char c);		// 객체 색 변경 모듈

void init(void)					
{
	glClearColor (0.0, 0.0, 1.0, 0.0);
	glShadeModel (GL_SMOOTH); 
	glEnable(GL_LIGHT0);		// 광원 사용
	glEnable(GL_DEPTH_TEST);	// 깊이 검사를 함(먼곳에 있는 객체는 가까운 객체에 가려짐)
	glEnable(GL_COLOR_MATERIAL);	// 객체의 칼라를 활성화
	glEnable(GL_TEXTURE_2D);
	glEnable(GL_DEPTH_TEST);
	glPolygonMode(GL_BACK, GL_LINE);
	glPolygonMode(GL_FRONT, GL_FILL);
}

void myDrow(void)
{
	if(model==1)
	{
		glPushMatrix();									// 큐브 객체 색 지정
			glColor3fv(cube_color[color_num[0]]);
			if(bCube[0])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);	// 큐브 객체 회전
			glTranslatef(cube1[0], cube1[1], cube1[2]);		// 큐브 객체 위치 지정
			glutSolidCube (5.0);							// 뷰브 생성
		glPopMatrix();
															// 이후 7개 객체 동일
		glPushMatrix();
			glColor3fv(cube_color[color_num[1]]);			
			if(bCube[1])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);		
			glTranslatef (cube2[0], cube2[1], cube2[2]);
			glutSolidCube (5.0);	
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[2]]);
			if(bCube[2])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube3[0], cube3[1], cube3[2]);
			glutSolidCube (5.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[3]]);
			if(bCube[3])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube4[0], cube4[1], cube4[2]);
			glutSolidCube (5.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[4]]);
			if(bCube[4])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube5[0], cube5[1], cube5[2]);
			glutSolidCube (5.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[5]]);
			if(bCube[5])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube6[0], cube6[1], cube6[2]);
			glutSolidCube (5.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[6]]);
			if(bCube[6])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube7[0], cube7[1], cube7[2]);
			glutSolidCube (5.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[7]]);
			if(bCube[7])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube8[0], cube8[1], cube8[2]);
			glutSolidCube (5.0);
		glPopMatrix();
		
	}
	else if(model==2)
	{
		glPushMatrix ();
			glRotated ((GLdouble) spin, 1.0, 1.0, 0.0);		
			glLightfv (GL_LIGHT0, GL_POSITION, position);	// 광원의 번호와 위치 배열 설정
			glTranslated (0.0, 0.0, 7.0);
			glColor3f (1.0, 1.0, 1.0);
			glScalef (1.0, 1.0, 2.0);	  
			glutWireCube (0.5);
			glEnable (GL_LIGHTING);
		glPopMatrix ();

		glPushMatrix();
			glColor3fv (cube_color[color_num[0]]);			// 큐브 객체 색 지정
			if(bCube[0])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);	// 큐브 객체 회전
			glTranslatef(cube1[0], cube1[1], cube1[2]);		// 큐브 객체 위치 지정
			glutSolidCube (3.0);							// 뷰브 생성
		glPopMatrix();	
															// 이후 7개 객체 동일
		glPushMatrix();
			glColor3fv(cube_color[color_num[1]]);
			if(bCube[1])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube2[0], cube2[1], cube2[2]);
			glutSolidCube (3.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[2]]);
			if(bCube[2])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube3[0], cube3[1], cube3[2]);
			glutSolidCube (3.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[3]]);
			if(bCube[3])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube4[0], cube4[1], cube4[2]);
			glutSolidCube (3.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[4]]);
			if(bCube[4])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube5[0], cube5[1], cube5[2]);
			glutSolidCube (3.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[5]]);
			if(bCube[5])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube6[0], cube6[1], cube6[2]);
			glutSolidCube (3.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[6]]);
			if(bCube[6])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube7[0], cube7[1], cube7[2]);
			glutSolidCube (3.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[7]]);
			if(bCube[7])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube8[0], cube8[1], cube8[2]);
			glutSolidCube (3.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[8]]);
			if(bCube[8])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube9[0], cube9[1], cube9[2]);
			glutSolidCube (3.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[9])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube10[0], cube10[1], cube10[2]);
			glutSolidCube (3.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[10]]);
			if(bCube[10])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube11[0], cube11[1], cube11[2]);
			glutSolidCube (3.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[11]]);
			if(bCube[11])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube12[0], cube12[1], cube12[2]);
			glutSolidCube (3.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[12]]);
			if(bCube[12])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube13[0], cube13[1], cube13[2]);
			glutSolidCube (3.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[13]]);
			if(bCube[13])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube14[0], cube14[1], cube14[2]);
			glutSolidCube (3.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[14]]);
			if(bCube[14])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube15[0], cube15[1], cube15[2]);
			glutSolidCube (3.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[15]]);
			if(bCube[15])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube16[0], cube16[1], cube16[2]);
			glutSolidCube (3.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[16]]);
			if(bCube[16])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube17[0], cube17[1], cube17[2]);
			glutSolidCube (3.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[17]]);
			if(bCube[17])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube18[0], cube18[1], cube18[2]);
			glutSolidCube (3.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[18]]);
			if(bCube[18])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube19[0], cube19[1], cube19[2]);
			glutSolidCube (3.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[19]]);
			if(bCube[19])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube20[0], cube20[1], cube20[2]);
			glutSolidCube (3.0);
		glPopMatrix();

			glPushMatrix();
			glColor3fv(cube_color[color_num[20]]);
			if(bCube[20])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube21[0], cube21[1], cube21[2]);
			glutSolidCube (3.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[21]]);
			if(bCube[21])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube22[0], cube22[1], cube22[2]);
			glutSolidCube (3.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[22]]);
			if(bCube[22])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube23[0], cube23[1], cube23[2]);
			glutSolidCube (3.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[23]]);
			if(bCube[23])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube24[0], cube24[1], cube24[2]);
			glutSolidCube (3.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[24]]);
			if(bCube[24])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube25[0], cube25[1], cube25[2]);
			glutSolidCube (3.0);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[25]]);
			if(bCube[25])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube26[0], cube26[1], cube26[2]);
			glutSolidCube (3.0);
		glPopMatrix();
			
		}
	
	else if(model==3)
	{
		glPushMatrix ();
			glRotated ((GLdouble) spin, 1.0, 1.0, 0.0);		
			glLightfv (GL_LIGHT0, GL_POSITION, position);	// 광원의 번호와 위치 배열 설정

			glTranslated (0.0, 0.0, 7.0);
			glColor3f (1.0, 1.0, 1.0);
			glScalef (1.0, 1.0, 2.0);	  
			glutWireCube (0.5);
			glEnable (GL_LIGHTING);
		glPopMatrix ();

		glPushMatrix();
			glColor3fv (cube_color[color_num[0]]);			// 큐브 객체 색 지정
			if(bCube[0])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);	// 큐브 객체 회전
			glTranslatef(cube1[0], cube1[1], cube1[2]);		// 큐브 객체 위치 지정
			glutSolidCube (1.75);							// 뷰브 생성
		glPopMatrix();	
															// 이후 7개 객체 동일
		glPushMatrix();
			glColor3fv(cube_color[color_num[1]]);
			if(bCube[1])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube2[0], cube2[1], cube2[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[2]]);
			if(bCube[2])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube3[0], cube3[1], cube3[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[3]]);
			if(bCube[3])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube4[0], cube4[1], cube4[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[4]]);
			if(bCube[4])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube5[0], cube5[1], cube5[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[5]]);
			if(bCube[5])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube6[0], cube6[1], cube6[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[6]]);
			if(bCube[6])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube7[0], cube7[1], cube7[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[7]]);
			if(bCube[7])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube8[0], cube8[1], cube8[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[8]]);
			if(bCube[27])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube27[0], cube27[1], cube27[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[28])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube28[0], cube28[1], cube28[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[29])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube29[0], cube29[1], cube29[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[30])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube30[0], cube30[1], cube30[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[31])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube31[0], cube31[1], cube31[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[32])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube32[0], cube32[1], cube32[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[33])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube33[0], cube33[1], cube33[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[34])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube34[0], cube34[1], cube34[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[35])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube35[0], cube35[1], cube35[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[36])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube36[0], cube36[1], cube36[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[37])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube37[0], cube37[1], cube37[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[38])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube38[0], cube38[1], cube38[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[39])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube39[0], cube39[1], cube39[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[40])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube40[0], cube40[1], cube40[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[41])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube41[0], cube41[1], cube41[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[42])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube42[0], cube42[1], cube42[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[43])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube43[0], cube43[1], cube43[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[44])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube44[0], cube44[1], cube44[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[45])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube45[0], cube45[1], cube45[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[46])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube46[0], cube46[1], cube46[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[47])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube47[0], cube47[1], cube47[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[48])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube48[0], cube48[1], cube48[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[49])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube49[0], cube49[1], cube49[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[50])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube50[0], cube50[1], cube50[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[51])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube51[0], cube51[1], cube51[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[52])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube52[0], cube52[1], cube52[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[53])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube53[0], cube53[1], cube53[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[54])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube54[0], cube54[1], cube54[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[55])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube55[0], cube55[1], cube55[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[56])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube56[0], cube56[1], cube56[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[57])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube57[0], cube57[1], cube57[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[58])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube58[0], cube58[1], cube58[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[59])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube59[0], cube59[1], cube59[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[60])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube60[0], cube60[1], cube60[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[61])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube61[0], cube61[1], cube61[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[62])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube62[0], cube62[1], cube62[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[63])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube63[0], cube63[1], cube63[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[64])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube64[0], cube64[1], cube64[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[65])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube65[0], cube65[1], cube65[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[66])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube66[0], cube66[1], cube66[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[67])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube67[0], cube67[1], cube67[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[68])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube68[0], cube68[1], cube68[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[69])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube69[0], cube69[1], cube69[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[70])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube70[0], cube70[1], cube70[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[71])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube71[0], cube71[1], cube71[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[72])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube72[0], cube72[1], cube72[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[73])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube73[0], cube73[1], cube73[2]);
			glutSolidCube (1.75);
		glPopMatrix();

		glPushMatrix();
			glColor3fv(cube_color[color_num[9]]);
			if(bCube[74])
				glRotated ((GLdouble) rot, r_x, r_y, r_z);
			glTranslatef (cube74[0], cube74[1], cube74[2]);
			glutSolidCube (1.75);
		glPopMatrix();	
		
	}
}	

void display(void)
{
	glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);		// 반사 효과
	glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess);	// 반사 효과	
	glPushMatrix ();
	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// 버퍼를 지운다.
	
	gluLookAt (t_x, t_y, t_z, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);	// 시점
	glLoadIdentity();
	
	gluLookAt(eye[0], eye[1], eye[2], center[0], center[1], center[2], 0, 1, 0);
	glRotatef(rots[0], 1.0f, 0.0f, 0.0f);
	glRotatef(rots[1], 0.0f, 1.0f, 0.0f);
	glRotatef(rots[2], 0.0f, 0.0f, 1.0f);
	myDrow();
	glPopMatrix ();
	glFlush ();		// 화면에 실제 출력	
	
}

void reshape (int w, int h)
{
	glViewport (0, 0, (GLsizei) w, (GLsizei) h); 
	glMatrixMode (GL_PROJECTION);
	glLoadIdentity ();
	glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 100.0);	// 깊이 100으로 지정
	glMatrixMode (GL_MODELVIEW);
}

void TimerFunc(int value)
 {							// 자동으로 돌아가는 애니메이션 적용
	if(value > 0){ 
		if(direct == 1)		rot = (rot + 10) % 360;	// 양의 방향으로 10도 증가
		else if(direct == 2) rot = (rot - 10) % 360;// 음의 방향으로 10도 증가
		glutPostRedisplay();						// 화면 재 출력
		glutTimerFunc(10, TimerFunc, value-1);		// 90도 회전까지 재 호출
	}else{
		object_chang(ob_ch);						// 실제 객체 색 변경
		rot = 0;									// 회전 각도를 0으로 초기화
	}
}
void myMouse(int btn, int state, int x, int y)
{
	if(btn==GLUT_LEFT_BUTTON && state == GLUT_DOWN) 
	{
		mouseState=state;
		mouseButton=btn;
		mouseX=x;
		mouseY=y; 
	}
	else if(btn==GLUT_LEFT_BUTTON && state == GLUT_UP)
		mouseState=-1;
	else return;
	glutPostRedisplay();
}

void myMotion(int x, int y)
{
	if(mouseButton == GLUT_LEFT_BUTTON && mouseState == GLUT_DOWN)
	{
		rots[1] -= (mouseX - x)/5.;
		rots[0] -= (mouseY - y)/5.;
		glutPostRedisplay();
		mouseX=x;
		mouseY=y;
	}
}

//void mouse(int button, int state, int x, int y)
//{
//	switch (button) {					// 마우스 좌,우 클릭으로 회전 방향 설정 
//		case GLUT_LEFT_BUTTON:
//			if(state == GLUT_DOWN) {
//				direct = 1;
//			}
//			break;
//		case GLUT_RIGHT_BUTTON:
//			if(state == GLUT_DOWN){
//				direct = 2;
//			}
//			break;
//		default:
//			break;
//	}
//}

void keyboard(unsigned char key, int x, int y)
{
	int i, direct = 1;
	ob_ch = key;			// 입력받은 키값 저장
	if(model==1)
	{
		switch (key) {
			case 'a' :							// 큐빅 좌측 부분 4개의 큐브 회전
				r_x = 0;
				r_y = 0;
				r_z = 1;
				for(i = 0; i < 8; i++){			// 큐빅 좌측 부분 선택
					if(i % 2) bCube[i] = true;	
					else bCube[i] = false;
				}
				break;
			case 'd' :							// 큐빅 우측 부분 4개의 큐브 회전
				r_x = 0; r_y = 0; r_z = 1;
				for(i = 0; i < 8; i++){
					if(i % 2) bCube[i] = false;
					else bCube[i] = true;
				}
				break;
			case 'z' :							// 큐빅 뒷부분 4개의 큐브 회전
				r_x = 1;
				r_y = 0;
				r_z = 0;
				for(i = 0; i < 8; i++){
					if(i < 4) bCube[i] = true;
					else bCube[i] = false;
				}
				break;
			case 'x' :							// 큐빅 앞부분 4개의 큐브 회전
				r_x = 1;
				r_y = 0;
				r_z = 0;
				for(i = 0; i < 8; i++){
					if(i < 4) bCube[i] = false;
					else bCube[i] = true;
				}
				break;
			case 'w' :							// 큐빅 윗부분 4개의 큐브 회전
				r_x = 0;
				r_y = 1;
				r_z = 0;
				for(i = 0; i < 8; i++){
					if(i % 4 < 2) bCube[i] = false;
					else bCube[i] = true;
				}
				break;
			case 's' :							// 큐빅 아래부분 4개의 큐브 회전
				r_x = 0; r_y = 1; r_z = 0;
				for(i = 0; i < 8; i++){
					if(i % 4 < 2) bCube[i] = true;
					else bCube[i] = false;
				}
				break;
			case '[' :							// 큐빅 세로 방향 전체 회전
				r_x = 0;
				r_y = 0;
				r_z = 1;
				for(i = 0; i < 8; i++) bCube[i] = true;
				break;
			case ']' :							// 큐빅 가로 방향 전체 회전
				r_x = 0;
				r_y = 1;
				r_z = 0;
				for(i = 0; i < 8; i++) bCube[i] = true;
				break;
			default :
				direct = 0;		
		}
	}
	else if(model==2){
		switch (key){ 
			case '7' :							// 큐빅 좌측 부분 9개의 큐브 회전
				r_x = 0;
				r_y = 0;
				r_z = 1;
				for(i = 0; i < 26; i++){			// 큐빅 좌측 부분 선택		
					if(i == 1 || i== 3 || i == 5 || i== 7 || i == 12 || i== 14 || i == 16 || i== 18 || i == 24) 
						bCube[i] = true;	
					else 
						bCube[i] = false;
				}
				break;
			case '9' :							// 큐빅 우측 부분 9개의 큐브 회전
				r_x = 0;
				r_y = 0;
				r_z = -1;
				for(i = 0; i < 26; i++){
					if(i == 0 || i== 2 || i == 4 || i== 6 || i == 13 || i== 15 || i == 17 || i== 19 || i == 25)  
						bCube[i] = true;
					else 
						bCube[i] = false;
				}
				break;
			case '6' :							// 큐빅 뒷부분 9개의 큐브 회전
				r_x = -1;
				r_y = 0;
				r_z = 0;
				for(i = 0; i < 26; i++){
					if(i == 0 || i== 1 || i == 2 || i== 3 || i == 10 || i== 11 || i == 18 || i== 19 || i == 21) 
						bCube[i] = true;
					else  
						bCube[i] = false;
				}
				break; 
			case '3' :							// 큐빅 앞부분 9개의 큐브 회전
				r_x = 1;
				r_y = 0;
				r_z = 0;
				for(i = 0; i < 26; i++){
					if(i ==  4 || i== 5 || i == 6 || i== 7 || i == 8 || i== 9 || i == 16 || i== 17 || i == 20) 
						bCube[i] = true;
					else 
						bCube[i] = false;
				}
				break;
			case '4' :							// 큐빅 윗부분 9개의 큐브 회전
				r_x = 0;
				r_y = 1;
				r_z = 0;
				for(i = 0; i < 26; i++){
					if(i == 2 || i== 3 || i == 6 || i== 7 || i == 8 || i== 10 || i == 12 || i== 13 || i == 22) 
						bCube[i] = true;
					else
						bCube[i] = false;
				}
				break;
			case '1' :							// 큐빅 아래부분 9개의 큐브 회전
				r_x = 0; r_y = 1; r_z = 0;
				for(i = 0; i < 26; i++){
					if(i == 0 || i== 1 || i == 4 || i== 5 || i == 9 || i== 11 || i == 14 || i== 15 || i == 23) 
						bCube[i] = true;
					else
						bCube[i] = false;
				}
				break;
			case '[' :							// 큐빅 세로 방향 전체 회전
				r_x = 0; 
				r_y = 0; 
				r_z = 1;
				for(i = 0; i < 26; i++) 
					bCube[i] = true;
				break;
			case ']' :							// 큐빅 가로 방향 전체 회전
				r_x = 0;
				r_y = 1;
				r_z = 0;
				for(i = 0; i < 26; i++) 
					bCube[i] = true;
				break;
			case 'q' :							// 라이트 회전
				spin = (spin + 10) % 360;
				for(i = 0; i < 26; i++) 
					bCube[i] = false;
				direct = 0;
				glutPostRedisplay();
				break;
			case 'e' :							// 라이트 회전
				spin = (spin - 10) % 360;
				for(i = 0; i < 26; i++) 
					bCube[i] = false;
				direct = 0;
				glutPostRedisplay();
				break;
			case 27:							// 종료
				exit(0);
				break;
			default :
				direct = 0;		
		}
	}
	else if(model==3)
	{
	}
	if(direct == 1 || direct == 2){
		glutTimerFunc(10, TimerFunc,9); // 속도 조절...
	}

}

void object_chang(char c){				// 객체 색 변경
	double temp, tempo, tempul;
	double temp1, tempo1, tempul1;
	if(direct == 1){
		if(model==1)
		{
			switch(c){
			case 'a' :
				temp = color_num[7];
				color_num[7] = color_num[5];
				color_num[5] = color_num[1];
				color_num[1] = color_num[3];
				color_num[3] = temp;
				break;
			case 'd' :
				temp = color_num[6];
				color_num[6] = color_num[4]; 
				color_num[4] = color_num[0];
				color_num[0] = color_num[2];
				color_num[2] = temp;
				break;
			case 'z' :
				temp = color_num[2];
				color_num[2] = color_num[0];
				color_num[0] = color_num[1];
				color_num[1] = color_num[3];
				color_num[3] = temp;
				break;
			case 'x' :
				temp = color_num[7];
				color_num[7] = color_num[6];
				color_num[6] = color_num[4];
				color_num[4] = color_num[5];
				color_num[5] = temp;
				break;
			case 's' :
				temp = color_num[5];
				color_num[5] = color_num[1];
				color_num[1] = color_num[0];
				color_num[0] = color_num[4];
				color_num[4] = temp;
				break;
			case 'w' :
				temp = color_num[7];
				color_num[7] = color_num[3];
				color_num[3] = color_num[2];
				color_num[2] = color_num[6];
				color_num[6] = temp;
				break;
			case '[' :
				temp = color_num[7];
				color_num[7] = color_num[5];
				color_num[5] = color_num[1];
				color_num[1] = color_num[3];
				color_num[3] = temp;
				temp = color_num[6];
				color_num[6] = color_num[4]; 
				color_num[4] = color_num[0];
				color_num[0] = color_num[2];
				color_num[2] = temp;
				break;
			case ']' :
				temp = color_num[7];
				color_num[7] = color_num[3];
				color_num[3] = color_num[2];
				color_num[2] = color_num[6];
				color_num[6] = temp;
				temp = color_num[5];
				color_num[5] = color_num[1];
				color_num[1] = color_num[0];
				color_num[0] = color_num[4];
				color_num[4] = temp;
				break;
			default :
				break;
			}
		}
		else if(model==2)
		{
		switch(c){
			case '7' :
				tempul = color_num[3];
				color_num[3] = color_num[7];
				color_num[7] = color_num[5];
				color_num[5] = color_num[1];
				color_num[1] = tempul;
				tempo = color_num[12];
				color_num[12] = color_num[16];
				color_num[16] = color_num[14];
				color_num[14] = color_num[18];
				color_num[18] = tempo; 
				break;
			case '9' :
				temp1 = color_num[6];
				color_num[6] = color_num[2];
				color_num[2] = color_num[0];
				color_num[0] = color_num[4];
				color_num[4] = temp1;
				tempo1 = color_num[15];
				color_num[15] = color_num[17];
				color_num[17] = color_num[13];
				color_num[13] = color_num[19];
				color_num[19] = tempo1;
				break;
			case '6' :
				tempul = color_num[2];
				color_num[2] = color_num[3];
				color_num[3] = color_num[1];
				color_num[1] = color_num[0];
				color_num[0] = tempul;
				tempo = color_num[10];
				color_num[10] = color_num[18];
				color_num[18] = color_num[11];
				color_num[11] = color_num[19];
				color_num[19] = tempo;
				break;
			case '3' :
				temp1 = color_num[7];
				color_num[7] = color_num[6];
				color_num[6] = color_num[4];
				color_num[4] = color_num[5];
				color_num[5] = temp1;
				tempo1 = color_num[8];
				color_num[8] = color_num[17];
				color_num[17] = color_num[9];
				color_num[19] = color_num[16];
				color_num[16] = tempo1;
				break;
			case '4' :
				tempul = color_num[6];
				color_num[6] = color_num[7];
				color_num[7] = color_num[3];
				color_num[3] = color_num[2];
				color_num[2] = tempul;
				tempo = color_num[8];
				color_num[8] = color_num[12];
				color_num[12] = color_num[10];
				color_num[10] = color_num[13];
				color_num[13] = tempo;
				break;
			case '1' :
				tempul = color_num[1];
				color_num[1] = color_num[0];
				color_num[0] = color_num[4];
				color_num[4] = color_num[5];
				color_num[5] = tempul;
				tempo = color_num[11];
				color_num[11] = color_num[15];
				color_num[15] = color_num[9];
				color_num[9] = color_num[14];
				color_num[14] = tempo;
				break;
		/*	case '[' :
				temp = color_num[7];
				color_num[7] = color_num[5];
				color_num[5] = color_num[1];
				color_num[1] = color_num[3];
				color_num[3] = temp;
				temp = color_num[6];
				color_num[6] = color_num[4]; 
				color_num[4] = color_num[0];
				color_num[0] = color_num[2];
				color_num[2] = temp;
				temp = color_num[6];
				color_num[6] = color_num[4]; 
				color_num[4] = color_num[0];
				color_num[0] = color_num[2];
				color_num[2] = temp;
				temp = color_num[7];
				color_num[7] = color_num[5];
				color_num[5] = color_num[1];
				color_num[1] = color_num[3];
				color_num[3] = temp;
				temp = color_num[6];
				color_num[6] = color_num[4]; 
				color_num[4] = color_num[0];
				color_num[0] = color_num[2];
				color_num[2] = temp;
				temp = color_num[6];
				color_num[6] = color_num[4]; 
				color_num[4] = color_num[0];
				color_num[0] = color_num[2];
				color_num[2] = temp;
				break;
			case ']' :
				temp = color_num[7];
				color_num[7] = color_num[3];
				color_num[3] = color_num[2];
				color_num[2] = color_num[6];
				color_num[6] = temp;
				temp = color_num[5];
				color_num[5] = color_num[1];
				color_num[1] = color_num[0];
				color_num[0] = color_num[4];
				color_num[4] = temp;
				break;*/
		
			}
		}
	}
}

void myMenu(int id)
{
	if(id == 4) exit(1);
	else model = id;
	glutPostRedisplay();
}

int main(int argc, char** argv)
{
	glutInit(&argc, argv); 
	glutInitDisplayMode (GLUT_RGB | GLUT_SINGLE );
	glutInitWindowSize (500, 500); 
	glutInitWindowPosition (100, 100);
	glutCreateWindow ("CUBIC");
	init ();
	glutDisplayFunc(display); 
	glutReshapeFunc(reshape);
	glutMouseFunc(myMouse);
	glutMotionFunc(myMotion);
	glutCreateMenu(myMenu);
	glutAddMenuEntry("2 X 2 Cubic", 1);
	glutAddMenuEntry("3 X 3 Cubic", 2);
	glutAddMenuEntry("4 X 4 Cubic", 3);
	glutAddMenuEntry("Quit", 4);
	glutAttachMenu(GLUT_RIGHT_BUTTON);
	glutKeyboardFunc(keyboard);
	glutMainLoop();
	return 0;
}


