Chapter 3: Modeling Transformation

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

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

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

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

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

CS 4204 Computer Graphics

OpenGL Transformations

Fundamental Types of Viewing

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

Using GLU/GLUT Objects

Transformations. CSCI 420 Computer Graphics Lecture 4

CSC 470 Computer Graphics

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

Lecture 4 of 41. Lab 1a: OpenGL Basics

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

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);

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

Hierarchical Modeling

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

Notes on Assignment. Notes on Assignment. Notes on Assignment. Notes on Assignment

Luiz Fernando Martha André Pereira

Affine Transformations in 3D

Computer Viewing Computer Graphics I, Fall 2008

Lecture 4. Viewing, Projection and Viewport Transformations

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

Overview. By end of the week:

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

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

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

Lecture 5b. Transformation

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

// double buffering and RGB glutinitdisplaymode(glut_double GLUT_RGBA); // your own initializations

Computer Graphics. Chapter 7 2D Geometric Transformations

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

Order of Transformations

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

Rendering Pipeline and Coordinates Transforms

Modeling Objects by Polygonal Approximations. Linear and Affine Transformations (Maps)

Graphics pipeline and transformations. Composition of transformations

OpenGL refresher. Advanced Computer Graphics 2012

CS354 Computer Graphics Viewing and Modeling

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

3.2 Hierarchical Modeling

COMP 175 COMPUTER GRAPHICS. Lecture 07: Scene Graph. COMP 175: Computer Graphics March 10, Remco Chang 07 Scene Graph

1 (Practice 1) Introduction to OpenGL

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

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

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

CITSTUDENTS.IN VIEWING. Computer Graphics and Visualization. Classical and computer viewing. Viewing with a computer. Positioning of the camera

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

Where We Are: Static Models

Computer Graphics Geometric Transformations

CIS 636 Interactive Computer Graphics CIS 736 Computer Graphics Spring 2011

C OMPUTER G RAPHICS Thursday

Modeling Objects. Modeling. Symbol-Instance Table. Instance Transformation. Each appearance of the object in the model is an instance

Exercise Max. Points Total 90

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

Modeling with Transformations

To Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3)

3D Viewing. With acknowledge to: Ed Angel. Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

OpenGL. Toolkits.

CS 4204 Computer Graphics

Computer Graphics. Bing-Yu Chen National Taiwan University

3D Viewing Episode 2

GL_MODELVIEW transformation

Transformations IV. Week 3, Wed Jan 20

UNIT 4 GEOMETRIC OBJECTS AND TRANSFORMATIONS-1

Lecture 2 2D transformations Introduction to OpenGL

EECE 478. Learning Objectives. Learning Objectives. Linear Algebra and 3D Geometry. Linear algebra in 3D. Coordinate systems

To Do. Outline. Translation. Homogeneous Coordinates. Foundations of Computer Graphics. Representation of Points (4-Vectors) Start doing HW 1

Introduction to OpenGL

Computer Graphics. Chapter 10 Three-Dimensional Viewing

Transformation Pipeline

CSCI E-74. Simulation and Gaming

Overview. Viewing and perspectives. Planar Geometric Projections. Classical Viewing. Classical views Computer viewing Perspective normalization

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

Last week. Machiraju/Zhang/Möller/Fuhrmann

7. 3D Viewing. Projection: why is projection necessary? CS Dept, Univ of Kentucky

Transformations III. Week 2, Fri Jan 19

CS380: Computer Graphics Viewing Transformation. Sung-Eui Yoon ( 윤성의 ) Course URL:

Introduction to Computer Graphics with OpenGL/GLUT

Humanoid Robotics. Projective Geometry, Homogeneous Coordinates. (brief introduction) Maren Bennewitz

Graphics and Visualization

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

Hierarchical Modeling

Name: [20 points] Consider the following OpenGL commands:

Transformations. CSCI 420 Computer Graphics Lecture 5

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

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

GEOMETRIC TRANSFORMATIONS AND VIEWING

Lecture 4: Transforms. Computer Graphics CMU /15-662, Fall 2016

OpenGL Tutorial. Ceng 477 Introduction to Computer Graphics

Introduction to OpenGL Transformations, Viewing and Lighting. Ali Bigdelou

CS 4204 Computer Graphics

Transforms 1 Christian Miller CS Fall 2011

CS D Transformation. Junqiao Zhao 赵君峤

Chap 3 Viewing Pipeline Reading: Angel s Interactive Computer Graphics, Sixth ed. Sections 4.1~4.7

HIERARCHICAL TRANSFORMATIONS A Practical Introduction

3D Viewing. CS 4620 Lecture 8

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

Transcription:

Chapter 3: Modeling Transformation Graphics Programming, 8th Sep. Graphics and Media Lab. Seoul National University 2011 Fall

OpenGL Steps Every step in the graphics pipeline is related to the transformation. 2 Graphics and Media Lab. at Seoul National University

Related Transformations (1/2) Euclidean (Rigid) motion Preserves distance & angle. Similarity motion Preserves angle. Linear motion Preserves linearity. 3 Graphics and Media Lab. at Seoul National University

Related Transformations (2/2) Affine motion Preserves parallel line. Projective motion Preserves line. How to represent? 4 Graphics and Media Lab. at Seoul National University

Transformation Classes Euclidean transformation(se3) Preserves distance & angle.(translation, Rotation) Similarity transformation Preserves angles.(rotation, Isotropic scaling) Linear transformation(gl3) Preserves linearity.(rotation,scaling,reflection,shear) Affine transformation Preserves parallel lines. Projective transformation Preserves lines. 4x4 Matrix! How about 3D points? 5 Graphics and Media Lab. at Seoul National University

Homogeneous Coordinates We augment a point in R 3 for the transformation matrices. a 00 Modelview matrix has the form a a 0 10 20 a a a 0 01 11 21 a a a 02 12 22 0 t t t 1 2 3 1 Projection matrix has the form (The next class!) Point [x y z 1] T The result of transformation needs to be divided by w to give the 3D position. (homogeneous) Vector [x y z 0] T w=0 represents a point at infinity. (Only direction differentiates.) 6 Graphics and Media Lab. at Seoul National University

Modelview & Projection matrix OpenGL helps us to change the two most important transformation matrices: Modelview Matrix The relative transformation between object and camera Projection Matrix Clipping volume (viewing frustum) Projection to screen Vertices(primitives) are transformed by P*M. P * M * 7 Graphics and Media Lab. at Seoul National University

Code Example from Ch.2 Draw a transformed box in 3d. 8 Graphics and Media Lab. at Seoul National University

Code Example 1 Resize() function was added. A few experiments with modeling transform 9 Graphics and Media Lab. at Seoul National University

Result 10 Graphics and Media Lab. at Seoul National University

Code Example 1 - Explanation glutmainloop() instructs the program to enter the event processing loop. glutreshapefunc() registers the resizing function as the callback function. glclear( ) clears video buffers. glviewport(x,y,w,h) sets the screen space. glmatrixmode(gl_projection) tells that we modify the projection matrix. glmatrixmode(gl_modelview) tells that we modify the modelview matrix. glloadidentity() replaces the current matrix with the identity matrix. glortho(l,r,b,t,zn,zf) sets the clipping space orthographically. This changes the projection matrix. gltranslatef(),glrotatef(), and glscalef() change the modelview matrix. 11 Graphics and Media Lab. at Seoul National University

The Order of Transformations Application glloadidentity(); glmultmatrixf(n); glmultmatrixf(m); glmultmatrixf(l); glbegin(gl_points); glvertex3f(v); glend(); // C = I // C = N // C = NM // C = NML // NMLv 12 Graphics and Media Lab. at Seoul National University

The Order is Important 45 deg rotation around z-axis then 10 unit translation along +x, and vice versa. 13 Graphics and Media Lab. at Seoul National University

Thinking in Terms of Fixed Coords Code for rot then trans wrt fixed coords. glmatrixmode(gl_modelview); glloadidentity(); glmultmatrixf(t); glmultmatrixf(r); draw_the_object(); 14 Graphics and Media Lab. at Seoul National University

Thinking in Terms of Local Coords Code for trans then rot wrt local coords. glmatrixmode(gl_modelview); glloadidentity(); glmultmatrixf(t); glmultmatrixf(r); draw_the_object(); 15 Graphics and Media Lab. at Seoul National University

Thinking in Terms of Local Coords Code for rot then trans wrt local coords. glmatrixmode(gl_modelview); glloadidentity(); glmultmatrixf(r); glmultmatrixf(t); draw_the_object(); 16 Graphics and Media Lab. at Seoul National University

Push & Pop We can manage the hierarchy by glpushmatrix(), glpopmatrix(). P * M Push M1 Pop Push Pop M2 * * * Vertices of arm Vertices of shoulder Vertices of body 17 Graphics and Media Lab. at Seoul National University

Code Example 2 Robot arm unit cube: [-0.5,0.5]^3 18 Graphics and Media Lab. at Seoul National University

Result 19 Graphics and Media Lab. at Seoul National University

Code Example 2 - Explanation glutkeyboardfunc() registers the key function as the callback function: If s is pressed, rotate shoulder If S is pressed, rotate shoulder reversely If e is pressed, rotate elbow If E is pressed, rotate elbow reversely glpushmatrix() saves the current matrix. glpopmatrix() loads the saved matrix. gluperpective(fov,ratio,zn,zf) sets the view frustum. This changes the projection matrix. gltranslatef(0,0,-1); glrotatef(-angle,0,0,1); gltranslatef(0,0,1); The rotation about a point 20 Graphics and Media Lab. at Seoul National University