void createChair(GLfloat x, GLfloat y, GLfloat z, GLfloat thick, GLfloat width, GLfloat height)
{
    /* function createChair()
    의자 왼쪽 위 끝 x,y,z좌표, 등받이 높이, 앉는부분 길이를 받아 의자를 생성하는 함수
    x : 의자 왼쪽 위 끝 x좌표
    y : 의자 왼쪽 위 끝 y좌표
    z : 의자 오른쪽 위 끝 z좌표
    thick : 의자 두께
    width : 의자 가로길이
    height : 의자 세로길이
    */
    glColor3ub(0, 0, 0);
    glBegin(GL_QUADS);
    glNormal3f(-1.0f, 0.0f, 0.0f);   //등받이 왼쪽 옆면
    glVertex3f(x, y, z);
    glVertex3f(x+thick, y, z);
    glVertex3f(x+thick, y+height, z);
    glVertex3f(x, y+height, z);
 
    glNormal3f(0.0f, 0.0f, 1.0f);   //등받이 앞면
    glVertex3f(x+thick, y, z);
    glVertex3f(x+thick, y, z+width);
    glVertex3f(x+thick, y+height, z+width);
    glVertex3f(x+thick, y+height, z);

    glNormal3f(1.0f, 0.0f, 0.0f);   //등받이 오른쪽 옆면
    glVertex3f(x+thick, y, z+width);
    glVertex3f(x, y, z+width);
    glVertex3f(x, y+height, z+width);
    glVertex3f(x+thick, y+height, z+width);

    glNormal3f(0.0f, 0.0f, -1.0f);   //등받이 뒷면
    glVertex3f(x, y, z+width);
    glVertex3f(x, y, z);
    glVertex3f(x, y+height+thick, z);
    glVertex3f(x, y+height+thick, z+width);
 
    glNormal3f(0.0f, 1.0f, 0.0f);   //등받이 윗면
    glVertex3f(x, y, z);
    glVertex3f(x, y, z+width);
    glVertex3f(x+thick, y, z+width);
    glVertex3f(x+thick, y, z);

    glNormal3f(0.0f, 1.0f, 0.0f);   //앉는 부분 윗면
    glVertex3f(x, y+height, z);
    glVertex3f(x, y+height, z+width);
    glVertex3f(x+height, y+height, z+width);
    glVertex3f(x+height, y+height, z);

    glNormal3f(-1.0f, 0.0f, 0.0f);   //앉는 부분 왼쪽 옆면
    glVertex3f(x, y+height, z);
    glVertex3f(x+height, y+height, z);
    glVertex3f(x+height, y+height+thick, z);
    glVertex3f(x, y+height+thick, z);
    glNormal3f(0.0f, 0.0f, -1.0f);   //앉는 부분 앞쪽
    glVertex3f(x+height, y+height, z);
    glVertex3f(x+height, y+height, z+width);
    glVertex3f(x+height, y+height+thick, z+width);
    glVertex3f(x+height, y+height+thick, z);

    glNormal3f(1.0f, 0.0f, 0.0f);   //앉는 부분 오른쪽 옆면
    glVertex3f(x, y+height, z+width);
    glVertex3f(x, y+height+thick, z+width);
    glVertex3f(x+height, y+height+thick, z+width);
    glVertex3f(x+height, y+height, z+width);

    glNormal3f(0.0f, -1.0f, 0.0f);   //앉는 부분 밑면
    glVertex3f(x, y+height+thick, z);
    glVertex3f(x+height, y+height+thick, z);
    glVertex3f(x+height, y+height+thick, z+width);
    glVertex3f(x, y+height+thick, z+width);
    glEnd();
}

'Graphics > OpenGL' 카테고리의 다른 글

[OpenGL]간단한 나무 만들기 함수  (2) 2014.07.05
[OpenGL]반구 만들기 함수  (0) 2014.07.05
[OpenGL]간단한 링 만드는 함수  (0) 2014.07.05
[OpenGL]간단한 배 만들기 함수  (5) 2014.07.05
[OpenGL]glColor() 색상모음  (1) 2014.07.05

+ Recent posts