HIERARCHICAL TRANSFORMATIONS A Practical Introduction

Similar documents
HIERARCHICAL TRANSFORMATIONS A Practical Introduction

HIERARCHICAL TRANSFORMATIONS A Practical Introduction

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

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

Computer Graphics Hands-on

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

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

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

Hierarchical Modeling

Transformations. Rotation and Scaling

IMAGE-BASED RENDERING AND ANIMATION

OUTLINE. Hierarchical Models Z-Fighting Primitives Besides Triangles Back Face Culling

Transforms 1 Christian Miller CS Fall 2011

RASTERISED RENDERING

TIEA311 Tietokonegrafiikan perusteet kevät 2018

Using GLU/GLUT Objects

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

DH2323 DGI16 Lab2 Transformations

Overview. By end of the week:

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

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

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

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

Where We Are: Static Models

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

Hierarchical Modeling

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

3D Mathematics. Co-ordinate systems, 3D primitives and affine transformations

Graphics pipeline and transformations. Composition of transformations

Introduction to OpenGL

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

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

Transformations IV. Week 3, Wed Jan 20

Chapter 3: Modeling Transformation

Lessons from Scene Graphs: Using Scene Graphs to Teach Hierarchical Modeling

Computer Graphics I. Midterm Examination. October 23, This is a closed-book exam; only one double-sided sheet of notes is permitted.

Hierarchical Modelling

3.2 Hierarchical Modeling

OpenGL Transformations

Hierarchical Modeling and Scene Graphs

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

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

CS354 Computer Graphics Character Animation and Skinning

Lecture 5b. Transformation

Hierarchical Modeling and scene graphs

Hierarchical Modeling. CS 432 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

OpenGL: Setup 3D World

Lecture 08: Hierarchical Modeling with Scene Graphs

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

Computer Graphics Hands-on

CS-184: Computer Graphics. Today. Forward kinematics Inverse kinematics. Wednesday, November 12, Pin joints Ball joints Prismatic joints

Luiz Fernando Martha André Pereira

Review of Thursday. xa + yb xc + yd

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

Transform 1: Translate, Matrices

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

Hierarchical Modeling and Scene Graphs

CS 559 Computer Graphics Midterm Exam March 22, :30-3:45 pm

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

2D/3D Geometric Transformations and Scene Graphs

Hierarchical Models Josef Pelikán & Alexander Wilkie CGG MFF UK Praha

CSC 470 Computer Graphics

Chapter 3 - Basic Mathematics for 3D Computer Graphics

Lecture 5: Transforms II. Computer Graphics and Imaging UC Berkeley CS184/284A

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

Hierarchy I. Guoying Zhao 1 / 40

EDAF80 Introduction to Computer Graphics. Seminar 1. Hierarchical Transformation. Michael Doggett. Some slides by Carl Johan Gribel,

CS 4620 Program 3: Pipeline

Animation. CS 4620 Lecture 32. Cornell CS4620 Fall Kavita Bala

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

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

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

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

CHAPTER 1 Graphics Systems and Models 3

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

CSE 167: Introduction to Computer Graphics Lecture 11: Scene Graph 2. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013

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

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

6.837 Introduction to Computer Graphics Assignment 5: OpenGL and Solid Textures Due Wednesday October 22, 2003 at 11:59pm

Graphical Objects and Scene Graphs

CS 4204 Computer Graphics

Basic Elements. Geometry is the study of the relationships among objects in an n-dimensional space

CMSC427 Transformations II: Viewing. Credit: some slides from Dr. Zwicker

CSE 167: Introduction to Computer Graphics Lecture #10: View Frustum Culling

CS 4620 Midterm 1. Tuesday 22 October minutes

Lecture 4 Advanced Computer Graphics (CS & SE )

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.

Rendering Pipeline and Coordinates Transforms

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

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

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

SM2231 :: 3D Animation I :: Basic. Rigging

Transformations. CSCI 420 Computer Graphics Lecture 4

Lecture 18 of 41. Scene Graphs: Rendering Lab 3b: Shader

Better Interactive Programs. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Set the current projection to perspective with the given field of view angle (degrees)

CMSC 425: Lecture 10 Basics of Skeletal Animation and Kinematics

This week. CENG 732 Computer Animation. Warping an Object. Warping an Object. 2D Grid Deformation. Warping an Object.

Lecture 4. Viewing, Projection and Viewport Transformations

Computer Graphics Geometric Transformations

Transcription:

HIERARCHICAL TRANSFORMATIONS A Practical Introduction HPCViz, KTH Royal Institute of Technology, Sweden https://www.kth.se/profile/chpeters/

Transformations Many objects are composed of hierarchies Transformations enable us to compose hierarchies

Geometric primitives (a brief introduction) Graphical objects are composed of primitives More about geometry in subsequent lectures

Transformations Recall translation from previous lecture:

Translating an object Translation operation takes place on a point But a geometric object (mesh) is a collection of vertices How to translate that? Translate each of its vertices

Rotating an object Rotation operation takes place on a point How to rotate a object? The same procedure applies: Rotate each vertex that comprises the object (from the previous lecture)

World space Object specified in Object space (OS) Positioned in world space (WS) via transform Transforms Multiple instances of the same object can be positioned in the world via individual transformations Objects positioned according to their respective object space origins More on this later

Representation Recall: Transformations are represented as 4x4 matrices From the last lecture:

Local Coordinate Marker Nothing is displayed on the screen until you draw an object Transformation matrices are stored in memory How do we keep track of positioning information? One answer: Local Coordinate Marker (LCM) A special coordinate system that we track via pen and graph paper or mentally The LCM represents a transformation matrix But in a manner more intuitive to humans

Practical transformations The LCM represents a special transformation matrix Modelview matrix When a geometric object is drawn, it is placed according to the transform defined in the Modelview matrix Modelview matrix

Practical transformations The LCM represents a special transformation matrix Modelview matrix When a geometric object is drawn, it is placed according to the transform defined in the Modelview matrix Identity matrix Modelview matrix

Practical transformations The LCM represents a special transformation matrix Modelview matrix When a geometric object is drawn, it is placed according to the transform defined in the Modelview matrix Modelview matrix Translate(5,3)

Practical transformations The LCM represents a special transformation matrix Modelview matrix When a geometric object is drawn, it is placed according to the transform defined in the Modelview matrix Modelview matrix Translate(5,3) Draw_Square()

Practical transformations The LCM represents a special transformation matrix Modelview matrix When a geometric object is drawn, it is placed according to the transform defined in the Modelview matrix Translations and rotations concatenate into the current state of the Modelview matrix Modelview matrix Translate(5,3) Draw_Square() Translate(-4,-1)

Practical transformations The LCM represents a special transformation matrix Modelview matrix When a geometric object is drawn, it is placed according to the transform defined in the Modelview matrix Translations and rotations concatenate into the current state of the Modelview matrix Modelview matrix Translate(5,3) Draw_Square() Translate(-4,-1) Result

Object space revisited Square1 specified in Object space (OS) Positioning in world space (WS) via transform Translate(2,2) Rotate(45) Draw_Square1() Rotations also occur about the origin of the object Default axis of rotation Notice that the transformation is the exact same

Object space revisited Square2 specified in Object space (OS) Positioning in world space (WS) via transform Translate(2,2) Rotate(45) Draw_Square2() Rotations also occur about the origin of the object Default axis of rotation Notice that the transformation is the exact same

Saving and loading transformations When positioning multiple objects, saving and loading transformations can be useful

Saving and loading transformations When positioning multiple objects, saving and loading transformations can be useful PushMatrix() Save our transformation details (position and orientation of the LCM)

Saving and loading transformations When positioning multiple objects, saving and loading transformations can be useful PushMatrix() Translate(2,2)

Saving and loading transformations When positioning multiple objects, saving and loading transformations can be useful PushMatrix() Translate(2,2) Rotate(45)

Saving and loading transformations When positioning multiple objects, saving and loading transformations can be useful PushMatrix() Translate(2,2) Rotate(45) Draw_Square()

Saving and loading transformations When positioning multiple objects, saving and loading transformations can be useful PushMatrix() Translate(2,2) Rotate(45) Draw_Square() PopMatrix() Load our previous transformation details (another option in this case: re-initialise the Modelview matrix)

Saving and loading transformations When positioning multiple objects, saving and loading transformations can be useful PushMatrix() Translate(2,2) Rotate(45) Draw_Square() PopMatrix() PushMatrix() Save our transformation details (position and orientation of the LCM)

Saving and loading transformations When positioning multiple objects, saving and loading transformations can be useful PushMatrix() Translate(2,2) Rotate(45) Draw_Square() PopMatrix() PushMatrix() Translate(6,3) Draw_Square()

Saving and loading transformations When positioning multiple objects, saving and loading transformations can be useful PushMatrix() Translate(2,2) Rotate(45) Draw_Square() PopMatrix() PushMatrix() Translate(6,3) Draw_Square() PopMatrix() Load our previous transformation details (another option in this case: re-initialise the Modelview matrix)

The stack Transformations are saved on and loaded from a stack data structure Saving a matrix = push operation Loading a matrix = pop operation LIFO (last in, first out) Push on to the top of the stack Pop off the top of the stack

Operations summary Initialise an identity transformation Identity matrix (look for functions with similar names to LoadIdentity()) Translate(tx,ty) Matrix multiplication Rotate(degrees) Usually also specify an axis of rotation In our examples, assume it is (0,0,1) Rotations around the z axis i.e. in the XY plane PushMatrix() Save the current Modelview matrix state on stack PopMatrix() Load a previous Modelview matrix state from stack

Introducing hierarchies A tree of separate objects that move relative to each other The positions and orientations of objects further down the tree are dependent on those higher up Parent and child objects Transformations applied to parents are also applied down the hierarchy to their children Examples: 1. The human arm (and body) Hand configuration depends the elbow configuration, depends on shoulder configuration, and so on 2. The Solar system Solar bodies rotate about their own axes as well as orbiting around the Sun (moons around planets, planets around the Sun)

Hierarchies You have already learned the basic operations necessary for hierarchical transformations Recall: up to now, the LCM has been moved back to the world-space origin before placing each object

Hierarchies It s slightly different in a hierarchy Objects depend on others (a parent object) for their configurations (position and orientation) These objects need to be placed relative to their parent objects coordinates, rather than in world-space In practice, this involves the use of nested PushMatrix() and PopMatrix()operations Especially when there are multiple branches

Simple chain example Three components A handle Two links Handle In order to define a simple connected chain: Link 1 Translate the handle location and draw it Translate to the first link and draw it Translate to the second link and draw it Note: we do not translate back to the world-space origin after drawing each component i.e. translations are relative to the respective parent objects Link 2 Start of Link 1 Start of Link 2

Step by step In more detail: PushMatrix()

Step by step In more detail: PushMatrix() Translate(Handle_pos) DrawHandle()

Step by step In more detail: PushMatrix() Translate(Handle_pos) DrawHandle() Translate(Link1_trans)

Step by step In more detail: PushMatrix() Translate(Handle_pos) DrawHandle() Translate(Link1_trans) Rotate(Link1_ang)

Step by step In more detail: PushMatrix() Translate(Handle_pos) DrawHandle() Translate(Link1_trans) Rotate(Link1_ang) Draw_Link1()

Step by step In more detail: PushMatrix() Translate(Handle_pos) DrawHandle() Translate(Link1_trans) Rotate(Link1_ang) Draw_Link1() Translate(Link2_trans)

Step by step In more detail: PushMatrix() Translate(Handle_pos) DrawHandle() Translate(Link1_trans) Rotate(Link1_ang) Draw_Link1() Translate(Link2_trans) Rotate(Link2_ang)

Step by step In more detail: PushMatrix() Translate(Handle_pos) DrawHandle() Translate(Link1_trans) Rotate(Link1_ang) Draw_Link1() Translate(Link2_trans) Rotate(Link2_ang) Draw_Link2()

Step by step In more detail: PushMatrix() Translate(Handle_pos) DrawHandle() Translate(Link1_trans) Rotate(Link1_ang) Draw_Link1() Translate(Link2_trans) Rotate(Link2_ang) Draw_Link2() PopMatrix()

Humanoid Hierarchy Use glpushmatrix() and glpopmatrix() to add/remove transforms from the stack glpushmatrix(); gltranslate(position of hand); Draw_palm_of_hand(); glpopmatrix(); 2013, Simulating virtual crowds: A perceptual DH2323 Rasterised Rendering II approach

Humanoid Hierarchy Use glpushmatrix() and glpopmatrix() to add/remove transforms from the stack glpushmatrix(); gltranslate(position of hand); Draw_palm_of_hand(); glpushmatrix(); gltranslate(position of finger 1); glrotatef(finger 1 rotation); Draw_finger_1(); glpopmatrix(); glpopmatrix(); 2013, Simulating virtual crowds: A perceptual DH2323 Rasterised Rendering II approach

Humanoid Hierarchy Use glpushmatrix() and glpopmatrix() to add/remove transforms from the stack glpushmatrix(); gltranslate(position of hand); Draw_palm_of_hand(); glpushmatrix(); gltranslate(position of finger 1); glrotatef(finger 1 rotation); Draw_finger_1(); glpopmatrix(); glpushmatrix(); gltranslate(position of finger 2); glrotatef(finger 2 rotation); Draw_finger_2(); glpopmatrix(); glpopmatrix(); 2013, Simulating virtual crowds: A perceptual DH2323 Rasterised Rendering II approach

Putting it into Practice https://processing.org/...a flexible software sketchbook and a language for learning how to code within the context of visual arts Good for a foray into transformations without the complexity of an IDE OpenGL-based: similar (but less sophisticated) functionality to the framework that you will use in the course Straight forward mapping from operations we covered in this lecture to graphics programming functions