Object Coordinates
Eye Coordinates
Clip Coordinates
Normalized Device Coordinates (NDC)
Window Coordinates (Screen Coordinates)
Object Coordinates
Eye Coordinates
Clip Coordinates
Normalized Device Coordinates (NDC)
Window Coordinates (Screen Coordinates)
OpenGL Transformation
http://dis.dankook.ac.kr/lectures/cg08/entry/transformation-예제
OpenGL Cube Transformation
http://dis.dankook.ac.kr/lectures/cg08/entry/cube3d-예제
// OpenGL 행렬는 column-order이고, 벡터와 행렬의 곱은 Post-multiply 방식 사용
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 0.0, 1.0);
glutWireCube(1);
////////////////////////////////////////////
// USING MATRIX
///////////////////////////////////////////
matrix4x4 M1, M2, M3, R, T, S;
R.rotate(45.0, ‘z’);
T.translate(vector3(1.5, 0.0, 0.0));
S.scale(vector3(0.5, 0.7, 1.0));
// p’= R T p (red) => translate, and then rotate
M1 = R * T;
glPushMatrix();
glMultMatrixf( M1 );
glColor3f(1.0, 0.0, 0.0);
glutWireCube(1);
glPopMatrix();
// p’= T R p (green) => rotate, and then translate
M2 = T * R;
glPushMatrix();
glMultMatrixf( M2 );
glColor3f(0.0, 1.0, 0.0);
glutWireCube(1);
glPopMatrix();
// p’= T R S p (blue) => scale, and then rotate, and then translate
M3 = T * R * S;
glPushMatrix();
glMultMatrixf( M3 );
glColor3f(0.0, 0.0, 1.0);
glutWireCube(1);
glPopMatrix();
// p’= T R p (green) => rotate, and then translate
glPushMatrix();
glMultMatrixf( T );
glMultMatrixf( R );
glColor3f(0.0, 1.0, 0.0);
glutWireCube(1);
glPopMatrix();
// p’= T R S p (blue) => scale, and then rotate, and then translate
glPushMatrix();
glMultMatrixf( T );
glMultMatrixf( R );
glMultMatrixf( S );
glColor3f(0.0, 0.0, 1.0);
glutWireCube(1);
glPopMatrix();
glutSwapBuffers();
}