소개글
이번 프로그램은 간단한 3D객체들을 이용하여 사람모양의 인형을 만들고 그것을 이용하여 걷는 모습과 간단한 조작기능을 구현 하는 것에 목적이 있다. OpenGL함수를 이용하여 작성하였으며 인터넷의 오픈 소스를 베이스로 작성 되었다.
컴파일 실행환경
VC++
본문내용
#include <GL/glut.h>
#include <iostream>
#include <stdlib.h>
#include <cstdio>
#define BODY_HEIGHT 5.0
#define UPPER_ARM_HEIGHT 3.0
#define LOWER_ARM_HEIGHT 2.0
#define UPPER_LEG_RADIUS 0.5
#define LOWER_LEG_RADIUS 0.5
#define LOWER_LEG_HEIGHT 2.0
#define UPPER_LEG_HEIGHT 3.0
#define UPPER_LEG_RADIUS 0.5
#define BODY_RADIUS 1.0
#define UPPER_ARM_RADIUS 0.5
#define LOWER_ARM_RADIUS 0.5
#define HEAD_HEIGHT 1.5
#define HEAD_RADIUS 1.0
typedef float point[3];
float time =0 ;
static GLfloat theta[12] = {90.0, 0.0, 0.0, 140.0, 0.0, -140.0, 45.0, 210.0, 0.0, -210.0, -45.0, 0.0};
GLint angle = 2;
GLint type = 1;
GLdouble walking_speed = 0.3;
GLUquadricObj *t, *h, *lua, *lla, *rua, *rla, *lll, *rll, *rul, *lul, *hr,*lf,*rf,*rfe,*lfe,*ls,*rs;
GLdouble size=1.0;
void body()
{
glPushMatrix();
glRotatef(-90.0, 1.0, 0.0, 0.0);
gluCylinder(t,BODY_RADIUS, BODY_RADIUS+0.5, BODY_HEIGHT,10,10);
glPopMatrix();
}
void head()
{
glPushMatrix();
glTranslatef(0.0, 0.5*HEAD_HEIGHT,0.0);
glScalef(HEAD_RADIUS, HEAD_HEIGHT, HEAD_RADIUS);
gluSphere(h,1.0,10,10);
glPopMatrix();
}
참고 자료
없음