Presentation is loading. Please wait.

Presentation is loading. Please wait.

What you will learn about today

Similar presentations


Presentation on theme: "What you will learn about today"— Presentation transcript:

1 What you will learn about today
Cameras in OpenGL Where this fits into world transformations Various types of cameras

2 What is moving? frame1 frame3 frame2

3 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? Position Which way we are looking Which way is “up” Aspect Ratio Field of View Near and Far

4 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 point up – the direction defined to be up for the camera

5 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 vector What happens if you don’t change the center? the camera will stay fixed on the original point

6 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

7 Camera: side view View Right View Up View Normal View Direction

8 Camera: looking through the camera
View Up View Right What are the vectors?

9 Transformation World->Camera
View Right = u 1 0 0  camerax  0 1 0 0 0 1 0 0 0 View Up = V camera  T   y  cameraz  1 n  N  (n , n , n ) N 1 2 3 u  V  N  (u , u , u ) V  N 1 2 3 View Direction = -N v  n  u  (v1 , v2 , v3 ) u1 u2 u3 0 v v v 0 R   3  n1 n2 n3 0   1 2 MW CVC  R  T

10 First Person Camera How is this implemented? Where is the ‘eye’?
What is the look at point? What is up? up center eye

11 First Person Camera How do we move the camera?
Add a vector to eye and center up move dir center eye

12 First Person Camera How do we rotate the camera?
Move the center point - add a vector to it Up vector Side vector: lookat x up center up eye

13 Lookat implementation oddities
What will happen if up == lookat direction? Spins around the up axis in a weird way Why 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

14 3rd Person Camera How is this implemented? Where is the ‘eye’?
What is the look at point? What is up?

15 3rd Person Camera Remember, initially the camera is
At 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 it Draw the character Rotate the world around Y at the fixed point of the character Translate the world inversely to the character position Render the world

16 Birds Eye Camera How is this implemented? Where is the ‘eye’? •
What is the look at point? What is up?

17 Review: What you learned about today
Cameras in OpenGL Where this fits into world transformation The camera transform is performed after the world transform IS THE SAME AS: The camera is always at 0,0,0 looking down –z The world transforms instead Various types of cameras 1st, 3rd, birdseye


Download ppt "What you will learn about today"

Similar presentations


Ads by Google