chapter 15: working with the camera

46
Chapter 15 Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 15: Working with the Camera

Upload: quant

Post on 12-Feb-2016

38 views

Category:

Documents


0 download

DESCRIPTION

Chapter 15: Working with the Camera. This Chapter: we will learn about. One example of implementing Computer Graphics Camera Working with multiple Cameras Examples of interactive camera manipulation Select primitive in 3D scenes. Changes to Library: 2D to 3D. No changes: - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Chapter 15: Working with the Camera

Page 2: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

This Chapter: we will learn about One example of implementing

Computer Graphics Camera

Working with multiple Cameras

Examples of interactive camera manipulation

Select primitive in 3D scenes

Page 3: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Changes to Library: 2D to 3D No changes:

Primitive: 2D primitives drawn in 3D SceneNode: continue to load MW Matrix Model: continue to be application main

class Changes:

WindowHandler When loading matrices!

Page 4: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

WindowHandler: 2D vs 3D

Page 5: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Lib14: Support for 3D New classes:

Camera PrimitiveAxisFrame:

Drawing x,y,z axis frame Modifications:

WindowHandler Support Camera Load View and Projection Matrices

XformInfo Support 3D rotation

Page 6: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Lib14: New Classes and Changes

Page 7: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Lib14: The Camera Class

Page 8: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Lib14: WindowHandler changes

Page 9: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Lib14: XformInfo Changes Xform Operator in 2D

Scale, Translate, Pivot: all 3D quantity Problem:

Rotation: θ rotates wrt to z-axis! Xform Operator in 3D (for now)

Rotation: (θx θy θz) Three rotations with respect to each axes

Page 10: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Lib14: XformInfo details …

Xform Operator:

Page 11: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 15.1: Working with Lib14 Using: Camera and WindowHandler

Page 12: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 15.1: WindowHandler details

Page 13: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Lib14: D3D_WindowHandler

Page 14: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 15.1: DrawHandler

Page 15: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 15.1: Application CTutorialDlg

Page 16: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 15.2: Working with 2 Cameras

CTutorialDlg class

Page 17: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Interactive Manipulation of Camera

Parameters under explicit user control Camera position Look at position

Parameters implicitly controlled Up Vector: try to maintain sense of “up”

Parameters typically not controlled Near/Far planes (no real-world correspondence) FOV – zooming control via camera position

movement

Page 18: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Notation and Terminology

Page 19: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 15.3: Camera Manipulation with the Mouse

Left Mouse Button (LMB) Orbit

Middle (MMB) Pan

Right (RMB) Zoom

Page 20: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

LMB: Tumble or Orbit the Camera

Page 21: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Left/Right Orbiting Axis of rotation: The “Up” Direction

Page 22: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Up/Down Orbiting Axis or rotation: Side Vector

Page 23: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Orbit: Idea Orbit or Rotate

Need Matrix:

Camera Position:

Page 24: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Orbit: Alternatively

Page 25: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Orbit: Implementation Rotate the World when compute

MV Instead of: Compute:

Compute and load:

Page 26: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Lib14: Orbit Support Camera: mouse movement to

radians

And … using in WindowHandler

Page 27: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Lib14: Using camera orbit info

In WindowHandler:: ComputeViewMatrix

Page 28: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

MMB: Pan or Track the camera

Page 29: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Vertical Tracking: (Along UpVector)

Page 30: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tracking: Implementation Horizontal/Vertical mouse movements

dx and dy Computer Movement vector:

Left/Right tracking: along side-vector Up/down tracking: along up-vector

Update both camera and at positions:

Page 31: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Lib14: Tracking Support Camera Class:

Page 32: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

RMB: Dolly or Zoom the Camera

Page 33: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Zoom: Implementation Mouse movement: d Move camera eye position in the

viewing direction!

Watch out!

Page 34: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Lib14: Mouse Zoom support Camera class

Page 35: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Drawing the Camera Requires at least two Views!

View-A cannot draw the camera of View-A! Can only draw the camera for another

view! i.e., View-A draws camera of View-B

Page 36: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Drawing camera: View Matrix Details

Recall: for “orbiting”, we computed and loaded MV with:

To properly draw camera-B, from view-A Include camera-B orbiting! Un-do view-A’s camera orbiting ( )

Page 37: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Implementation: Load into the WORLD matrix

Page 38: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

3D DC to WC Transformation

Must: DC NDC EC WC

Page 39: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Transform: DC to NDC Assume Recall:

Or: In 3D:

Page 40: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

DC Points and NDC Ray

Page 41: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

NDC Ray to EC Ray Transform

Page 42: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

NDC EC

If:

In general: or: Given:

Then:

Page 43: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Reconstruct the ray in EC: Given: In general, NDC Point:

is a line in EC:

Or:

Page 44: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

EC to WC Transform: Given:

Choose convenient ze values ze= 0 and ze = 1

Use to compute WC positions:

Page 45: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 15.4: Mouse Click to WC Shift-LMB to see the selection ray

Page 46: Chapter 15:  Working with the Camera

Chapter 15

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 15.4: Device to WC Xform