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)

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

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

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

2D/3D Geometric Transformations and Scene Graphs

Transforms 1 Christian Miller CS Fall 2011

Computer Graphics Hands-on

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

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

IMAGE-BASED RENDERING AND ANIMATION

Transformations. Rotation and Scaling

CT5510: Computer Graphics. Transformation BOCHANG MOON

Graphics pipeline and transformations. Composition of transformations

GEOMETRIC TRANSFORMATIONS AND VIEWING

RASTERISED RENDERING

MODULE - 7. Subject: Computer Science. Module: Other 2D Transformations. Module No: CS/CGV/7

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

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

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

UNIT 2 2D TRANSFORMATIONS

TIEA311 Tietokonegrafiikan perusteet kevät 2018

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

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

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

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

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

Homework 5: Transformations in geometry

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

Computer Graphics Hands-on

CHAPTER 1 Graphics Systems and Models 3

Hierarchical Modeling

Computer Graphics: Geometric Transformations

Vector Algebra Transformations. Lecture 4

3D GRAPHICS. design. animate. render

Linear transformations Affine transformations Transformations in 3D. Graphics 2009/2010, period 1. Lecture 5: linear and affine transformations

CS451Real-time Rendering Pipeline

Linear and Affine Transformations Coordinate Systems

3D Modelling: Animation Fundamentals & Unit Quaternions

Processing Transformations. Affine Transformations

Overview. By end of the week:

Computer Graphics Hands-on

COMPSCI 372 S2 C - Assignment 2 Due Date: Monday 22nd September 2008, 9.30pm

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

Transform 1: Translate, Matrices

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

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

Maya Lesson 3 Temple Base & Columns

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

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

Today. Parity. General Polygons? Non-Zero Winding Rule. Winding Numbers. CS559 Lecture 11 Polygons, Transformations

CS 4620 Program 3: Pipeline

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

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

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

Computer Graphics Geometric Transformations

DH2323 DGI16 Lab2 Transformations

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

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

3D Programming. 3D Programming Concepts. Outline. 3D Concepts. 3D Concepts -- Coordinate Systems. 3D Concepts Displaying 3D Models

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

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

CS475/675: Computer Graphics End-Semester Examination (Solutions), Fall 2016

Today. Today. Introduction. Matrices. Matrices. Computergrafik. Transformations & matrices Introduction Matrices

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

Scanline Rendering 1 1/42

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

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

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

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

CS 184, Fall 1992 MT Solutions Professor Brian A. Barsky

Computer graphics 2: Graduate seminar in computational aesthetics

CS184, Fall 1997 Midterm #1 Professor Brian A. Barksy

Temporal Resolution. Flicker fusion threshold The frequency at which an intermittent light stimulus appears to be completely steady to the observer

Viewing with Computers (OpenGL)

Announcements. Submitting Programs Upload source and executable(s) (Windows or Mac) to digital dropbox on Blackboard

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

Graphics and Interaction Transformation geometry and homogeneous coordinates

Specifying Complex Scenes

Using GLU/GLUT Objects

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

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

Kinematics and Orientations

Lecture 5 2D Transformation

Where We Are: Static Models

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

1 Projective Geometry

CS 4204 Computer Graphics

we now have a good understanding of 3d representations, rigid body transforms, camera projections, and the fixed function steps in graphics

CS354 Computer Graphics Character Animation and Skinning

Core Graphics and OpenGL ES. Dr. Sarah Abraham

Matrices. Chapter Matrix A Mathematical Definition Matrix Dimensions and Notation

(a) rotating 45 0 about the origin and then translating in the direction of vector I by 4 units and (b) translating and then rotation.

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

CS354 Computer Graphics Rotations and Quaternions

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

OpenGL Transformations

Game Programming. Bing-Yu Chen National Taiwan University

1.8 Composition of Transformations

Transcription:

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

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

Transformations Positioning geometric objects in the virtual world is an operation fundamental for scene composition and computer animation Scenes are composed of: Viewer/camera Objects and shapes (composed of geometric primitives) Other (textures, lighting, ) In this lecture, we will consider only rotation and translation transformations There are others too: Shear, squash, stretch

Scene composition A photorealistic scene (circa 2013)

Scene composition A photorealistic scene (circa 2013) Underlying representation (geometry: white)

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

Vertices

Vertices Q: Why this ordering? Hint: do cross-product on vectors defined by two edges incident to any vertex

Vertices Right-hand rule Winding order of the vertices

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?

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)

Coordinate spaces? What are the coordinates of an object? Answer: It depends on the coordinate space

Coordinate spaces Object specified in Object space (OS) What are the coordinates of an object? Answer: It depends on the coordinate space The vertices of an object are usually specified in its own local coordinate space Object space (OS) Origin often located near the centroid of the object

World space Object specified in Object space (OS) Transform Positioned in world space (WS) via transform An instance of an object is positioned in the world using a transformation World space (WS) In this case, the transformation Translate(t x,t y ) Displacement of t x units along the x-axis and t y units along the y-axis

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

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

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

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

Geometry and transformations Scene containing three instances in worldspace Geometry Transformations + = Geometry is usually stored separately from respective transformations Objects definitions versus object instances Memory savings

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?

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

Local Coordinate Marker LCM begins at the worldspace origin Its basis vectors match those of the WS basis

Local Coordinate Marker Translate(5,3) We keep a track of the marker as we conduct various positioning operations

Local Coordinate Marker Translate(5,3) Draw_Square() Until we draw the object Note: the LCM is not drawn on the screen! (unless you decide to add some code to do so )

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

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

Rotations and translations Let s add in some rotations to the mix

Rotations and translations Translate(5,3) Let s add in some rotations to the mix

Rotations and translations Translate(5,3) Rotate(45) Let s add in some rotations to the mix

Rotations and translations Translate(5,3) Rotate(45) Translate(2,0) Let s add in some rotations to the mix Notice how the final translation of (2,0) takes place with respect to the LCM coordinate system Not the WS axes

Order matters Translation and rotation operations are non-commutative

Order matters Translate(2,2) Rotate(45) Translation and rotation operations are non-commutative

Order matters Translate(2,2) Rotate(45) Rotate(45) Translate(2,2) Translation and rotation operations are non-commutative See matrices from last lecture

Object space revisited Square1 specified in Object space (OS) Positioning in world space (WS) via transform Example 1: Objects are placed in world space according to their corresponding origin in object space

Object space revisited Square1 specified in Object space (OS) Positioning in world space (WS) via transform Translate(2,2) Example 1: Objects are placed in world space according to their corresponding origin in object space

Object space revisited Square1 specified in Object space (OS) Positioning in world space (WS) via transform Translate(2,2) Draw_Square1() Example 1: Objects are placed in world space according to their corresponding origin in object space i.e. Object space origin is mapped onto the LCM

Object space revisited Square2 specified in Object space (OS) Positioning in world space (WS) via transform Example 2: Objects are placed in world space according to their corresponding origin in object space

Object space revisited Square2 specified in Object space (OS) Positioning in world space (WS) via transform Translate(2,2) Example 2: Objects are placed in world space according to their corresponding origin in object space

Object space revisited Square2 specified in Object space (OS) Positioning in world space (WS) via transform Translate(2,2) Draw_Square2() Example 2: Objects are placed in world space according to their corresponding origin in object space i.e. Object space origin is mapped onto the LCM Notice here that the LCM (transformation) is the exact same as in example 1

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)

Adding some animation Enter a variable angle for the first rotate Increase it by e.g. 10 degrees at each update x=0 PushMatrix() Translate(2,2) Rotate(x) Draw_Square() PopMatrix() PushMatrix() Translate(6,3) Draw_Square() PopMatrix() x=x+10 (constrain x to sensible value)

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(t x,t y ) 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 In order to define a simple connected chain: 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 Start of Link 1 Handle Link 1 Link 2 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()

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

Something for the break Object specified in Object space (OS) Positioned in world space (WS) via transform Transforms

Q: What is the transformation T1? Vertex position: OS (4.0,5.0) WS (13.0,12.0)

Q: What is the transformation T3? Vertex position: OS (4.0,5.0) WS (-14.3,7.4)