















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
















Computer Graphics 3D Viewing and Camera Control
world (cx, cy, cz)
(ex, ey, ez) view up vector (Up_x, Up_y, Up_z)
n Constructing eye coordinate frame (u, v, n) n Composes matrix to perform coordinate transformation n Loads this matrix into the V part of modelview matrix n Allows flexible Camera Control
eye
Lookat Point
orthogonal to view plane (plane that objects will be projected onto)
90
o
eye
Lookat n
u
v
U = V_up x n
u = U / | U |
eye
Lookat n
u
v
v = n x u
v is already normalized
v u
n
world x
y
z
v u
n
world x
y
z
(ex,ey,ez)
Rotation: ux uy uz 0 vx vy vz 0 nx ny nz 0 0 0 0 1
Translation: 1 0 0 -ex 0 1 0 -ey 0 0 1 -ez 0 0 0 1
n Pitch: nose up-down n Roll: roll body of plane n Yaw: move nose side to side
pitch
x
y
yaw
y
x
roll
void Camera::setModelViewMatrix(void)
{ // load modelview matrix with existing camera values
float m[16]; Vector3 eVec(eye.x, eye.y, eye.z);// eye as vector m[0] = u.x; m[4] = u.y; m[8] = u.z; m[12] = -eVec.dot(u); m[1] = v.x; m[5] = v.y; m[9] = v.z; m[13] = -eVec.dot(v); m[2] = n.x; m[6] = n.y; m[10] = n.z; m[14] = -eVec.dot(n); m[3] = 0; m[7] = 0; m[11] = 0; m[15] = 1.0; glMatrixMode(GL_MODELVIEW); glLoadMatrixf(m); // load OpenGL’s modelview matrix
}