/
What   you   wi l l  l earn What   you   wi l l  l earn

What you wi l l l earn - PowerPoint Presentation

giovanna-bartolotta
giovanna-bartolotta . @giovanna-bartolotta
Follow
343 views
Uploaded On 2019-06-21

What you wi l l l earn - PPT Presentation

about today C a m e r a s i n O pen GL W h e r e this f its in to w or ld t r a n s for m a tions V a r iou s typ e s of ca ID: 759444

lookat camera iew world camera lookat world iew center vector point eye person translate glm move eye

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "What you wi l l l earn" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

What you will learn about today

Cameras in OpenGLWhere this fits into world transformationsVarious types of cameras

Slide2

What is moving?

f

ra

m

e1

frame2

frame3

Slide3

Let’s Examine the Camera

If I gave you a world, and said I want to render it from another viewpoint, what information do I have to give you?PositionWhich way we are lookingWhich way is “up”Aspect RatioField of ViewNear and Far

Slide4

glm::lookat

Orients and positions the “camera”lookat( eyex, eyey, eyez,centerx, centery, centerz, upx,upy, upz);eye – the position of the camera in world coordinates center – the camera is pointed at this pointup – the direction defined to be up for the camera

Slide5

Moving the camera

How can we translate the camera?add a vector to the eye and center parameters How far will this move it?the length of the vectorWhat happens if you don’t change the center?the camera will stay fixed on the original point

Slide6

Camera without glm::lookat?

How can we translate and orient the camera without lookat?inverse transforms: translate(-x,-y,-z); rotate(-angle, a,b,c) Where does this go in your openGL program (using lookat or not)?usually at the beginning of your display function

Slide7

C

a

mera: side view

V

iew

N

or

m

al

V

iew

D

irection

V

iew

Up

V

iew

R

ight

Slide8

Camera: looking through thecamera

V

iew

Up

V

iew

R

ight

W

hat are

the

vectors?

Slide9

T

ransform

ation World->Camera

M

W

C

V

C  R  T

3 n1 n2 n3 0 0 0 0 1

u1 u2 u3 0v v v

R  

v  n  u  (v1 , v2 , v3 )

u  V  N  (u , u , u )

V  N

n  N  (n , n , n )

N

cameraz 

camera 

1 0 0  camerax 0 1 00 0 10 0 0

T  

y 

0



1

1 2

1 2 3

1 2 3

V

iew

U

p

=

V

V

iew

R

ight

= u

V

iew

D

irection

=

-N

Slide10

First Person Camera

H

ow

is

this

i

m

ple

m

ented?

W

here is the

‘eye’?

W

hat is the

look at

point?

W

hat is up?

up

center

eye

Slide11

First Person Camera

How do we move the camera?Add a vector to eye and center

center

eye

up

move

d

ir

Slide12

First Person Camera

H

ow

do

w

e rotate

the camera?Move the center point - add a vector to itUp vectorSide vector: lookat x upcenterupeye

Slide13

Lookat implementation oddities

What will happen if up == lookat direction?Spins around the up axis in a weird wayWhy does this happen?Two axes of your camera frame are aligned!How can we avoid this?Maintain an orthogonal camera frame - Reset the up vector using lookat X side (e.g., more common in flight games)Constrain the lookat direction to not get to close to the up vector (e.g., common in FPS games)Use quaternions

Slide14

3rd Person Camera

H

ow is this implemented?Where is the ‘eye’?What is the look at point?What is up?

Slide15

3rd Person Camera

Remember, initially the camera isAt the origin looking down –z)• Same as glm::lookat(0,0,0, 0,0,-1,0,1,0)How can this be more easily implemented without glm::lookat?translate the character so you can see itDraw the characterRotate the world around Y at the fixed point of the characterTranslate the world inversely to the character positionRender the world

Slide16

Birds Eye Camera

H

ow is this implemented?

Where is the ‘eye’?••

What is the look at point?

What is up?

Slide17

Review: What you learned abouttoday

Cameras in OpenGLWhere this fits into world transformationThe camera transform is performed after the world transformIS THE SAME AS:The camera is always at 0,0,0 looking down –zThe world transforms insteadVarious types of cameras1st, 3rd, birdseye