#include <math.h>
#include <stdio.h>
#include <windows.h>
#include <gl/glut.h>
#include <gl/glaux.h>
#include "glm.h"
#include <windows.h>

#define DEGINRAD 3.14/180

float	anitheta=.0;
float	anithetaDelta=.125;
GLUquadricObj *c;

typedef float vec3_t[3]; 
void tree();//나무 함수 
void tree2();//나무2 함수 
void circle(float s);
void Street1();//도로 함수
void human(); //사람
void bench();
void ballon();
void human1(); //피티피플
void io(); //중앙
void io1();//중앙1
void dog(); //개
void cage(); //동물농장??
void bench1();
void bench2();
void dog1();
void human3();
void human4();
int interval = 0;
int doga1=0;
int doga2=0;
int doga3=0;
vec3_t cube[] = {	
	{-1,-1,-1},	
	{-1,1,-1},
	{1,1,-1},	
	{1,-1,-1},
	{1,1,1},
	{1,1,-1},
	{-1,1,-1},
	{-1,1,1},	
	{1,-1,1},
	{-1,-1,1},	
	{-1,-1,-1},
	{1,-1,-1},	
	{-1,1,1},
	{-1,1,-1},
	{-1,-1,-1},	
	{-1,-1,1},
 	{1,1,1},
	{1,-1,1},
	{1,-1,-1},
	{1,1,-1},	
	{-1,-1,1},
	{1,-1,1},
	{1,1,1},
	{-1,1,1}    
};
vec3_t color[] = {
	{1.0f, 0.0f, 0.0f},		//red
	{0.0f, 1.0f, 0.0f},		//green
	{0.0f, 0.0f, 1.0f},		//blue
	{1.0f, 1.0f, 0.0f},		//yellow
	{1.0f, 0.0f, 1.0f},		//magenta
	{0.0f, 1.0f, 1.0f},		//cyan
	{1.0f, 1.0f, 1.0f},		//white
	{.25f, .25f, .25f},		//dark gray
	{.60f, .40f, .70f},		//barney purple
	{.98f, .625f, .12f},		//pumpkin orange
	{.98f, .04f, .70f},		//pastel pink
	{.75f, .75f, .75f},		//light gray
	{.60f, .40f, .12f},		//brown
	{0.5f, 1.0f, 0.7f}	     ///grass
};
vec3_t rot = {0.,0.,0.}; 
vec3_t eye = {0.,0.,-5}; 
vec3_t center = {0.,0.,0.};

//시점 조절 관련 변수
vec3_t veye    = {0.,0.,0.}; 
vec3_t vcenter = {0.,0.,0.};
vec3_t vvecter = {0.,0.,1.};

int v_mode=0;
int	magminfilter = 1;
float	size=3.;
float	theta=.0;
float	thetaDelta=.05;
float	eyeDelta=.125;
float	scale=0.3;
float	scaleDelta=1.125;
float   delt=0;
float	anitheta7 = -25.; //열기구 움직임

GLfloat	xTheta=0., yTheta=0., zTheta=0.; //사람 움직임

int     speed = 0;
int		mouseX = 0;
int		mouseY = 0;
int		mouseState = 0;
int		mouseButton = 0; 
int		projection = 0;
int		aniOn = 0;
int		depthOn = 1;
int		openOn = 0;
int		fillOn = 0;
int		windowWidth, windowHeight;
float   pi = 3.14;


int ballonT=0;
GLfloat ballonTurn=180;

int check1 = 0;
int mancheck = 0; // 사람
int		check3 = 0;//도로
int		check4 = 0;//도로2
int check5 = 0;
int interval2=0;


GLMmodel *hmodel[10] = 
{
	glmReadOBJ("data/boat.obj"),
	glmReadOBJ("data/나무1.obj"),
	glmReadOBJ("data/나무2.obj"),
	glmReadOBJ("data/가로등.obj"),
	glmReadOBJ("data/버스.obj"),
	glmReadOBJ("data/기둥축.obj"),
	glmReadOBJ("data/웨곤.obj"),
	glmReadOBJ("data/차.obj"),
	glmReadOBJ("data/픽업트럭.obj")
};//한번 호출해서 뿌려줌 
//예전 방법은 GLMmodel *hmodel = NULL 으로 작성해서 OBJ을 계속 호출
//해서 메모리에 계속 누적이 됨 

float	d_height=.001;
float	d_aniheight=.125;
float	d_theta=.0;
float	d_deltatheta=.05;
float   man = 0;
float   xtheta=0;


/////////사람/////////
GLfloat xRot = 0.0f; //키보드의 방향키 사용으로 시점변환 
GLfloat yRot = 0.0f;
static GLfloat left_arm_up=-45, left_arm_down=0, left_arm_left; //회전을 위한 변수들.
static GLfloat right_arm_up=45, right_arm_down=0, right_arm_right;
static GLfloat left_leg_up=45, left_leg_down=0;
static GLfloat right_leg_up=-45, right_leg_down=0;

static GLfloat left_arm_up1=0, left_arm_down1=0, left_arm_left1; //회전을 위한 변수들.
static GLfloat right_arm_up1=0, right_arm_down1=0, right_arm_right1;
static GLfloat left_leg_up1=0, left_leg_down1=0;
static GLfloat right_leg_up1=0, right_leg_down1=0;

static GLfloat left_arm_up3=0, left_arm_down3=0, left_arm_left3; //회전을 위한 변수들.
static GLfloat right_arm_up3=0, right_arm_down3=0, right_arm_right3;
static GLfloat left_leg_up3=0, left_leg_down3=0;
static GLfloat right_leg_up3=0, right_leg_down3=0;

static GLfloat left_arm_up4=0, left_arm_down4=0, left_arm_left4; //회전을 위한 변수들.
static GLfloat right_arm_up4=0, right_arm_down4=0, right_arm_right4;
static GLfloat left_leg_up4=0, left_leg_down4=0;
static GLfloat right_leg_up4=0, right_leg_down4=0;


static const GLfloat flag1=45;
static const GLfloat flag2=-45;
static const GLfloat flag3=170;
static const GLfloat flag4=0;
static const GLfloat flag6=15;
static const GLfloat flag7=0;
static const GLfloat man1=0;
GLfloat ballon1 = 0;
GLfloat ballon2 = 0;
int iman=0;
float jump=0; //피티
float dogjump=0;
GLfloat dogjump1=0;
GLfloat dogjump2=0;
GLfloat kick1=0;
GLfloat kick2=0;
GLfloat ballk=0;
int ballk1=0;
int kickc1=0;
int kickc2=0;
int kickc3=0;
int kickc4=0;
int dog4=0;
int dog2=0;
int dog3=0;

float d1=0;

void myDisplay (void) 
{
	char *name = 0;
	glClear(GL_COLOR_BUFFER_BIT | 					GL_DEPTH_BUFFER_BIT);
	glMatrixMode(GL_MODELVIEW);    
	glLoadIdentity();
	
	if(!v_mode)//일반모드
	{
		//7.33,7.6,-1
	gluLookAt(eye[0], eye[1], eye[2], center[0],center[1],center[2], 0, 1, 0);	
		glRotatef(rot[0], 1.0f, 0.0f, 0.0f);
		glRotatef(rot[1], 0.0f, 1.0f, 0.0f);
		glRotatef(rot[2], 0.0f, 0.0f, 1.0f);
		glScalef(scale, scale, scale);
		glRotatef(-90., 1., 0., 0.);	
	}

	else //시점 모드 
		gluLookAt(veye[0],veye[1],veye[2],vcenter[0],vcenter[1], vcenter[2],vvecter[0],vvecter[1],vvecter[2]);

/////////도로 부분1////////////////////////
	glPushMatrix();
		glRotatef(90, 0,0,1);
		glTranslatef(-2,-5,-0.8);
		Street1();
	glPopMatrix(); 

	/////////도로 부분2////////////////////////
	glPushMatrix();
		glRotatef(0, 0,0,1);
		glTranslatef(-2,-5,-0.8);
		Street1();
	glPopMatrix(); 

	/////////도로 부분3////////////////////////
	glPushMatrix();
		glRotatef(180, 0,0,1);
		glTranslatef(-2,-5,-0.8);
		Street1();
	glPopMatrix(); 
	/////////도로 부분4////////////////////////
	glPushMatrix();
		glRotatef(270, 0,0,1);
		glTranslatef(-2,-5,-0.8);
		Street1();
	glPopMatrix(); 

 //////////////열기구/////////////
 	
	glPushMatrix();
		if(ballonT==1)
		{
		
			glRotatef(ballon1, 0,0, 1);
		
			glTranslatef(8,0,10);
		
			glColor3fv(color[0]);
			glRotatef(ballonTurn,0,0,1);
		}
		else
		{
			glRotatef(ballon1, 0,0, 1);
			
		
			glTranslatef(8,0,10);
		
			glColor3fv(color[0]);
			glRotatef(ballonTurn,0,0,1);
		}
		ballon();
	glPopMatrix();
 //////////////////////////////////



	/////////////길 위에 걷는 사람///////////
	glPushMatrix();
		glColor3fv(color[2]);
		glTranslatef(15.5,0.19,0);
		glTranslatef(0,15.5,0);
		glPushMatrix();
			glRotatef(90,0,0,1);
			glTranslatef(0,man,0);
			glPushMatrix();
				glRotatef(man1,0,0,1);
				human();
			glPopMatrix();	
		glPopMatrix();	
	glPopMatrix();
	glPushMatrix();
		glColor3fv(color[2]);
		glTranslatef(-15.5,0.19,0);
		glTranslatef(0,-15.5,0);
		glPushMatrix();
			glRotatef(90,0,0,1);
			glTranslatef(0,-man,0);
			glPushMatrix();
				glRotatef(man1,0,0,1);
				human();
			glPopMatrix();
		glPopMatrix();	
	glPopMatrix();
	glPushMatrix();
		glColor3fv(color[2]);
		glRotatef(90,0,0,1);
		glTranslatef(15.5,0.19,0);
		glTranslatef(0,15.5,0);
		glPushMatrix();
			glRotatef(90,0,0,1);
			glTranslatef(0,man,0);
			glPushMatrix();
				glRotatef(man1,0,0,1);
				human();
			glPopMatrix();
		glPopMatrix();	
	glPopMatrix();
	glPushMatrix();
		glColor3fv(color[2]);
		glRotatef(90,0,0,1);
		glTranslatef(-15.5,0.19,0);
		glTranslatef(0,-15.5,0);
		glPushMatrix();
			glRotatef(90,0,0,1);
			glRotatef(man1,0,0,1);
			glTranslatef(0,-man,0);
			human();				
		glPopMatrix();	
	glPopMatrix();
	//////////////////////////////////

	///////// 의자////////////////////
	
	glPushMatrix();
		glTranslatef(-14.,-12,-2.29);
		bench2();
	glPopMatrix();
	glPushMatrix();
		glTranslatef(-14.,-6,-2.29);
		bench1();
	glPopMatrix();
	glPushMatrix();
		glTranslatef(-14.,0,-2.29);
		bench();
	glPopMatrix();
	glPushMatrix();
		glTranslatef(-14.,6,-2.29);
		bench();
	glPopMatrix();
	glPushMatrix();
		glTranslatef(-14.,12,-2.29);
		bench();
	glPopMatrix();
	glPushMatrix();
		glTranslatef(-14.,-12,-2.29);
		bench();
	glPopMatrix();

	glPushMatrix();
		glRotatef(90,0,0,1);
		glTranslatef(-14.,-12,-2.29);
		bench1();
	glPopMatrix();
		
	glPushMatrix();
		glRotatef(90,0,0,1);
		glTranslatef(-14.,-6,-2.29);
		bench();
	glPopMatrix();

	glPushMatrix();
		glRotatef(90,0,0,1);
		glTranslatef(-14.,0,-2.29);
		bench();
	glPopMatrix();

	glPushMatrix();
		glRotatef(90,0,0,1);
		glTranslatef(-14.,6,-2.29);
		bench2();
	glPopMatrix();

	glPushMatrix();
		glRotatef(90,0,0,1);
		glTranslatef(-14.,12,-2.29);
		bench();
	glPopMatrix();
	///////////////////////////
	
	////////바닥///////////
	glPushMatrix();
		glColor3fv(color[13]);
		glScalef(1.3,1.3,0.01);
		glTranslatef(0.,0,-280);
		glutWireCube(22);
	glPopMatrix();
	/////////////////
	///////////중앙 나무
	for(int i=-3;i<=3;i++)
	{
		glPushMatrix();
			glTranslatef(i,4,-3.0);
			glScalef(1,1,2);
			tree();
		glPopMatrix();
	}
	for(int i=-3;i<=3;i++)
	{
		glPushMatrix();
			glTranslatef(i,-4,-3.0);
			glScalef(1,1,2);
			tree();
		glPopMatrix();
	}

	for(int i=-3;i<=3;i++)
	{
		glPushMatrix();
			glTranslatef(-4,i,-3.0);
			glScalef(1,1,2);
			tree();
		glPopMatrix();
	}

	//
	//////////////길쪽/////////나무///////////////// 이 코드를 복원하면 너무 느려집니다
	//for(int i=-16;i<17;i++)
	//{
	//	glPushMatrix();
	//		glTranslatef(i,16.5,-3.0);
	//		glScalef(1,1,2);
	//		tree();
	//	glPopMatrix();
	//}
	//for(int i=-16;i<17;i++)
	//{
	//	glPushMatrix();
	//		glTranslatef(i,-16.5,-3.0);
	//		glScalef(1,1,2);
	//		tree();
	//	glPopMatrix();
	//}
	//for(int i=-16;i<17;i++)
	//{
	//	glPushMatrix();
	//		glTranslatef(16.5,i,-3.0);
	//		glScalef(1,1,2);
	//		tree();
	//	glPopMatrix();
	//}
	//for(int i=-16;i<17;i++)
	//{
	//	glPushMatrix();
	//		glTranslatef(-16.5,i,-3.0);
	//		glScalef(1,1,2);
	//		tree();
	//	glPopMatrix();
	//}
	///////////////////////////////////////
	
//////////////////////////피티
	glPushMatrix();
		glColor3fv(color[8]);
		glTranslatef(9.5,4,0.5);
		human1();
	glPopMatrix();
	glPushMatrix();
		glTranslatef(10,9,0);
		for(double j=-3;j<3;j++){
			for(double i=-3;i<3;i+=1){
				glPushMatrix();
					glColor3fv(color[9]);
					glTranslatef(j,i,0.5);
					//glTranslatef(0,0,jump);
					human1();
				glPopMatrix();
			}
		}
	glPopMatrix();
	
	
	
	//glPushMatrix();
	//	glutSolidSphere(0.5,10,8); //머리
	//glPopMatrix();
	//glPushMatrix();
	//	glTranslatef(0,0,-2.5);
	//	glScalef(1,1,4);
	//	glutSolidCube(1); //몸
	//glPopMatrix();
	//glPushMatrix();
	//	glRotatef(45,1,0,0);
	//	glTranslatef(0.8,0,-2.65);
	//	
	//	
	//	glScalef(0.4,0.4,4);
	//		
	//	glutSolidCube(1); //팔
	//glPopMatrix();
	//glPushMatrix();
	///*	glRotatef(arm,0,1,0);*/	
	//	glTranslatef(-0.8,0,-2.65);
	//	glScalef(0.4,0.4,4);
	//	glutSolidCube(1); //팔
	//glPopMatrix();
	//glPushMatrix();
	//	glTranslatef(-0.3,0,-6.3);

	//	glScalef(0.4,0.4,4);
	//	glutSolidCube(1); //다리
	//glPopMatrix();	
	//glPushMatrix();
	//	glTranslatef(0.3,0,-6.3);
	//	glScalef(0.4,0.4,4);
	//	glutSolidCube(1); //다리
	//glPopMatrix();	
			
		//glScalef(0.4,0.4,1);
		//glTranslatef(1.9,0,-0.05);
		//glPushMatrix();
		//	glRotatef(45,0,1,0);
		//	glutWireCube(1);
		//glPopMatrix();
		//glTranslatef(-3.8,0,0);
		//glutWireCube(1);
		//glScalef(1,1,0.9);
		//glTranslatef(1.3,0,-0.98);
		//glutWireCube(1);
		//glTranslatef(1.1,0,0);
		//glutWireCube(1);





	/////////중앙 건물
	glPushMatrix();
		glTranslatef(0,0,-2.7);
		glScalef(3., 3., 3.);
		io1();
	glPopMatrix();
/////////////////////////////
	////////////////////cage
	glPushMatrix();
		glTranslatef(-9,0,0);
		glScalef(0.8,0.8,0.8);
		cage();
	glPopMatrix();

	///////////////
	glPushMatrix();
		glColor3fv(color[7]);
		glRotatef(90,0,0,1);
		glScalef(1.1,11.5,0.2);
		glTranslatef(0,-0.85,-14);
		glutSolidCube(1);
	glPopMatrix();
//	
	/////////////개/////////////
	glPushMatrix();
		glScalef(0.7,0.7,0.7);
		glTranslatef(-11,-5,-1.2);
		glRotatef(45,0,0,1);
		
		dog1();
	glPopMatrix();
	glPushMatrix();
		glScalef(0.7,0.7,0.7);
		glTranslatef(-9,-1,-1.2);
		glRotatef(170,0,0,1);
		dog();
	glPopMatrix();
	glPushMatrix();
		glScalef(0.7,0.7,0.7);
		glTranslatef(-13,0,-1.2);
		glTranslatef(0,0,0);
		
		dog();
	glPopMatrix();
	glPushMatrix();
	
		glScalef(0.7,0.7,0.7);
		glTranslatef(-15.5,5,-1.2);
		glRotatef(180,0,0,1);
		glTranslatef(0,0,d1-0.5);
		dog();
	glPopMatrix();
	glPushMatrix();
		glScalef(0.7,0.7,0.7);
		glTranslatef(-15,-15,-1.2);
		glTranslatef(0,0,d1-0.5);
		dog1();
	glPopMatrix();
	/////////////////////////////
	//////벤치주변 개
	if(doga1==1){
		glPushMatrix();
			glScalef(0.7,0.7,0.7);
			glTranslatef(-6,-19.0,-1.2);
			glRotatef(-90,0,0,1);
			glTranslatef(0,0,d1-0.5);
			glRotatef(dogjump1,0,0,1);
			dog1();
		glPopMatrix();
	}
	if(doga2==1){
		glPushMatrix();
			glScalef(0.7,0.7,0.7);
		
			glTranslatef(-11.5,-20.0,-1.2);
		
			glRotatef(-90,0,0,1);
			glTranslatef(0,0,d1-0.5);
			/*glTranslatef(0,-3,0);*/
		
			glRotatef(dogjump1,0,0,1);
		
			dog1();
		glPopMatrix();
	}
	if(doga3==1){
		glPushMatrix();
			glScalef(0.7,0.7,0.7);
		
			glTranslatef(-8,-23.0,-1.2);
		
			glRotatef(-90,0,0,1);
			glTranslatef(0,0,d1-0.5);
			/*glTranslatef(0,-3,0);*/
		
			glRotatef(dogjump1,0,0,1);
		
			dog1();
		glPopMatrix();
	}
	///////////
	///////////////족구장!!!!?????????????
	glPushMatrix();
		glPushMatrix();
			glScalef(7,10,0.2);
			glTranslatef(1.35,-0.7,-13);
			glutWireCube(1);
			glPushMatrix();
				glTranslatef(0,0,3);
				glScalef(1,1,5);
				glutWireCube(1);
				glScalef(1,0.01,1);
				glutWireCube(1);
			glPopMatrix();
			glScalef(0.9,0.9,0.9);
			glColor3f(0,0.8,0);
			glutSolidCube(1);
		glPopMatrix();
		glColor3fv(color[5]);
		glTranslatef(9.5,-3,0.2);
		human3();
		glRotatef(270,1,0,0);
		glTranslatef(0,-8,2);
		glColor3fv(color[6]);
		human4();
		glColor3f(1,0,0);
		glTranslatef(0,0,-4);
		glRotatef(ballk,1,0,0);
		glTranslatef(0,0,-3.5);
		
		glutSolidSphere(0.2,10,8);
		
	glPopMatrix();
	///////////////
	

	glFlush();
//	glutSwapBuffers();
}
void human3(){
	glRotatef(90, 1.0, 0.0, 0.0);
	glTranslatef(0,-1.7,0);
	GLUquadricObj *obj; //gluCylinder 함수를 사용하기 위한 설정 
	obj = gluNewQuadric();
	glutSolidSphere(0.1,10,8);
	glTranslatef(0.0,-0.2,0.0);
	glutSolidCube(0.2);
	glTranslatef(0.0,-0.2,0.0);
	glutSolidCube(0.2);
	glPushMatrix(); //머리, 몸통
		glTranslatef(-0.15,0.25,0.0);
		glRotatef(-left_arm_up3,0.0,0.0,1.0);/////////////////////////////
		glRotatef(-left_arm_left3,0.0,0.0,1.0); 
		glutSolidSphere(0.04,10,8);
		glRotatef(90,0.1,0.0,0.0);
		gluCylinder(obj, 0.05, 0.05,0.15,3,3); //왼쪽 팔 위
		glPushMatrix();
			glTranslatef(0.0,0.0,0.15);
			glRotatef(left_arm_down3,1.0,0.0,0.0);
			glutWireSphere(0.04,10,8);
			gluCylinder(obj, 0.05, 0.05,0.3,3,3); //왼쪽 팔 아래
		glPopMatrix();
	glPopMatrix();
	glPushMatrix(); 
		glTranslatef(0.15,0.25,0.0);
		glRotatef(right_arm_up3,0.0,0.0,1.0);////////////////////
		glRotatef(right_arm_right3,0.0,0.0,1.0);
		glutSolidSphere(0.04,10,8);
		glRotatef(90,0.1,0.0,0.0);
		gluCylinder(obj, 0.05, 0.05,0.15,3,3); //오른쪽 팔 위 
		glPushMatrix();
			glTranslatef(0.0,0.0,0.15);
			glRotatef(right_arm_down3,1.0,0.0,0.0);
			glutSolidSphere(0.04,10,8);
			gluCylinder(obj, 0.05, 0.05,0.3,3,3); //오른쪽 팔 아래
		glPopMatrix();
	glPopMatrix();
	glPushMatrix(); 
		glTranslatef(-0.07,-0.1,0.0);
		glRotatef(-left_leg_up3,0.0,0.0,1.0);
		glutSolidSphere(0.04,10,8);
		glRotatef(90,0.1,0.0,0.0);
		gluCylinder(obj, 0.06, 0.06,0.25,5,5); //왼쪽 다리 위 
		glPushMatrix();
			glTranslatef(0.0,0.0,0.25);
			glRotatef(-left_leg_down3,1.0,0.0,0.0);
			glutSolidSphere(0.04,10,8);
			gluCylinder(obj, 0.06, 0.06,0.3,5,5); //왼쪽 다리 아래
		glPopMatrix();
	glPopMatrix();
	glPushMatrix(); 
		glTranslatef(0.07,-0.1,0.0);
		glRotatef(right_leg_up3,1.0,0.0,0.0);
		glutSolidSphere(0.04,10,8);
		glRotatef(90,0.1,0.0,0.0);
		gluCylinder(obj, 0.06, 0.06,0.25,5,5); //오른쪽 다리 위 
		glPushMatrix();
			glTranslatef(0.0,0.0,0.25);
			glRotatef(-right_leg_down3,1.0,0.0,0.0);
			glutSolidSphere(0.04,10,8);
			gluCylinder(obj, 0.06, 0.06,0.3,5,5); //오른쪽 다리 아래
		glPopMatrix();
	glPopMatrix();
}
void human4(){
	glRotatef(90, 1.0, 0.0, 0.0);
	glTranslatef(0,-1.7,0);
	GLUquadricObj *obj; //gluCylinder 함수를 사용하기 위한 설정 
	obj = gluNewQuadric();
	glutSolidSphere(0.1,10,8);
	glTranslatef(0.0,-0.2,0.0);
	glutSolidCube(0.2);
	glTranslatef(0.0,-0.2,0.0);
	glutSolidCube(0.2);
	glPushMatrix(); //머리, 몸통
		glTranslatef(-0.15,0.25,0.0);
		glRotatef(-left_arm_up4,0.0,0.0,1.0);/////////////////////////////
		glRotatef(-left_arm_left4,0.0,0.0,1.0); 
		glutSolidSphere(0.04,10,8);
		glRotatef(90,0.1,0.0,0.0);
		gluCylinder(obj, 0.05, 0.05,0.15,3,3); //왼쪽 팔 위
		glPushMatrix();
			glTranslatef(0.0,0.0,0.15);
			glRotatef(left_arm_down4,1.0,0.0,0.0);
			glutWireSphere(0.04,10,8);
			gluCylinder(obj, 0.05, 0.05,0.3,3,3); //왼쪽 팔 아래
		glPopMatrix();
	glPopMatrix();
	glPushMatrix(); 
		glTranslatef(0.15,0.25,0.0);
		glRotatef(right_arm_up4,0.0,0.0,1.0);////////////////////
		glRotatef(right_arm_right4,0.0,0.0,1.0);
		glutSolidSphere(0.04,10,8);
		glRotatef(90,0.1,0.0,0.0);
		gluCylinder(obj, 0.05, 0.05,0.15,3,3); //오른쪽 팔 위 
		glPushMatrix();
			glTranslatef(0.0,0.0,0.15);
			glRotatef(right_arm_down4,1.0,0.0,0.0);
			glutSolidSphere(0.04,10,8);
			gluCylinder(obj, 0.05, 0.05,0.3,3,3); //오른쪽 팔 아래
		glPopMatrix();
	glPopMatrix();
	glPushMatrix(); 
		glTranslatef(-0.07,-0.1,0.0);
		glRotatef(-left_leg_up4,0.0,0.0,1.0);
		glutSolidSphere(0.04,10,8);
		glRotatef(90,0.1,0.0,0.0);
		gluCylinder(obj, 0.06, 0.06,0.25,5,5); //왼쪽 다리 위 
		glPushMatrix();
			glTranslatef(0.0,0.0,0.25);
			glRotatef(-left_leg_down4,1.0,0.0,0.0);
			glutSolidSphere(0.04,10,8);
			gluCylinder(obj, 0.06, 0.06,0.3,5,5); //왼쪽 다리 아래
		glPopMatrix();
	glPopMatrix();
	glPushMatrix(); 
		glTranslatef(0.07,-0.1,0.0);
		glRotatef(right_leg_up4,1.0,0.0,0.0);
		glutSolidSphere(0.04,10,8);
		glRotatef(90,0.1,0.0,0.0);
		gluCylinder(obj, 0.06, 0.06,0.25,5,5); //오른쪽 다리 위 
		glPushMatrix();
			glTranslatef(0.0,0.0,0.25);
			glRotatef(-right_leg_down4,1.0,0.0,0.0);
			glutSolidSphere(0.04,10,8);
			gluCylinder(obj, 0.06, 0.06,0.3,5,5); //오른쪽 다리 아래
		glPopMatrix();
	glPopMatrix();
}
void myIdle()
{
	interval++;
	/////////////////////////신출귀몰한 개///////////////////

	if(interval%20==0 || interval%20==1)
	{
		doga1=1;
	}
	else
		doga1=0;
	if(interval%30==0 || interval%30==1)
	{
		doga2=1;
	}
	else
		doga2=0;
	if(interval%50==0 || interval%50==1)
	{
		doga3=1;
	}
	else
		doga3=0;

	////////////////////////
	////////////////////////////족구장????/////////////////////
	
	if(kickc3==1)
	{
		ballk+=30;
		if(ballk>=180)
		{
			ballk=180;
			kickc3=0;
		}
	}
	if(kickc4==1)
	{
		ballk-=30;
		if(ballk<=0)
		{
			ballk=0;
			kickc4=0;
		}
	}

	if(kickc1==1)
	{
		right_leg_up3=-45;
		if(interval%30==0)
		{	
			right_leg_up3=0;
			kickc1=0;
		}
	}
	else
	{
		right_leg_up3=0;
		if(interval%30==0)
		{
			right_leg_up3=0;
			kickc1=0;
		}
	}
	if(kickc2==1)
	{
		right_leg_up4=45;

		if(interval%30==0)
		{	
			right_leg_up4=0;
			kickc2=0;
		}
	}
	else
	{
		right_leg_up4=0;
		if(interval%30==0)
		{
			right_leg_up4=0;
			kickc2=0;
		}
	}
	/////////////////////////////////////////
	dogjump1+=10;
	dogjump2+=1;
	////개 점프
	if(dog2==0)
	{
		d1+=0.5;
		if(d1>=1)
			dog2=1;
	}
	else
	{
		d1-=0.5;
		if(d1<=1)
			dog2=0;
	}

	/////////////
	///////걷는사람
	if(check1 ==0)
	{
		left_arm_up+=1;  
		right_arm_up-=1;
		left_leg_up-=1;
		right_leg_up+=1;
		if(left_arm_up>=flag1){
			check1=1;
		
		}
	}
	else if(check1==1)
	{
		left_arm_up-=1; 
		right_arm_up+=1;
		left_leg_up+=1;
		right_leg_up-=1;
		if(left_arm_up<=flag2)
			check1=0;
	}
	if(man<=31)
	{
		man+=0.01;
		

	}
	else
		man=0;
	/////////////
	
			/////////피티피플///////////
	
	if(iman==0)
	{
		if(check1 ==0)
		{

			left_arm_up1+=1; 
			right_arm_up1+=1;
			left_leg_up1+=0.2;
			right_leg_up1+=0.2;
			//jump+=0.001;
			if(right_leg_up1>34)
			{
				
				left_arm_up1=170;  
				right_arm_up1=170;
				left_leg_up1=34;
				right_leg_up1=34;
				
				check1=1;
			}
		}
		else if(check1==1)
		{
			left_arm_up1-=1; 
			right_arm_up1-=1;
			left_leg_up1-=0.2;
			right_leg_up1-=0.2;
		/*	jump-=0.001;*/
			if(right_leg_up1<0)
			{
				
				left_arm_up1=0;  
				right_arm_up1=0; 
				left_leg_up1=0;
				right_leg_up1=0;
				
				check1=0;
			}
		}
	}
	else
	{
			left_arm_up1=0; 
			right_arm_up1=0;
			left_leg_up1=0;
			right_leg_up1=0;
			/*jump=0;*/
			check1=0;

	}


	///////////////////

	//////////////풍선
	
	
	if(ballonT==1)
	{
		ballonTurn=180;
		ballon1+=0.1;
	}
	else
	{
		ballonTurn=0;
		ballon1-=0.1;
	}
	////////////////////
	
	glutSwapBuffers();
	glutPostRedisplay();

}
void cage()
{
	glPushMatrix();
		glColor3fv(color[8]);
		glTranslatef(0,0,-2.9);
		glScalef(8,29,0.8);
		glutWireCube(1);
		//glColor3f(0,0.7,0);
		//glTranslatef(0,0,-0.3);
		//glScalef(1,1,0.1);
		//glutSolidCube(1);
	glPopMatrix();




}
void dog()
{	
	glScalef(0.5, 0.5, 0.5);
	glTranslatef(0,0,-4.2);
	glColor3fv(color[11]);
	/////////////몸
	glPushMatrix();
		glScalef(1,1.8,0.8);
		glTranslatef(0,-0.2,0);
		glutWireCube(1);
		
	glPopMatrix();
	////////////
	///////////목
	glPushMatrix();
		glScalef(0.6,0.7,0.6);
		glRotatef(45,1,0,0);
		glTranslatef(0,1,0);
		glutWireCube(1);
	glPopMatrix();
	//////////////
	///////////머리
	glPushMatrix();
		glScalef(0.8,1.3,0.8);
		glRotatef(-12,1,0,0);
		glTranslatef(0,0.9,1.3);
		glutWireCube(1);
	glPopMatrix();
	//////////////
	///////////귀////////////////
	glPushMatrix();
		glRotatef(-7,0,1,0);
		glScalef(0.1,0.5,1.1);
		glTranslatef(5,2.3,0.6);
		glutWireCube(1);
	glPopMatrix();
	glPushMatrix();
		glRotatef(7,0,1,0);
		glScalef(0.1,0.5,1.1);
		glTranslatef(-5,2.3,0.6);
		glutWireCube(1);
	glPopMatrix();
		/////////////////////
	//////////////
	///////// 입
	//glPushMatrix();
	//	glScalef(0.65,0.65,0.65);
	//	glRotatef(-7,1,0,0);
	//	glTranslatef(0,3,1.7);
	//	glutWireCube(1);
	//glPopMatrix();
	///////////////////
	////////////////////앞다리
	glPushMatrix();
		glPushMatrix();
			glScalef(0.3,0.3,1.2);
			glTranslatef(1.15,0.7,-0.3);
			glutWireCube(1);
		glPopMatrix();
		glPushMatrix();
			glScalef(0.4,0.4,0.15);
			glTranslatef(0.9,0.65,-6.5);
			glutWireCube(1);
		glPopMatrix();
		glPushMatrix();
			glScalef(0.3,0.3,1.2);
			glTranslatef(-1.15,0.7,-0.3);
			glutWireCube(1);
		glPopMatrix();
		glPushMatrix();
			glScalef(0.4,0.4,0.15);
			glTranslatef(-0.9,0.65,-6.5);
			glutWireCube(1);
		glPopMatrix();
	glPopMatrix();
	/////////////////////
	/////////////뒷다리
		glPushMatrix();
		glPushMatrix();
			glScalef(0.3,0.3,1.2);
			glTranslatef(1.15,-3,-0.3);
			glutWireCube(1);
		glPopMatrix();
		glPushMatrix();
			glScalef(0.4,0.4,0.15);
			glTranslatef(0.9,-2.15,-6.5);
			glutWireCube(1);
		glPopMatrix();
		glPushMatrix();
			glScalef(0.3,0.3,1.2);
			glTranslatef(-1.15,-3,-0.3);
			glutWireCube(1);
		glPopMatrix();
		glPushMatrix();
			glScalef(0.4,0.4,0.15);
			glTranslatef(-0.9,-2.15,-6.5);
			glutWireCube(1);
		glPopMatrix();
	glPopMatrix();

	///////////////



	////////////////////

	
}
void dog1()
{	
	glScalef(0.5, 0.5, 0.5);
	glTranslatef(0,0,-4.2);
	glColor3fv(color[8]);
	/////////////몸
	glPushMatrix();
		glScalef(1,1.8,0.8);
		glTranslatef(0,-0.2,0);
		glutWireCube(1);
		
	glPopMatrix();
	////////////
	///////////목
	glPushMatrix();
		glScalef(0.6,0.7,0.6);
		glRotatef(45,1,0,0);
		glTranslatef(0,1,0);
		glutWireCube(1);
	glPopMatrix();
	//////////////
	///////////머리
	glPushMatrix();
		glScalef(0.8,1.3,0.8);
		glRotatef(-12,1,0,0);
		glTranslatef(0,0.9,1.3);
		glutWireCube(1);
	glPopMatrix();
	//////////////
	///////////귀////////////////
	glPushMatrix();
		glRotatef(-7,0,1,0);
		glScalef(0.1,0.5,1.1);
		glTranslatef(5,2.3,0.6);
		glutWireCube(1);
	glPopMatrix();
	glPushMatrix();
		glRotatef(7,0,1,0);
		glScalef(0.1,0.5,1.1);
		glTranslatef(-5,2.3,0.6);
		glutWireCube(1);
	glPopMatrix();
		/////////////////////
	//////////////
	///////// 입
	//glPushMatrix();
	//	glScalef(0.65,0.65,0.65);
	//	glRotatef(-7,1,0,0);
	//	glTranslatef(0,3,1.7);
	//	glutWireCube(1);
	//glPopMatrix();
	///////////////////
	////////////////////앞다리
	glPushMatrix();
		glPushMatrix();
			glScalef(0.3,0.3,1.2);
			glTranslatef(1.15,0.7,-0.3);
			glutWireCube(1);
		glPopMatrix();
		glPushMatrix();
			glScalef(0.4,0.4,0.15);
			glTranslatef(0.9,0.65,-6.5);
			glutWireCube(1);
		glPopMatrix();
		glPushMatrix();
			glScalef(0.3,0.3,1.2);
			glTranslatef(-1.15,0.7,-0.3);
			glutWireCube(1);
		glPopMatrix();
		glPushMatrix();
			glScalef(0.4,0.4,0.15);
			glTranslatef(-0.9,0.65,-6.5);
			glutWireCube(1);
		glPopMatrix();
	glPopMatrix();
	/////////////////////
	/////////////뒷다리
		glPushMatrix();
		glPushMatrix();
			glScalef(0.3,0.3,1.2);
			glTranslatef(1.15,-3,-0.3);
			glutWireCube(1);
		glPopMatrix();
		glPushMatrix();
			glScalef(0.4,0.4,0.15);
			glTranslatef(0.9,-2.15,-6.5);
			glutWireCube(1);
		glPopMatrix();
		glPushMatrix();
			glScalef(0.3,0.3,1.2);
			glTranslatef(-1.15,-3,-0.3);
			glutWireCube(1);
		glPopMatrix();
		glPushMatrix();
			glScalef(0.4,0.4,0.15);
			glTranslatef(-0.9,-2.15,-6.5);
			glutWireCube(1);
		glPopMatrix();
	glPopMatrix();

	///////////////



	////////////////////

	
}
void io1()
{	
	glPushMatrix();
		glPushMatrix();
			glScalef(3., 3., .1);
			glColor3fv(color[0]);
			 glutWireCube(1.0);
			 glColor3fv(color[2]);
			 glutSolidCube(0.9);
		glPopMatrix();
		glPushMatrix();
			glPushMatrix();
				glColor3f(0,0.5,0);
				glScalef(1.,1., 2);
				gluCylinder(c, 1., 1., .5, 120, 10);
			glPopMatrix();
			glPushMatrix();
				glColor3fv(color[3]);
				glTranslatef(0., 0., 1.01);
				glPushMatrix();
					glScalef(0.8,0.8, 1.5);
					gluCylinder(c, 1., 1., .5, 120, 10);
				glPopMatrix();
				glColor3fv(color[4]);
				glTranslatef(0., 0., 0.72);
				glPushMatrix();
					glScalef(0.7,0.7, 1.3);
					gluCylinder(c, 1., 1., .5, 120, 10);
				glPopMatrix();
				glColor3fv(color[5]);
				glTranslatef(0., 0., 0.67);
				glPushMatrix();
					glScalef(0.6,0.6, 1.1);
					gluCylinder(c, 1., 1., .5, 120, 10);
				glPopMatrix();
				glColor3fv(color[6]);
				glTranslatef(0., 0., 0.58);
				glPushMatrix();
					glScalef(0.5,0.5, 0.9);
					gluCylinder(c, 1., 1., .5, 120, 10);
				glPopMatrix();
				glColor3fv(color[7]);
				glTranslatef(0., 0., 0.48);
				glPushMatrix();
					glScalef(0.4,0.4, 0.7);
					gluCylinder(c, 1., 1., .5, 120, 10);
				glPopMatrix();
				glColor3fv(color[8]);
				glTranslatef(0., 0., 0.4);
				glPushMatrix();
					glScalef(1,1, 0.06);
					glutSolidCube(1.05);
				glPopMatrix();
			glPopMatrix();

			//glPushMatrix();
			//	glColor3fv(color[3]);
			//	glTranslatef(0., 0., 1.01);
			//	glScalef(0.8,0.8, 1.5);
			//	gluCylinder(c, 1., 1., .5, 120, 10);
			//glPopMatrix();
			//glPushMatrix();
			//	glColor3fv(color[3]);
			//	glTranslatef(0., 0., 1.01);
			//	glScalef(0.8,0.8, 1.5);
			//	gluCylinder(c, 1., 1., .5, 120, 10);
			//glPopMatrix();
			//glPushMatrix();
			//	glColor3fv(color[3]);
			//	glTranslatef(0., 0., 1.01);
			//	glScalef(0.8,0.8, 1.5);
			//	gluCylinder(c, 1., 1., .5, 120, 10);
			//glPopMatrix();

			glPushMatrix();
				
				
			glPopMatrix();
		glPopMatrix();




	glPopMatrix();
}
void io()
{
	glPushMatrix();


		glPushMatrix();
			glScalef(3., 3., .1);
			glColor3fv(color[0]);
			 glutWireCube(1.0);
			 glColor3fv(color[2]);
			 glutSolidCube(0.9);
		
		glPopMatrix();
			glTranslatef(0., 0., .1);
		glRotatef(anitheta, 0., 0., 1.);
		glColor3fv(color[1]);
		gluCylinder(c, 1., 1., .5, 12, 10);
		glTranslatef(0., 0., .5);
		glPushMatrix();
			glTranslatef(-.5, 0., 0.);
			glRotatef(-anitheta*5, 0., 0., 1.);
			glColor3f(0,0,0);
			gluCylinder(c, .25, .25, .25, 12, 10);
		glPopMatrix();
		glPushMatrix();
			glTranslatef(0., -.5, 0.);
			glRotatef(-anitheta*5, 0., 0., 1.);
			glColor3fv(color[3]);
			gluCylinder(c, .25, .25, .25, 12, 10);
		glPopMatrix();
		glPushMatrix();
			glTranslatef(0., .5, 0.);
			glRotatef(-anitheta*5, 0., 0., 1.);
			glColor3fv(color[4]);
			gluCylinder(c, .25, .25, .25, 12, 10);
		glPopMatrix();
		glPushMatrix();
			glTranslatef(.5, 0., 0.);
			glRotatef(-anitheta*5, 0., 0., 1.);
			glColor3fv(color[5]);
			gluCylinder(c, .25, .25, .25, 12, 10);
		glPopMatrix();
		glTranslatef(0., 0., .25);
		glRotatef(-anitheta*5, 0., 0., 1.);
		glColor3fv(color[6]);
		gluCylinder(c, .5, .1, .25, 12, 10);
		glTranslatef(0., 0., .25);
		glColor3fv(color[7]);
		gluCylinder(c, .1, .1, .5, 12, 10);
		glTranslatef(0., 0., .725);
		glColor3fv(color[8]);
		if(fillOn) glutSolidSphere(.25, 10, 10);
		else glutWireSphere(.25, 10, 10);
	



	
	glPopMatrix();



}
void ballon(){
	glPushMatrix();
		glutSolidSphere(1.0, 10, 10);
		for(double i=1.0;i>0.5;i-=0.05)
		{
			glTranslatef(0,0.19,0);
			glutSolidSphere(i, 10, 10);
		}
		glutSolidSphere(0.8, 10, 10);
	glPopMatrix();
}
void bench()
{
	glPushMatrix();
		glColor3fv(color[12]);
			glScalef(0.5, 2., .1);
			glutSolidCube(1);
	glPopMatrix();
	glPushMatrix();
		glScalef(0.5, 0.5, 0.5);
		glTranslatef(0.,1.,-0.39);
		glutSolidCube(1);
		glTranslatef(0.,-2.,0);
		glutSolidCube(1);
	glPopMatrix();
}
void bench1()
{
	glPushMatrix();
		glColor3fv(color[6]);
		glPushMatrix();
			glRotatef(10,1,0,0);
			glTranslatef(0,0.2,0.24);

			glScalef(0.1,0.1,0.55);
			glutSolidCube(1);
		glPopMatrix();
		glPushMatrix();
			glRotatef(-10,1,0,0);
			glTranslatef(0,-0.2,0.24);

			glScalef(0.1,0.1,0.55);
			glutSolidCube(1);
		glPopMatrix();
		glPushMatrix();
			glTranslatef(0,0,0.6);
			glutSolidSphere(0.1,10,8);
			glTranslatef(0,0,-0.35);
			glScalef(0.2,0.2,0.55);
			glutSolidCube(1);
		glPopMatrix();
		glPushMatrix();
			glTranslatef(0.2,0.0,0.1);
			glScalef(0.55,0.2,0.2);
			glutSolidCube(1);
		glPopMatrix();
		glPushMatrix();
			glTranslatef(0.4,0.0,-0.2);
			glScalef(0.2,0.2,0.55);
			glutSolidCube(1);

		glPopMatrix();

		glPushMatrix();
		glColor3fv(color[12]);
			glScalef(0.5, 2., .1);
			glutSolidCube(1);
		glPopMatrix();
		glScalef(0.5, 0.5, 0.5);
		glTranslatef(0.,1.,-0.39);
		glutSolidCube(1);
		glTranslatef(0.,-2.,0);
		glutSolidCube(1);
	glPopMatrix();
}
void bench2()
{
	glPushMatrix();
		glColor3fv(color[6]);
		glPushMatrix();
			glTranslatef(0,0.5,0);
			glPushMatrix();
				glRotatef(10,1,0,0);
				glTranslatef(0,0.2,0.24);

				glScalef(0.1,0.1,0.55);
				glutSolidCube(1);
			glPopMatrix();
			glPushMatrix();
				glRotatef(-10,1,0,0);
				glTranslatef(0,-0.2,0.24);

				glScalef(0.1,0.1,0.55);
				glutSolidCube(1);
			glPopMatrix();
			glPushMatrix();
				glTranslatef(0,0,0.6);
				glutSolidSphere(0.1,10,8);
				glTranslatef(0,0,-0.35);
				glScalef(0.2,0.2,0.55);
				glutSolidCube(1);
			glPopMatrix();
			glPushMatrix();
				glTranslatef(0.2,0.0,0.1);
				glScalef(0.55,0.2,0.2);
				glutSolidCube(1);
			glPopMatrix();
			glPushMatrix();
				glTranslatef(0.4,0.0,-0.2);
				glScalef(0.2,0.2,0.55);
				glutSolidCube(1);
			glPopMatrix();
		glPopMatrix();
		glPushMatrix();
			glTranslatef(0,-0.5,0);
			glPushMatrix();
				glRotatef(10,1,0,0);
				glTranslatef(0,0.2,0.24);

				glScalef(0.1,0.1,0.55);
				glutSolidCube(1);
			glPopMatrix();
			glPushMatrix();
				glRotatef(-10,1,0,0);
				glTranslatef(0,-0.2,0.24);

				glScalef(0.1,0.1,0.55);
				glutSolidCube(1);
			glPopMatrix();
			glPushMatrix();
				glTranslatef(0,0,0.6);
				glutSolidSphere(0.1,10,8);
				glTranslatef(0,0,-0.35);
				glScalef(0.2,0.2,0.55);
				glutSolidCube(1);
			glPopMatrix();
			glPushMatrix();
				glTranslatef(0.2,0.0,0.1);
				glScalef(0.55,0.2,0.2);
				glutSolidCube(1);
			glPopMatrix();
			glPushMatrix();
				glTranslatef(0.4,0.0,-0.2);
				glScalef(0.2,0.2,0.55);
				glutSolidCube(1);
			glPopMatrix();
		glPopMatrix();
		glPushMatrix();
		glColor3fv(color[12]);
			glScalef(0.5, 2., .1);
			glutSolidCube(1);
		glPopMatrix();
		glScalef(0.5, 0.5, 0.5);
		glTranslatef(0.,1.,-0.39);
		glutSolidCube(1);
		glTranslatef(0.,-2.,0);
		glutSolidCube(1);
	glPopMatrix();
}


void human(){
	glRotatef(90, 1.0, 0.0, 0.0);
	glTranslatef(0,-1.7,0);
	GLUquadricObj *obj1; //gluCylinder 함수를 사용하기 위한 설정 
	obj1 = gluNewQuadric();
	glutSolidSphere(0.1,10,8);
	glTranslatef(0.0,-0.2,0.0);
	glutSolidCube(0.2);
	glTranslatef(0.0,-0.2,0.0);
	glutSolidCube(0.2);
	glPushMatrix(); //머리, 몸통
		glTranslatef(-0.15,0.25,0.0);
		glRotatef(left_arm_up,1.0,0.0,0.0);
		glRotatef(-left_arm_left,0.0,0.0,1.0); 
		glutSolidSphere(0.04,10,8);
		glRotatef(90,0.1,0.0,0.0);
		gluCylinder(obj1, 0.05, 0.05,0.15,3,3); //왼쪽 팔 위
		glPushMatrix();
			glTranslatef(0.0,0.0,0.15);
			glRotatef(left_arm_down,1.0,0.0,0.0);
			glutWireSphere(0.04,10,8);
			gluCylinder(obj1, 0.05, 0.05,0.3,3,3); //왼쪽 팔 아래
		glPopMatrix();
	glPopMatrix();
	glPushMatrix(); 
		glTranslatef(0.15,0.25,0.0);
		glRotatef(right_arm_up,1.0,0.0,0.0);
		glRotatef(right_arm_right,0.0,0.0,1.0);
		glutSolidSphere(0.04,10,8);
		glRotatef(90,0.1,0.0,0.0);
		gluCylinder(obj1, 0.05, 0.05,0.15,3,3); //오른쪽 팔 위 
		glPushMatrix();
			glTranslatef(0.0,0.0,0.15);
			glRotatef(right_arm_down,1.0,0.0,0.0);
			glutSolidSphere(0.04,10,8);
			gluCylinder(obj1, 0.05, 0.05,0.3,3,3); //오른쪽 팔 아래
		glPopMatrix();
	glPopMatrix();
	glPushMatrix(); 
		glTranslatef(-0.07,-0.1,0.0);
		glRotatef(left_leg_up,1.0,0.0,0.0);
		glutSolidSphere(0.04,10,8);
		glRotatef(90,0.1,0.0,0.0);
		gluCylinder(obj1, 0.06, 0.06,0.25,5,5); //왼쪽 다리 위 
		glPushMatrix();
			glTranslatef(0.0,0.0,0.25);
			glRotatef(-left_leg_down,1.0,0.0,0.0);
			glutSolidSphere(0.04,10,8);
			gluCylinder(obj1, 0.06, 0.06,0.3,5,5); //왼쪽 다리 아래
		glPopMatrix();
	glPopMatrix();
	glPushMatrix(); 
		glTranslatef(0.07,-0.1,0.0);
		glRotatef(right_leg_up,1.0,0.0,0.0);
		glutSolidSphere(0.04,10,8);
		glRotatef(90,0.1,0.0,0.0);
		gluCylinder(obj1, 0.06, 0.06,0.25,5,5); //오른쪽 다리 위 
		glPushMatrix();
			glTranslatef(0.0,0.0,0.25);
			glRotatef(-right_leg_down,1.0,0.0,0.0);
			glutSolidSphere(0.04,10,8);
			gluCylinder(obj1, 0.06, 0.06,0.3,5,5); //오른쪽 다리 아래
		glPopMatrix();
	glPopMatrix();
}
void human1(){
	glRotatef(90, 1.0, 0.0, 0.0);
	glTranslatef(0,-1.7,0);
	GLUquadricObj *obj2; //gluCylinder 함수를 사용하기 위한 설정 
	obj2 = gluNewQuadric();
	glutSolidSphere(0.1,10,8);
	glTranslatef(0.0,-0.2,0.0);
	glutSolidCube(0.2);
	glTranslatef(0.0,-0.2,0.0);
	glutSolidCube(0.2);
	glPushMatrix(); //머리, 몸통
		glTranslatef(-0.15,0.25,0.0);
		glRotatef(-left_arm_up1,0.0,0.0,1.0);/////////////////////////////
		glRotatef(-left_arm_left1,0.0,0.0,1.0); 
		glutSolidSphere(0.04,10,8);
		glRotatef(90,0.1,0.0,0.0);
		gluCylinder(obj2, 0.05, 0.05,0.15,3,3); //왼쪽 팔 위
		glPushMatrix();
			glTranslatef(0.0,0.0,0.15);
			glRotatef(left_arm_down1,1.0,0.0,0.0);
			glutWireSphere(0.04,10,8);
			gluCylinder(obj2, 0.05, 0.05,0.3,3,3); //왼쪽 팔 아래
		glPopMatrix();
	glPopMatrix();
	glPushMatrix(); 
		glTranslatef(0.15,0.25,0.0);
		glRotatef(right_arm_up1,0.0,0.0,1.0);////////////////////
		glRotatef(right_arm_right1,0.0,0.0,1.0);
		glutSolidSphere(0.04,10,8);
		glRotatef(90,0.1,0.0,0.0);
		gluCylinder(obj2, 0.05, 0.05,0.15,3,3); //오른쪽 팔 위 
		glPushMatrix();
			glTranslatef(0.0,0.0,0.15);
			glRotatef(right_arm_down1,1.0,0.0,0.0);
			glutSolidSphere(0.04,10,8);
			gluCylinder(obj2, 0.05, 0.05,0.3,3,3); //오른쪽 팔 아래
		glPopMatrix();
	glPopMatrix();
	glPushMatrix(); 
		glTranslatef(-0.07,-0.1,0.0);
		glRotatef(-left_leg_up1,0.0,0.0,1.0);
		glutSolidSphere(0.04,10,8);
		glRotatef(90,0.1,0.0,0.0);
		gluCylinder(obj2, 0.06, 0.06,0.25,5,5); //왼쪽 다리 위 
		glPushMatrix();
			glTranslatef(0.0,0.0,0.25);
			glRotatef(-left_leg_down1,1.0,0.0,0.0);
			glutSolidSphere(0.04,10,8);
			gluCylinder(obj2, 0.06, 0.06,0.3,5,5); //왼쪽 다리 아래
		glPopMatrix();
	glPopMatrix();
	glPushMatrix(); 
		glTranslatef(0.07,-0.1,0.0);
		glRotatef(right_leg_up1,0.0,0.0,1.0);
		glutSolidSphere(0.04,10,8);
		glRotatef(90,0.1,0.0,0.0);
		gluCylinder(obj2, 0.06, 0.06,0.25,5,5); //오른쪽 다리 위 
		glPushMatrix();
			glTranslatef(0.0,0.0,0.25);
			glRotatef(-right_leg_down1,1.0,0.0,0.0);
			glutSolidSphere(0.04,10,8);
			gluCylinder(obj2, 0.06, 0.06,0.3,5,5); //오른쪽 다리 아래
		glPopMatrix();
	glPopMatrix();
}

void tree()//나무 그려주는 함수 
{	
	glRotatef(90,1,0,0);
	glRotatef(90,0,1,0);
	glScalef(0.8,0.8,0.8);
	glColor3fv(color[1]);
	glmDraw(hmodel[1],GLM_WIREFRAME);
}

void tree2()//나무 그려주는 함수2
{
	glRotatef(90,1,0,0);
	glRotatef(90,0,1,0);
	glScalef(0.8,0.8,0.8);
	glColor3fv(color[1]);
	glmDraw(hmodel[2],GLM_WIREFRAME);
}

//도로 부분
void Street1()
{
  glPushMatrix();
  glTranslatef(18, 5, -2.0);
  glScalef(1.0, 32., .1);
  glTranslatef(-0.5, 0., 0);
  glColor3fv(color[7]);
  if(fillOn) glutSolidCube(1.0);
  else glutSolidCube(1.0); 
  glPopMatrix();
}
void myLookAt(int key)
{
	if(key == GLUT_KEY_UP) {
		eye[2] = eye[2]-cos(theta)*eyeDelta;
		eye[0] = eye[0]+sin(theta)*eyeDelta;
	}
	else if(key == GLUT_KEY_DOWN) {
		eye[2] = eye[2]+cos(theta)*eyeDelta;
		eye[0] = eye[0]-sin(theta)*eyeDelta;
	}
	center[2] = eye[2]-cos(theta);
	center[0] = eye[0]+sin(theta);
}
void myResize (int width, int height){    
	glClear(GL_COLOR_BUFFER_BIT | 					GL_DEPTH_BUFFER_BIT);    
	glViewport(0, 0, width, height);    
	glMatrixMode(GL_PROJECTION);   
	glLoadIdentity();	
	if(projection) {
		glOrtho(-size, size, -size, size, -size, size); 
		eye[2] = 0.;
	}
	else {
		gluPerspective(60., (float)width/height, .1, 100.);
		eye[2] = 5.;
		myLookAt(0);
	}
	glEnable(GL_DEPTH_TEST);
	windowWidth=width;
	windowHeight=height;
}
void myMouse(int btn, int state, int x, int y)
{
	if(btn==GLUT_LEFT_BUTTON && state == 				GLUT_DOWN) {
		if(aniOn) glutIdleFunc(NULL);
		mouseState=state;
		mouseButton=btn;
		mouseX=x;
		mouseY=y;
	}
	else if(btn==GLUT_LEFT_BUTTON && state == 			GLUT_UP) {
		mouseState=-1;
		if(aniOn) glutIdleFunc(myIdle);
	}
	else return;
	glutPostRedisplay();
}
void myKeyboard (unsigned char key, int x, int y)
{	
	switch (key)	{	
		case 'e':
			
			iman=0;
		break;
		case 'r':
			iman=1;
		break;
		case 'w':
			ballonT=1;				
		break;
		case 'q':	
			ballonT=0;
		break;
		case 'z':
			kickc1=1;
			kickc3=1;
		break;
		case 'x':
			kickc2=1;
			kickc4=1;
		break;
		//case 'd':
		//	depthOn = !depthOn;
		//	if(depthOn) glEnable(GL_DEPTH_TEST);
		//	else glDisable(GL_DEPTH_TEST);
		//break;
		case 'a':
			scale*=scaleDelta;
		break;
		case 's':
			scale/=scaleDelta;
		break;
		//case 'a':
		//	glRotatef(180,0,0,1);
		//break;
	}
	glutPostRedisplay();
}
void mySKeyboard (int key, int x, int y)
{
	switch (key) {
		case GLUT_KEY_UP : 
		break;
		case GLUT_KEY_DOWN : 
		break;
		case GLUT_KEY_LEFT : 
			theta-=thetaDelta; 
		break;
		case GLUT_KEY_RIGHT : 
			theta+=thetaDelta; 
		break;
		default : return;
    	}
	myLookAt(key);
	glutPostRedisplay();
}
void myMotion(int x, int y)
{
	if(mouseButton == GLUT_LEFT_BUTTON && 				mouseState == GLUT_DOWN) {
		rot[1] -= (mouseX - x)/5.;
		rot[0] -= (mouseY - y)/5.;
		glutPostRedisplay();
		mouseX=x;
		mouseY=y;
	}
}
//시점 조절 메뉴 

void s_menu(int value)
{
	switch(value){

	case '1':
		if(!v_mode)
		v_mode=1;	
		
		veye[0]=15;
		veye[1]=0;
		veye[2]=1;

		vcenter[0]=0;
		vcenter[1]=15;
		vcenter[2]=-2;

		break;
	
	case '2':

		if(!v_mode)
		v_mode=1;

		veye[0]=15;
		veye[1]=-15;
		veye[2]=5;

		vcenter[0]=0;
		vcenter[1]=5;
		vcenter[2]=-8;

		break;
	
	case '3':
		
		if(!v_mode)
		v_mode=1;
		
		veye[0]=-20;
		veye[1]=-20;
		veye[2]=10;

		vcenter[0]=0;
		vcenter[1]=0;
		vcenter[2]=0;

		

		break;
	case '4':
		
		if(!v_mode)
		v_mode=1;
		
		veye[0]=10;
		veye[1]=0;
		veye[2]=30;

		vcenter[0]=0;
		vcenter[1]=0;
		vcenter[2]=-8;

		

		break;

	case '5':
		if(v_mode)
		v_mode=0;

		break;



	}
	glutPostRedisplay();
}

void myInit()
{
	c=gluNewQuadric();
	gluQuadricDrawStyle(c, GLU_LINE);
}
void main (void)
{
	myInit();    
	glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | 			GLUT_DEPTH);    
	glutInitWindowSize(1000,1000);    
	glutCreateWindow("공원---행사풍선방향(q,w)---공차기(z,x)---PT체조시작/멈춤(e,r)---멀리/가까이보기(s,a)");
	glutDisplayFunc(myDisplay);
	glutReshapeFunc(myResize);
	glutKeyboardFunc(myKeyboard); 
	glutSpecialFunc(mySKeyboard);
	glutMouseFunc(myMouse);
	glutMotionFunc(myMotion);
	glutIdleFunc(myIdle);
	glutCreateMenu(s_menu);
    glutAddMenuEntry("PT체조하는 사람들", '1');
    glutAddMenuEntry("족구장", '2');
    glutAddMenuEntry("개",'3');
    glutAddMenuEntry("위에서 밑으로 보는 시점", '4');
	glutAddMenuEntry("일반시점", '5');
    glutAttachMenu(GLUT_RIGHT_BUTTON);
	/*glutTimerFunc(1000,timerFunction,1);	
	glutDisplayFunc(dog_Display);*/
	glutMainLoop();
}
