MP2 QUATERNION BASED CAMERA FOR FLIGHT SIM. Quaternions!  You need to have a good understanding of what they are, and a good grasp of how they work.

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

Lecture 3: Transformations and Viewing. General Idea Object in model coordinates Transform into world coordinates Represent points on object as vectors.
Defining the Viewing Coordinate System
MAT 594CM S2010Fundamentals of Spatial ComputingAngus Forbes Overview Goals of the course: 1. to introduce real-time 3D graphics programming with openGL.
Geometry Primer Lines and rays Planes Spheres Frustums Triangles Polygon Polyhedron.
Based on slides created by Edward Angel
Viewing and Projections
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 5: Viewing
CS 352: Computer Graphics Chapter 5: Viewing. Interactive Computer GraphicsChapter Overview Specifying the viewpoint Specifying the projection Types.
Now Playing: Coulibaly Amadou & Mariam from Dimanche a Bamako Released August 2, 2005.
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 14 Chapter 14: The Camera.
Viewing Doug James’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals of Computer Graphics, Chap 7 Wen-Chieh (Steve) Lin Institute of Multimedia.
4.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 4 Projection Clipping Viewport Transformation.
OpenGL (II). How to Draw a 3-D object on Screen?
CS 4731: Computer Graphics Lecture 11: 3D Viewing Emmanuel Agu.
CHAPTER 7 Viewing and Transformations © 2008 Cengage Learning EMEA.
Computer Graphics 3D Transformations. 3D Translation Remembering 2D transformations -> 3x3 matrices, take a wild guess what happens to 3D transformations.
2/26/04© University of Wisconsin, CS559 Spring 2004 Last Time General Orthographic Viewing –Specifying cameras in world coordinates –Building world  view.
Introduction to 3D viewing 3D is just like taking a photograph!
12.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 12 – 3D Graphics Transformation Pipeline: Projection and Clipping.
Lecture 5: 3D Rendering Pipeline (II) Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering Georgia Institute of Technology.
Viewing and Projections
Introduction Tracking the corners Camera model and collision detection Keyframes Path Correction Controlling the entire path of a virtual camera In computer.
02/26/02 (c) 2002 University of Wisconsin, CS 559 Last Time Canonical view pipeline Orthographic projection –There was an error in the matrix for taking.
Advanced Computer Graphics Three Dimensional Viewing
Week 2 - Wednesday CS361.
3D Viewing.
2 COEN Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing.
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
2/24/04© University of Wisconsin, CS559 Spring 2004 Last Time 3D Transformations –Most are natural extensions of 2D transforms –Rotations can be represented.
CAP 4703 Computer Graphic Methods Prof. Roy Levow Chapter 5.
CAP4730: Computational Structures in Computer Graphics 3D Transformations.
10/3/02 (c) 2002 University of Wisconsin, CS 559 Last Time 2D Coordinate systems and transformations.
Computer Graphics I, Fall 2010 Computer Viewing.
Games Development 1 Camera Projection / Picking CO3301 Week 8.
OpenGL The Viewing Pipeline: Definition: a series of operations that are applied to the OpenGL matrices, in order to create a 2D representation from 3D.
OpenGL Viewing and Modeling Transformation Geb Thomas Adapted from the OpenGL Programming Guidethe OpenGL Programming Guide.
Basic Perspective Projection Watt Section 5.2, some typos Define a focal distance, d, and shift the origin to be at that distance (note d is negative)
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
Three-Dimensional Viewing
Three-Dimensional Viewing Hearn & Baker Chapter 7
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 5: Viewing
©2005, Lee Iverson Lee Iverson UBC Dept. of ECE EECE 478 Viewing and Projection.
Graphics CSCI 343, Fall 2015 Lecture 16 Viewing I
CS COMPUTER GRAPHICS LABORATORY. LIST OF EXPERIMENTS 1.Implementation of Bresenhams Algorithm – Line, Circle, Ellipse. 2.Implementation of Line,
Viewpoints and Transformations CSIS 5838: Graphics and Animation for Gaming.
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
Part One - Parallel Projection textbook
A Photograph of two papers
Coordinate Systems Lecture 1 Fri, Sep 2, The Coordinate Systems The points we create are transformed through a series of coordinate systems before.
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
3D GRAPHICS RENDERING PIPELINE CS / TECHNICAL BACKGROUND PAGE 11.
Orthonormal Basis Cartesian Coordinate System – Unit vectors: i, j, k – Normalized to each other – Unique representation for each position!! – Convenient!
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Computer Viewing Isaac Gang University of Mary Hardin-Baylor.
OpenGL LAB III.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS 490: Computer Graphics Chapter 5: Viewing. Interactive Computer GraphicsChapter Overview Specifying the viewpoint Specifying the projection Types.
A Photograph of two papers The Model: 2 papers – 8cm x 8cm and 5cm x 5cm The Camera – Simple pinhole – No focusing capability The Scene – Arrangements.
What you will learn about today
CSE 167 [Win 17], Lecture 5: Viewing Ravi Ramamoorthi
Chapter 3 Drawing In the World.
Introduction to Computer Graphics with WebGL
A Photograph of two papers
Chapter V Vertex Processing
What you will learn about today
Last Time Canonical view pipeline Projection Local Coordinate Space
Introduction to Computer Graphics with WebGL
CS 352: Computer Graphics Chapter 5: Viewing.
Presentation transcript:

MP2 QUATERNION BASED CAMERA FOR FLIGHT SIM

Quaternions!  You need to have a good understanding of what they are, and a good grasp of how they work.  Good places to start:  athematics/Quaternions athematics/Quaternions 

Making a non-rotating camera first.  You want mat4.perspective and mat4.lookAt.  mat4.perspective(out, fovy, aspect, near, far)  Out is the resultant matrix.  Fovy is the Vertical field of view in radians  Aspect ratio. typically viewport width/height  Near bound of the frustum  Far bound of the frustum  You may have already seen all this in class. This function will only need to be called once. You can pass the resultant matrix to the shaders without needing to update it at all.

Using Mat4.lookAt  This is the function that you will have to call with the right parameters. Eye, Center, Up are the arguments.  Eye – is the position of the viewer.  In the case of a non-moving camera, this will be constant.  In the case of a moving camera, this will change.  When the camera is moving, you have to ask yourself where the next eye position will be.  Hint: Imagine a plane flying. Where is the cockpit?

Using Mat4.lookAt  Center – the point the viewer is looking at.  You know a plane can rotate along any of the 3 axes. When does the point change?  Hint for implementation:  Does it really have to be that exact point in the distance?  What could you do to ensure that you always get a point such that you are looking the same way?

Using Mat4.lookAt  Up Vector!  Up Vector is local to the camera. Not the same as the Global Up Vector!  So, it changes as the flight rotates.  For instance, imagine you are changing the nose of the airplane to point more upwards. Is upwards always the same with respect to the Global and Local vectors?

Where to start?  Imagine how a plane starts on the runway. What are its axes?  Allow your flight-sim to always start with the same axes. Then, you know the initial values.  (Think about how the default OpenGL camera works. What are its axes?)

One way of doing it..  Assume the plane starts in with 0 rotation.  Keep one quaternion that represents the entire rotation so far.  Every time there is a new rotation, we can take it into account by changing that quaternion.  Then, at every frame, we apply this rotation to the initial state.  Then we make the lookAt matrix.  You could come up with another way if you want.

Tutorial:  present_rotation present_rotation

Passing the Matrices in.  The matrices generated from the glmatrix functions can be directly passed in by:  var projMatrixUniform = gl.getUniformLocation(ShaderProgram, "projectionMatrix"); //  gl.uniformMatrix4fv(projMatrixUniform, false, projectionMatrix); //  You want to use something like this to pass in your matrices to the shader pipeline.

Generating Terrain  You need to have something to fly over  Terrain can be implemented as a height map  result will only be semi-realistic, but good enough for now  Cover a rectangular area with triangles  Have x and z arranged in a grid pattern  Generate a y coordinate  Compute averaged per-vertex normals  You can use the diamond-square algorithm to generate a fractal terrain 