GL_MODELVIEW transformation

Similar documents
Computer Graphics. Chapter 7 2D Geometric Transformations

Lecture 5b. Transformation

Using GLU/GLUT Objects

CS 428: Fall Introduction to. Transformations in OpenGL + hierarchical modeling. Andrew Nealen, Rutgers, /21/2009 1

Computer Graphics Geometric Transformations

API for creating a display window and using keyboard/mouse interations. See RayWindow.cpp to see how these are used for Assignment3

CS 4204 Computer Graphics

Fall CSCI 420: Computer Graphics. 2.2 Transformations. Hao Li.

Spring 2013, CS 112 Programming Assignment 2 Submission Due: April 26, 2013

Transformations. CSCI 420 Computer Graphics Lecture 4

CS4202: Test. 1. Write the letter corresponding to the library name next to the statement or statements that describe library.

The Viewing Pipeline adaptation of Paul Bunn & Kerryn Hugo s notes

Modeling with Transformations

CSC 470 Computer Graphics

Lecture 6 Sections 4.3, 4.6, 4.7. Wed, Sep 9, 2009

Computer Graphics. Chapter 10 Three-Dimensional Viewing

蔡侑庭 (Yu-Ting Tsai) National Chiao Tung University, Taiwan. Prof. Wen-Chieh Lin s CG Slides OpenGL 2.1 Specification

OpenGL. Toolkits.

CSCI E-74. Simulation and Gaming

Questions HW1 Transform Q/A. Transform. Shaoting Zhang. May 11, 2008

Lecture 5: Viewing. CSE Computer Graphics (Fall 2010)

DH2323 DGI16 Lab2 Transformations

3D Transformation. In 3D, we have x, y, and z. We will continue use column vectors:. Homogenous systems:. x y z. x y z. glvertex3f(x, y,z);

Translation. 3D Transformations. Rotation about z axis. Scaling. CS 4620 Lecture 8. 3 Cornell CS4620 Fall 2009!Lecture 8

Modeling Transform. Chapter 4 Geometric Transformations. Overview. Instancing. Specify transformation for objects 李同益

Introduction to 3D Graphics with OpenGL. Z-Buffer Hidden Surface Removal. Binghamton University. EngiNet. Thomas J. Watson

Affine Transformations in 3D

Order of Transformations

Transformation Pipeline

Precept 2 Aleksey Boyko February 18, 2011

Hidden Surface Removal. 3D Graphics with OpenGL. Back-Face Culling

Lecture 4: Transformations and Matrices. CSE Computer Graphics (Fall 2010)

Hierarchical Modeling. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

CSE 690: GPGPU. Lecture 2: Understanding the Fabric - Intro to Graphics. Klaus Mueller Stony Brook University Computer Science Department

CS354 Computer Graphics Viewing and Modeling

C OMPUTER G RAPHICS Thursday

Reading. Hierarchical Modeling. Symbols and instances. Required: Angel, sections , 9.8. Optional:

Graphics Pipeline & APIs

Lecture 4 of 41. Lab 1a: OpenGL Basics

Transformation, Input and Interaction. Hanyang University

Computer Viewing Computer Graphics I, Fall 2008

Computer graphics MN1

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches:

6. Modelview Transformations

CIS 636 Interactive Computer Graphics CIS 736 Computer Graphics Spring 2011

Computer Graphics (CS 4731) Lecture 11: Implementing Transformations. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Books, OpenGL, GLUT, GLUI, CUDA, OpenCL, OpenCV, PointClouds, and G3D

Computer Graphics. Chapter 5 Geometric Transformations. Somsak Walairacht, Computer Engineering, KMITL

Graphics Pipeline & APIs

Rendering Pipeline and Coordinates Transforms

Luiz Fernando Martha André Pereira

Using GLU/GLUT Objects. GLU/GLUT Objects. glucylinder() glutwirecone() GLU/GLUT provides very simple object primitives

Viewing and Modeling

Prof. Feng Liu. Fall /19/2016

COMP Computer Graphics and Image Processing. 5: Viewing 1: The camera. In part 1 of our study of Viewing, we ll look at ˆʹ U ˆ ʹ F ˆʹ S

1 Transformations. Chapter 1. Transformations. Department of Computer Science and Engineering 1-1

Two possible ways to specify transformations. Each part of the object is transformed independently relative to the origin

Computer Graphics Hands-on

Hierarchical Modeling II. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Computer Graphics Lighting

Computer Graphics Lighting. Why Do We Care About Lighting?

CS D Transformation. Junqiao Zhao 赵君峤

Transforms 1 Christian Miller CS Fall 2011

Books, OpenGL, GLUT, CUDA, OpenCL, OpenCV, PointClouds, G3D, and Qt

Hierarchical Modeling: Tree of Transformations, Display Lists and Functions, Matrix and Attribute Stacks,

Describe the Orthographic and Perspective projections. How do we combine together transform matrices?

Graphics and Visualization

Lecture 2 2D transformations Introduction to OpenGL

Rendering Pipeline/ OpenGL

An Interactive Introduction to OpenGL Programming

Cheating: In case of cheating, all parts involved (source(s) and receiver(s)) get zero.

Projection: Mapping 3-D to 2-D. Orthographic Projection. The Canonical Camera Configuration. Perspective Projection

CS559: Computer Graphics. Lecture 12: OpenGL Transformation Li Zhang Spring 2008

Hierarchical Modeling and scene graphs

Scene Graphs. CS4620/5620: Lecture 7. Announcements. HW 1 out. PA 1 will be out on Wed

OpenGL: Open Graphics Library. Introduction to OpenGL Part II. How do I render a geometric primitive? What is OpenGL

Today s Agenda. Basic design of a graphics system. Introduction to OpenGL

Computer graphics MN1

lecture 9 Object hierarchies - call trees and GL_MODELVIEW stack - fractals - L systems

CS 543: Computer Graphics Midterm review. Emmanuel Agu

Introduction to OpenGL Transformations, Viewing and Lighting. Ali Bigdelou

Getting Started. Overview (1): Getting Started (1): Getting Started (2): Getting Started (3): COSC 4431/5331 Computer Graphics.

Introduction to OpenGL

Transformations. CSCI 420 Computer Graphics Lecture 5

Transformations. OpenGL Transformations. 4x4 Model-view Matrix (this lecture) OpenGL Transformation Matrices. 4x4 Projection Matrix (next lecture)

Chapter 3: Modeling Transformation

Hierarchical Modeling and Scene Graphs

3D Viewing Episode 2

OpenGL Transformations

CS 591B Lecture 9: The OpenGL Rendering Pipeline

CS380: Computer Graphics 2D Imaging and Transformation. Sung-Eui Yoon ( 윤성의 ) Course URL:

Computer Graphics (CS 4731) Lecture 11: Implementing Transformations. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Notes. University of British Columbia

GRAFIKA KOMPUTER. ~ M. Ali Fauzi

OpenGL: Setup 3D World

Transformations Computer Graphics I Lecture 4

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

Computer Graphics 7: Viewing in 3-D

1/29/13. Computer Graphics. Transformations. Simple Transformations

part 3 Martin Samuelčík Room I4

Transcription:

lecture 3 view transformations model transformations GL_MODELVIEW transformation

view transformations: How do we map from world coordinates to camera/view/eye coordinates? model transformations: How do we map from object coordinates to world coordinates? GL_MODELVIEW transformation How do we map from object (to world) to view coordinates?

How can we specify the viewer's coordinate system?

Define the z axis of the viewer by a vector from the 'look at' point to the viewer.

The z coordinate axis of the viewer is a unit vector in the direction is from the 'look at' point to the viewer.

To specify the viewer's x and y coordinate axes, we need to choose from 360 degrees of possibilities. Which way is up?

Define any 3D vector Vup such that This defines a plane, containing Vup and z_c.

will be defined to lie in this plane.

See lecture notes for the calculation.

As a programmer using OpenGL, you don't have to compute these vectors. Instead you just define: eye =... // 3D points lookat =... up =... glulookat( eye[0], eye[1], eye[2], lookat[0], lookat[1], lookat[2], up[0], up[1], up[2] ) What does this definition do ("under the hood")? Coming soon...

What is the relationship between the world coordinate system and the viewer's coordinate system?

To re-map a general scene point (x,y,z) from world coordinates to viewer coordinates, we translate and rotate.

Let the viewer's position be expressed in world coordinates. The matrix T translates the viewer's position to the origin.

R rotates into the viewer's orientation.

Recall slide 7 from lecture 2. R maps to a new coordinate system by projecting onto new axes.

view transformations: How do we map from world coordinates to camera/view/eye coordinates? model transformations: How do we map from object coordinates to world coordinates? GL_MODELVIEW transformation How do we map from object (to world) to view coordinates?

glvertex3f(x1, y1, z1) glvertex3f(x2, y2, z2) glvertex3f(x3, y3, z3)

glbegin( GL_LINES ) glvertex3f(x1, y1, z1) glvertex3f(x2, y2, z2) glvertex3f(x3, y3, z3) glvertex3f(x4, y4, z4) // more vertex pairs gives more lines glend()

glbegin( GL_TRIANGLES ) glvertex3f(x1, y1, z1) glvertex3f(x2, y2, z2) glvertex3f(x3, y3, z3) // more vertex triples gives more triangles glend()

glbegin( GL_POLYGON ) glvertex3f(x1, y1, z1) glvertex3f(x2, y2, z2) glvertex3f(x4, y4, z4) glvertex3f(x3, y3, z3) glend()

"Quadric" (Quadratic) Surfaces: examples

Quadric Surfaces: General

Recall homogeneous coordinates. Same quadric surface is represented if we scale 4D vector by a constant.

Q: What is this surface? (a, b, c > 0) A: rotated and translated ellipsoid.

How to define quadric surfaces in OpenGL? GLUquadricObj myquadric = glunewquadric() glusphere(myquadric,...) parameters glucylinder(myquadric,...) // need to supply

Non-quadric surfaces from OpenGL Utility Toolkit (GLUT) glutsolidcube() glutwirecube() glutsolidtorus() glutwiretorus() glutsolidteapot() glutwireteapot()

How to transform objects in OpenGL? glrotatef( vx, vy, vz, angle ) gltranslatef( x, y, z) glscalef( sx, sy, sz) The parameters of each of these calls specify a 4x4 matrix. These transformations are not associated with (bound to) any particular object, however. We'll see how this works next.

Recall how to transform from world coordinates to viewer coordinates:

How to transform from dog (object) coordinates to viewer coordinates?

glulookat(... ) gltranslate(... ) glrotate(... )

glulookat(... ) // transform from world coordinates // to viewer/eye coordinates gltranslate(... ) // transform position and orientation glrotate(... ) // of dog to world coordinates glvertex( ) // etc. all the triangles of the dog object... // defined in dog coordinate system

GL_MODELVIEW OpenGL is a "state machine". One of its states is the GL_MODELVIEW matrix. This is a 4x4 matrix that transforms a vertex into eye coordinates. We would like : GL_MODELVIEW

glmatrixmode(gl_modelview) glloadidentity() initializes: GL_MODELVIEW ASIDE: How to examine the GL_MODELVIEW matrix? (python) m = (GLfloat * 16)() glgetfloatv(gl_modelview_matrix,m) glmodelviewmatrix = [ [ ],[ ], [ ], [ ] ] for i in range(16): glmodelviewmatrix[i % 4].append(m[i]) print 'GL_MODELVIEW ', glmodelviewmatrix # OpenGL stores in column major order

GL_MODELVIEW Q: What happens when you make these calls? Answer: glulookat(... ) glrotatef(... ) gltranslatef(... ) glscalef(... )

Problem: the GL_MODELVIEW matrix only keeps track of one (model to view) transformation. But we may have hundreds of object models. How do we keep track of all these transformations? glmatrixmode(gl_modelview) glloadidentity() glulookat( eye..., lookat..., up...) gltranslate(...) glrotate(...) drawdog() gltranslate(...) glrotate(...) drawhouse() // glvertex() etc... // glvertex() etc...

Solution: use a stack of GL_MODELVIEW transformations. glmatrixmode(gl_modelview) glloadidentity() glulookat( eye..., lookat..., up...) glpushmatrix() gltranslate(...) glrotate(...) drawdog() glpopmatrix() glpushmatrix() gltranslate(...) glrotate(...) drawhouse() glpopmatrix()

Summary of Today viewer coordinate systems view transformations : glulookat() model transformations : glrotate(), gltranslate(), glscale() GL_MODELVIEW transformation