460 likes | 555 Views
Explore working with multiple cameras, interactive camera manipulation, and 3D scene primitives in computer graphics. Understand camera positions, orbits, panning, zooming, and tracking. Learn how to transform 3D points and rays to world coordinates for precise rendering. Discover techniques like tumble, orbit, dolly, and drawing cameras accurately. Dive deep into camera control and parameter adjustments in your 3D projects.
E N D
Chapter 15: Working with the Camera Chapter 15
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 Chapter 15
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! Chapter 15
WindowHandler: 2D vs 3D Chapter 15
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 Chapter 15
Lib14: New Classes and Changes Chapter 15
Lib14: The Camera Class Chapter 15
Lib14: WindowHandler changes Chapter 15
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 Chapter 15
Lib14: XformInfo details … Xform Operator: Chapter 15
Tut 15.1: Working with Lib14 • Using: Camera and WindowHandler Chapter 15
Tut 15.1: WindowHandler details Chapter 15
Lib14: D3D_WindowHandler Chapter 15
Tut 15.1: DrawHandler Chapter 15
Tut 15.1: Application CTutorialDlg Chapter 15
Tut 15.2: Working with 2 Cameras • CTutorialDlg class Chapter 15
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 Chapter 15
Notation and Terminology Chapter 15
Tut 15.3: Camera Manipulation with the Mouse • Left Mouse Button (LMB) • Orbit • Middle (MMB) • Pan • Right (RMB) • Zoom Chapter 15
LMB: Tumble or Orbit the Camera Chapter 15
Left/Right Orbiting • Axis of rotation: The “Up” Direction Chapter 15
Up/Down Orbiting • Axis or rotation: Side Vector Chapter 15
Orbit: Idea • Orbit or Rotate • Need Matrix: • Camera Position: Chapter 15
Orbit: Alternatively Chapter 15
Orbit: Implementation • Rotate the World when compute MV • Instead of: • Compute: • Compute and load: Chapter 15
Lib14: Orbit Support • Camera: mouse movement to radians • And … using in WindowHandler Chapter 15
Lib14: Using camera orbit info • In WindowHandler:: ComputeViewMatrix Chapter 15
MMB: Pan or Track the camera Chapter 15
Vertical Tracking: (Along UpVector) Chapter 15
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: Chapter 15
Lib14: Tracking Support • Camera Class: Chapter 15
RMB: Dolly or Zoom the Camera Chapter 15
Zoom: Implementation • Mouse movement: d • Move camera eye position in the viewing direction! • Watch out! Chapter 15
Lib14: Mouse Zoom support • Camera class Chapter 15
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 Chapter 15
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 ( ) Chapter 15
Implementation: • Load into the WORLD matrix Chapter 15
3D DC to WC Transformation • Must: DC NDC EC WC Chapter 15
Transform: DC to NDC • Assume • Recall: • Or: • In 3D: Chapter 15
DC Points and NDC Ray Chapter 15
NDC Ray to EC Ray Transform Chapter 15
NDC EC • If: • In general: or: • Given: • Then: Chapter 15
Reconstruct the ray in EC: • Given: • In general, NDC Point: • is a line in EC: • Or: Chapter 15
EC to WC Transform: • Given: • Choose convenient ze values • ze= 0 and ze = 1 • Use to compute WC positions: Chapter 15
Tut 15.4: Mouse Click to WC • Shift-LMB to see the selection ray Chapter 15
Tut 15.4: Device to WC Xform Chapter 15