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

Similar documents
Using GLU/GLUT Objects

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

Computer Graphics (CS 543) Lecture 6a: Hierarchical 3D Models. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Transformations. Rotation and Scaling

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

Hierarchical Modeling

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

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

3.2 Hierarchical Modeling

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

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

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

Hierarchical Modelling

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

Transforms 1 Christian Miller CS Fall 2011

Hierarchical Modeling

Hierarchical Modeling and scene graphs

Hierarchical Modeling and Scene Graphs

Hierarchical Modeling and Scene Graphs

OpenGL: Setup 3D World

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

Modeling with Transformations

Computer Graphics Hands-on

Chapter 3: Modeling Transformation

OpenGL Transformations

Hierarchy I. Guoying Zhao 1 / 40

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

Hierarchical Models. Roadmap. Importance of shadows. Importance of shadows. Importance of shadows. Importance of shadows

Outline. Introduction Surface of Revolution Hierarchical Modeling Blinn-Phong Shader Custom Shader(s)

CIS 636 Interactive Computer Graphics CIS 736 Computer Graphics Spring 2011

CSC 470 Computer Graphics

HIERARCHICAL TRANSFORMATIONS A Practical Introduction

TIEA311 Tietokonegrafiikan perusteet kevät 2018

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

Graphics pipeline and transformations. Composition of transformations

Affine Transformations in 3D

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

Lecture 5b. Transformation

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

Where We Are: Static Models

Graphics and Visualization

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

GL_MODELVIEW transformation

Lecture 08: Hierarchical Modeling with Scene Graphs

Transformations IV. Week 3, Wed Jan 20

Luiz Fernando Martha André Pereira

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

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

Computer Graphics. Prof. Feng Liu. Fall /21/2016

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

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

Introduction to OpenGL Transformations, Viewing and Lighting. Ali Bigdelou

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

Due: Thursday, April 28 th by the stroke of midnight! TA: Jeff Booth

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

Graphical Objects and Scene Graphs

Maya Lesson 3 Temple Base & Columns

Transformation Pipeline

6.837 Computer Graphics Hierarchical Modeling Wojciech Matusik, MIT EECS Some slides from BarbCutler & Jaakko Lehtinen

3D Graphics Pipeline II Clipping. Instructor Stephen J. Guy

Rendering Pipeline and Coordinates Transforms

Due: Thursday, February 6 th, 11:59 pm TA: Mason Remy

HIERARCHICAL TRANSFORMATIONS A Practical Introduction

HIERARCHICAL TRANSFORMATIONS A Practical Introduction

Computer graphics MN1

Fundamental Types of Viewing

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

CHAPTER 1 Graphics Systems and Models 3

CS 465 Program 4: Modeller

12. Selection. - The objects selected are specified by hit records in the selection buffer. E.R. Bachmann & P.L. McDowell MV 4202 Page 1 of 13

Computer Graphics Geometric Transformations

COMP3421. Week 2 - Transformations in 2D and Vector Geometry Revision

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

Transformations. CSCI 420 Computer Graphics Lecture 4

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

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

Computer Graphics. Chapter 10 Three-Dimensional Viewing

CS354 Computer Graphics Viewing and Modeling

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

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

Computer Viewing Computer Graphics I, Fall 2008

Advanced Computer Graphics (CS & SE )

Transformations III. Week 2, Fri Jan 19

COMP3421. Week 2 - Transformations in 2D and Vector Geometry Revision

EECE 478. Learning Objectives. Learning Objectives. Rasterization & Scenes. Rasterization. Compositing

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

Computer Graphics. Transformations. CSC 470 Computer Graphics 1

Computer Graphics. Chapter 7 2D Geometric Transformations

Precept 2 Aleksey Boyko February 18, 2011

6. Modelview Transformations

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

Review of Thursday. xa + yb xc + yd

CS 591B Lecture 9: The OpenGL Rendering Pipeline

SE313: Computer Graphics and Visual Programming. Computer Graphics Notes Gazihan Alankus, Fall 2011

Introduction to OpenGL

E.Order of Operations

Transformations IV. Week 3, Mon Jan 22

Fachhochschule Regensburg, Germany, February 15, 2017

9. [20 points] A degree three Bezier curve q(u) has the four control points p 0 = 0,0, p 1 = 2,0, p 2 = 0,2, and p 3 = 4,4.

Transcription:

Transformations Two possible ways to specify transformations Each part of the object is transformed independently relative to the origin - Not convenient! z y Translate the base by (5,0,0); Translate the lower arm by (5,00); Translate the upper arm by (5,00); x

Hierarchical Transformation A better (and easier) way: Hierarchical (relative) transformation: ti Specify the transformation for each object relative to its parent (or the current local reference e e frame)

Object Dependency A graphical scene often consists of many small objects The attributes of an object (positions, orientations) can depend on each other A Robot Hammer! hammer upper arm lower arm base

Hierarchical Representation - Scene Graph We can describe the object dependency using a tree structure Root node Base Lower arm The position and orientation of an object can be affected by its parent, grand-parent, grand-grand-parent nodes Leaf node Upper arm Hammer This hierarchical representation is referred to as Scene Graph

Hierarchical Transformation Relative transformation: Specify the transformation for each object relative to its parent S 1 T l h b d Step 1: Translate the base and its descendants by (5,0,0);

Hierarhical Transformation (2) Step 2: Rotate the lower arm and all its descendants relative to its local y axis by -90 degree y y z z x x

Hierarchical Transformation(3) Represent hierarhical transformations using scene graph Base Translate (5,0,0) Lower arm Rotate (-90) about its local y Upper arm Hammer Apply all the way down Apply all the way down

Incremental update of the modeling transformation matrix Translate base and all its descendants by (5,0,0) Rotate the lower arm and its descendants by -90 degree about the local y Initialize your matrix to identity I Base Lower arm Upper arm Hammer M1 <- Translatef(5,0,0); M=MxM1 M M1 Draw_base(); // apply M to the vertices M2 = Rotatef(-90, 0, 1, 0); M = M x M2 // accumulate M2 to M Draw_lower _arm(); Draw_upper_arm(); Draw_hammer();

OpenGL Fixed Function Pipeline Translate base and all its descendants by (5,0,0) Rotate the lower arm and its descendants by -90 degree about the local y glmatrixmode(gl_modelview); glloadidentity(); Base Lower arm Upper arm Hammer gltranslatef(5,0,0); Draw_base(); glrotatef(-90, 0, 1, 0); Draw_lower _arm(); Draw_upper_arm(); Draw_hammer();

A more complicated example How about this model? left hammer Right hammer Scene Graph? base Lower arm Lower arm Upper arm Upper arm base Hammer (left hammer) Hammer (right hammer)

Do this Base and everything translate (5,0,0) Left hammer rotate 75 degree about the local y Right hammer rotate -75 degree about the local y

Depth-first traversal Program this transformation by depth-first traversal base Lower arm Lower arm Do Draw base transformation(s) Upper arm Upper arm Hammer Hammer (left hammer) (right hammer) Depth First Traversal Do transformation(s) Draw left arm Do transformation(s) Draw right arm What are they?

How about this? base Lower arm Upper arm Hammer (left hammer) Lower arm Upper arm Hammer (right hammer) Translate(5,0,0) Draw base Rotate(75, 0, 1, 0) Draw left hammer What s wrong?! Rotate(-75, 0, 1, 0) Draw right hammer

Something is wrong What s wrong? We want to transform the right hammer relative to the base, not to the left hammer How about this? Do Translate(5,0,0) Draw base Do Rotate(75, 0, 1, 0) Draw left hammer What s wrong?! We should undo the left hammer transformation before we transform the right hammer Need to undo this first Do Rotate(-75 75, 0, 1, 0) Draw right hammer

Undo the previous transformation(s) Need to save the modelview matrix right after we draw base Initial modelview M Translate(5,0,0) -> M = M x T Draw base Rotate(75, 0, 1, 0) Draw left hammer Rotate(-75 75, 0, 1, 0) Undo the previous transformation means we want to restore the Modelview Matrix M to what it was here ie i.e., savemrighthere here And then restore the saved Modelview Matrix Draw right hammer

Matrix Stack We can use OpenGL Matrix Stack to perform matrix save and restore Initial modelview M Do Translate(5,0,0) -> M = M x T * Store the current modelview matrix - Make a copy of the current matrix and push into a Matrix Stack Draw base Do Rotate(75, 0, 1, 0) Draw left hammer Do Rotate(-75 75, 0, 1, 0) - continue to modify the current matrix * Restore the saved Matrix -Popthe top of the matrix stackand copy it back to the current Modelview Matrix: Draw right hammer

OpenGL Fixed Function Pipeline Matrix Stack OpenGL fixed function pipeline has a Matrix Stack to perform matrix save and restore Initial modelview M Do Translate(5,0,0) -> M = M x T Draw base glpushmatrix() Do Rotate(75, 0, 1, 0) Draw left hammer Do Rotate(-75 75, 0, 1, 0) glpopmatrix() Draw right hammer

Push and Pop Matrix Stack Nested push and pop operations Model matrix (M) Stack // Transform using M1; // Transform using M2; Push Matrix(); // Transform using M3 Push Matrix();.. // Transform using M4 Pop Matrix(); // Transform using M5 Pop Matrix(); M = M1 M = M1 x M2 M = M1 x M2 x M3 M1xM2 M1xM2xM3 M1 x M2 M = M1 x M2 x M3 x M4 M = M1 x M2xM3 M1 x M2 M = M1 x M2 x M3 x M5 M = M1 x M2

Push and Pop Matrix Stack Nested push and pop operations glmatrixmode(gl_modelview); MODELVIEW); glloadidentity(); // Transform using M1; // Transform using M2; glpushmatrix(); // Transform using M3 glpushmatrix();.. // Transform using M4 glpopmatrix(); // Transform using M5 glpopmatrix(); Modelview matrix (M) Stack M = I M = M1 M = M1 x M2 M1xM2 M = M1 x M2 x M3 M1xM2xM3 M1 x M2 M = M1 x M2 x M3 x M4 M = M1 x M2 x M3 M1 x M2 M = M1 x M2 x M3 x M5 M = M1 x M2

Push and Pop Matrix Stack A simple OpenGL routine: push Lower arm base pop Lower arm gltranslate(5,0,0) Draw_base(); glpushmatrix(); Upper arm Upper arm glrotate(75, 0,1,0); Draw_left_hammer(); Hammer Hammer (left hammer) (right hammer) Depth First Traversal glpopmatrix(); glrotate(-75, 0,1,0); Draw_right_hammer(); right hammer();

Creating your own objects Create simple geometry primitives Cone Cube Cylinder Teapot

Objects in local coordinates It is more convenient to create all objects with a default size, position, and orientation, i.e., defined in their local l coordinate systems Then you can perform modeling transformation to make it right for you Cube(1.0) Put a 1x1x1 cube with its center at world (0,0,0) T t 2 0 1 2 t bl t l (2 0 1 2) b f To create a 2 x 0.1 x 2 table top - you can scale (2, 0.1, 2) before you Draw the Cube(1.0)

Cylinder() Three steps to create a cylinder Cylinder(base, top, height, slice, stacks) Base z y base radius x The default position is with base at z = 0 plane top radius height num. of vertical lines num. of horizontal lines

Cone() z y Cone(base, height, slices, stacks) - A polygon approximation of a cone. Base x Default position: its base at Z = 0 plane base: the width of its base height: the height of the cone slices: the number of vertical lines used to make up the cone stace: the number of horizontal lines used to make up the cone

Teapot, Bunny etc There are many famous geometric models on the web that you can use. For example, Utah Teapot, Stanford Bunny etc Read the PLY help in our class web site for more information