1 View ing Transform ation Eye Coordinate Fram e Recall OpenGL way - - PDF document

1
SMART_READER_LITE
LIVE PREVIEW

1 View ing Transform ation Eye Coordinate Fram e Recall OpenGL way - - PDF document

3 D view ing under the hood CS 4 7 3 1 : Com put e r Gr a phics Le ct ur e 1 2 : M or e 3 D Vie w ing Modeling Viewing Projection Em m anuel Agu Transformation Transformation Transformation Viewport


slide-1
SLIDE 1

1

CS 4 7 3 1 : Com put e r Gr a phics Le ct ur e 1 2 : M or e 3 D Vie w ing Em m anuel Agu

3 D view ing under the hood

Modeling Viewing Projection Transformation Transformation Transformation Viewport Transformation Display

3 D view ing under the hood

  • Topics of Interest:
Viewing transform ation Projection transform ation

View ing Transform ation

  • Transform the object from world to eye space
  • Const ruct eye coordinat e fram e
  • Const ruct m at rix t o perform coordinat e t ransform at ion
  • Flexible Cam era Cont rol
slide-2
SLIDE 2

2

View ing Transform ation

  • Recall OpenGL way to set cam era:
gluLookAt (Ex, Ey, Ez, c x, cy, cz, Up_x , Up_y , Up_z) The view up vect or is usually ( 0,1,0) Rem em ber t o set t he OpenGL m at rix m ode t o

GL_MODELVI EW first

  • Modelview m atrix:
com binat ion of m odeling m at rix M and Cam era t ransform s V
  • gluLookAt fills V part of m odelview m atrix
  • What does gluLookAt do with param eters (eye, COI , up

vector) you provide?

Eye Coordinate Fram e

  • Known: eye position, center of interest, view- up vect or
  • To find out: new origin and three basis vectors

eye cent er of int erest ( COI )

Assum ption: direct ion of view is

  • rt hogonal t o view plane ( plane

t hat obj ect s will be proj ect ed ont o) 90

  • Eye Coordinate Fram e
  • Origin: eye position (that was easy)
  • Three basis vectors:
  • ne is t he norm al vect or ( n) of t he view ing plane,
  • t her t wo ( u and v ) span t he viewing plane

eye Cent er of int erest ( COI ) n u v world origin Rem em ber u,v,n should be all unit vectors n is point ing away from t he world because we use left hand coordinat e syst em N = ey e – COI n = N / | N | ( u,v,n should all be ort hogonal)

Eye Coordinate Fram e

  • How about u and v?

eye COI n u v V _ u p

  • We can get u first -
  • u is a vector that is perp

to the plane spanned by N and view up vector (V_up)

U = V_up x n u = U / | U |

slide-3
SLIDE 3

3

Eye Coordinate Fram e

  • How about v?

eye COI n u v V _ u p

Knowing n and u, getting v is easy

v = n x u v is a lr e a dy n or m a liz e d

Eye Coordinate Fram e

  • Put it all together

eye COI n u v V _ u p Eye space or igin: ( Eye .x , Eye .y, Eye .z) Basis vectors: n = ( ey e – COI ) / | eye – COI | u = ( V_up x n ) / | V_up x n | v = n x u

W orld to Eye Transform ation

  • Transform ation m atrix (Mw2e) ?

P’ = Mw2e x P

u v n world x y z P

  • 1. Com e up wit h t he t ransform at ion

sequence t o m ove eye coordinat e fram e t o t he world

  • 2. And t hen apply t his sequence t o t he

point P in a reverse order

W orld to Eye Transform ation

  • Rotate the eye fram e to “align” it with the world fram e
  • Translate (- ex, - ey, - ez)

u v n world x y z (ex, e y, ez) Rot at ion: ux uy uz 0 vx vy v z 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

slide-4
SLIDE 4

4

W orld to Eye Transform ation

  • Transform ation order: apply the transform ation to the
  • bject in a reverse order -

translation first, and then rotate

Mw2e =

u v n world x y z (ex, e y, ez) ux uy ux 0 1 0 0 - ex vx vy vz 0 0 1 0 -e y nx ny nz 0 0 0 1 -ez 0 0 0 1 0 0 0 1

W orld to Eye Transform ation

Head tilt: Rotate your head by δ Just rotate the object about the eye space z

axis - δ

Mw2e=

cos(- δ)

  • sin( -δ)

0 0 ux uy ux 0 1 0 0 -e x sin( -δ) cos (- δ) 0 0 vx vy v z 0 0 1 0 -ey 0 1 0 nx ny nz 0 0 0 1 -ez 0 0 1 0 0 0 1 0 0 0 1 u v n world x y z Why - δ? When you rot at e your head by δ, it is lik e rot at e t he obj ect by –δ