Models & Hierarchies CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2006.

Slides:



Advertisements
Similar presentations
MAT 594CM S2010Fundamentals of Spatial ComputingAngus Forbes Overview Goals of the course: 1. to introduce real-time 3D graphics programming with openGL.
Advertisements

Graphics Pipeline.
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
Computer Graphics Visible Surface Determination. Goal of Visible Surface Determination To draw only the surfaces (triangles) that are visible, given a.
3D Graphics for Game Programming (J. Han) Chapter XI Character Animation.
CGDD 4003 THE MASSIVE FIELD OF COMPUTER GRAPHICS.
Clipping & Scan Conversion
Skin CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.
Models & Hierarchies CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2005.
Viewing & Perspective CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2006.
Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.
Graphical Objects and Scene Graphs CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
10/11/2001CS 638, Fall 2001 Today Kd-trees BSP Trees.
CSE 473 Dr. Charles B. Owen Fundamentals of 3D Game Development1 Skeletons and Skinning Bones and Skeletons Mesh Skinning.
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology 3D Engines and Scene Graphs Spring 2012.
Hierarchical Transformations Hierarchical Models Scene Graphs
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Viewing & Perspective CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2005.
COMP 175: Computer Graphics March 10, 2015
Introduction to 3D Graphics Lecture 4: Scenes and Scene Graphs Anthony Steed University College London.
Spatial Data Structures Jason Goffeney, 4/26/2006 from Real Time Rendering.
Objectives Review some advanced topics, including Review some advanced topics, including Chapter 8: Implementation Chapter 8: Implementation Chapter 9:
COMP 175: Computer Graphics March 24, 2015
CSE 381 – Advanced Game Programming Basic 3D Graphics
Graphical Objects and Scene Graphs 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009.
Week 2 - Wednesday CS361.
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare.
Buffers Textures and more Rendering Paul Taylor & Barry La Trobe University 2009.
Week 5 - Wednesday.  What did we talk about last time?  Project 2  Normal transforms  Euler angles  Quaternions.
Transforms Hierarchical Modeling Scene Graphs Using hierarchical modeling techniques in 3D software design Transforms Local basis Matrix math review Matrices.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 14 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 14 Going-through.
Data Structures for Scenes, The Basics of Scene Graphs Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday,
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Kinematic Linkages.
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
Lecture 6: 3D graphics Concepts 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271 
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
CS-378: Game Technology Lecture #4: Texture and Other Maps Prof. Okan Arikan University of Texas, Austin V Lecture #4: Texture and Other Maps.
#5: Models & Scenes CSE167: Computer Graphics Instructor: Ronen Barzel UCSD, Winter 2006.
Computing & Information Sciences Kansas State University Lecture 19 of 42CIS 636/736: (Introduction to) Computer Graphics Lecture 19 of 42 William H. Hsu.
Representation. Objectives Introduce concepts such as dimension and basis Introduce coordinate systems for representing vectors spaces and frames for.
Jul 25, 2014IAT 3551 Scene Graphs.  A data structure that stores information about a graphics scene –Each node has information that structures the interpretation.
Image Synthesis Rabie A. Ramadan, PhD 4. 2 Review Questions Q1: What are the two principal tasks required to create an image of a three-dimensional scene?
CSCE 552 Spring D Models By Jijun Tang. Triangles Fundamental primitive of pipelines  Everything else constructed from them  (except lines and.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 7. Speed-up Techniques Presented by SooKyun Kim.
Modeling CSCI 440 Computer Graphics based on Chapter 9
Computer Graphics Matrix Hierarchies / Animation
1 OGRE Programming Intermediate Tutorial: Volume Selection.
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell Hierarchical Modeling.
Graphical Objects and Scene Graphs Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
1cs426-winter-2008 Notes. 2 Kinematics  The study of how things move  Usually boils down to describing the motion of articulated rigid figures Things.
11/16/04© University of Wisconsin, CS559 Fall 2004 Last Time Texture Anti-Aliasing Texture boundaries Modeling introduction.
CSCE 441: Computer Graphics: Hierarchical Models Jinxiang Chai.
OpenGL LAB III.
Administrivia Back on track: canceling OpenGL lecture 2 Assignment 1
- Introduction - Graphics Pipeline
COMPUTER GRAPHICS CHAPTER 35 CS 482 – Fall 2017 ANIMATION
CS451Real-time Rendering Pipeline
Hierarchical and Object-Oriented Graphics
CSCE 441: Computer Graphics: Hierarchical Models
Skeletons and Skinning
Chapter XIII Character Animation
Hierarchical and Object-Oriented Graphics
Dr. Chih-Kuo Yeh 葉智國 Computer Graphics Dr. Chih-Kuo Yeh 葉智國
Hierarchical Modeling
Computer Graphics Matrix Hierarchies / Animation
CSCE 441: Computer Graphics: Hierarchical Models
Presentation transcript:

Models & Hierarchies CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2006

Normals The concept of normals is essential to lighting Intuitively, we might think of a flat triangle as having a constant normal across the front face However, in computer graphics, it is most common to specify normals and perform lighting at the vertices This gives us a method of modeling smooth surfaces as a mesh of triangles with ‘shared’ normals at the vertices We will talk about lighting in the next lecture, but for today, we will still think of our vertex as containing a normal

Models We will extend our concept of a Model to include normals We can do this by simply extending our vertex class: class Vertex { Vector3 Position; Vector3 Color; Vector3 Normal; public: void Draw() { glColor3f(Color.x, Color.y, Color.z); glNormal3f(Normal.x, Normal.y, Normal.z); glVertex3f(Position.x, Position.y, Position.z);// This has to be last }

Model Data Structures Everybody knows that a cube has 8 vertices If we need to render a cube, however, each of those vertices requires 3 different normals. In other words, we might really need 3*8=24 vertices If we render it as triangles, each 4-sided face actually requires 6 vertices, meaning that we might need to store and process 36 different vertices!

Indexed Models So far, we have simply thought of a model as an array of triangles, each triangle storing 3 unique vertices A more common method of storing a model is as an array of vertices, and an array of triangles In the second method, each triangle stores an index (or pointer) to a vertex instead of storing the vertex data explicitly This is called an indexed model or single indexed model Indexing will almost always save memory, as models often have shared vertices that are used by several triangles Large, smooth meshes will often share a single vertex between 4-6 triangles (or more) Indexing can also save processing time as the vertex array can first be transformed and lit, and then the triangle array can be clipped and scan converted…

Single Indexed Model class Vertex { Vector3 Position; Vector3 Color; Vector3 Normal; }; class Triangle { Vertex *Vert[3];// or int Vert[3]; }; class Model { int NumVerts,NumTris; Vertex *Vert; Triangle *Tri; };

Index vs. Pointer Should we store the triangle verts as integers (indexing into the array of actual Vertex’s) ? int Vert[3]; Or should we store them as pointers to the actual Vertex’s themselves ? Vertex *Vert[3]; Memory: In most systems an int is 4 bytes and a pointer is 4 bytes, so there isn’t a big difference in memory However, for smaller models, you could benefit from using short ints, which are 2 bytes each. This would cut the triangle size in half, but limit you to vertices Performance: Storing Vertex*’s gives the triangle direct access to the data so should be faster Other Issues: It’s definitely more convenient to store the pointers instead of integers One important reason to consider storing integers instead of pointers, however, is if you are using some type of dynamic array for the vertices (such as an STL vector). Pointers to members of these arrays are considered dangerous, since the array may have to reallocate itself if more vertices are added

Vertex Buffers Hardware rendering API’s (like Direct3D and OpenGL) support some type of vertex buffer system as well (but everybody has a different name for it) This is essentially an unindexed or single indexed model format You start by defining your specific vertex type. Verts usually have a position and normal, and might have one or more colors, texture coordinates, or other properties You then request a vertex buffer of whatever memory size you want. This memory is usually the actual video memory on the graphics board (not main memory) The vertex buffer can then be filled up with vertex data as a single large array One can then draw from the vertex buffer with a command like this: DrawSomething(int type,int first vert,int numverts); // type: triangles, strips, lines… The advantage is that a large number of triangles can be drawn with a single CPU call and all of the work then takes place entirely on the graphics board

Index Buffers An index buffer (or whatever name one calls it) is an array of (usually 2 byte or 4 byte) integers It is stored in video memory like the vertex buffer The integers index into a vertex buffer array One can then draw triangles (or other primitives) by specifying a range of these indexes Using vertex/index buffers is most likely going to be the fastest way to render on modern graphics hardware

Triangles, Strips, Fans Graphics hardware usually supports slightly more elaborate primitives than single triangles Most common extensions are strips and fans v0v0 v1v1 v2v2 v4v4 v6v6 v8v8 v7v7 v5v5 v3v3 v0v0 v1v1 v2v2 v3v3 v4v4 v5v5 v6v6 v7v7

Materials & Grouping Usually models are made up from several different materials The triangles are usually grouped and drawn by material

Hierarchical Transformations

We have seen how a matrix can be used to place an individual object into a virtual 3D world Sometimes, we have objects that are grouped together in some way For example, we might have an articulated figure which contains several rigid components connected together in some fashion Or we might have several objects sitting on a tray that is being carried around Or we might have a bunch of moons and planets orbiting around in a solar system Or we might have a hotel with 1000 rooms, each room containing a bed, chairs, table, etc. In each of these cases, the placement of objects is described more easily when one considers their locations relative to each other We will see how hierarchical transformations can be used to describe their placement

Scene Hierarchy If a scene contains 1000 objects, we might think of a simple organization like this: Scene Object 1Object 2Object 3Object 1000…

Scene Hierarchy Or we could go for a more hierarchical grouping like: Scene Room 1Room 2Room 3 Chair 1Chair 2Table BookMonitor BedDresseretc…

Scene Hierarchy It is very common in computer graphics to define a complex scene in some sort of hierarchical fashion The individual objects are grouped into a tree like structure (upside down tree) Each moving part is a single node in the tree The node at the top is the root node A node directly above another is that node’s parent A node below another is a child and nodes with the same parent are called siblings Nodes at the bottom of the tree with no children are called leaf nodes

Articulated Figures An articulated figure is an example of a hierarchical object The moving parts can be arranged into a tree data structure if we choose some particular piece as the ‘root’ For an articulated figure (like a biped character), we usually choose the root to be somewhere near the center of the torso Each joint in the figure has specific allowable degrees of freedom (DOFs) that define the range of possible poses for the figure

Example Articulated Figure

Hierarchical Transformations We assume that each node in the tree graph represents some object that has a matrix describing its location and a model describing its geometry When a node up in the tree moves its matrix, it takes its children with it (in other words, rotating a character’s shoulder joint will cause the elbow, wrist, and fingers to move as well)

Local Matrices We will assume a tree structure where child nodes inherit transformations from the parent nodes Each node in the tree stores a local matrix which is its transformation relative to its parent To compute a node’s world space matrix, we need to concatenate its local matrix with its parent’s world matrix: W=W parent ·L

Recursive Traversal To compute all of the world matrices in the scene, we can traverse the tree in a depth-first traversal As each node is traversed, we compute its world space matrix By the time a node is traversed, we are guaranteed that the parent’s world matrix is available

Forward Kinematics In the recursive tree traversal, each joint first computes its local matrix L based on the values of its DOFs and some formula representative of the joint type: Local matrix L = L joint (φ 1,φ 2,…,φ N ) Then, world matrix W is computed by concatenating L with the world matrix of the parent joint World matrix W = W parent · L

GL Matrix Stack The GL matrix stack is set up to facilitate the rendering of hierarchical scenes While traversing the tree, we can call glPushMatrix() when going down a level and glPopMatrix() when coming back up

Hierarchical Culling Scene hierarchies can also assist in the culling process Each object has a precomputed bounding sphere This sphere is compared against the view volume to determine if the object is visible We can also do hierarchical culling where each sphere contains all of its children as well Culling a sphere automatically culls an entire subtree of the scene

Project 2 In project 2, you are must create some sort of simple articulated figure, such as a hand It must perform some simple animation (such as opening/closing the fingers) It must be object oriented and make use of classes for key objects such as: Camera, Light, Model, Hand…

Cameras Camera { float FOV, Aspect, NearClip, FarClip; Vector3 Position, Target; public: Camera(); void DrawBegin(); void DrawEnd(); void SetAspect(float a); };

Camera void Camera::DrawBegin() { glClear(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(FOV,Aspect,NearClip,FarClip); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(Position.x,Position,y,Position.z, Target.x,Target.y,Target.z,0,1,0); glPushMatrix(); } void Camera::DrawBegin() { glPopMatrix(); glSwapBuffers(); }