73
CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Embed Size (px)

Citation preview

Page 1: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

CS 352: Computer Graphics

HierarchicalGraphics,Modeling,

And Animation

Page 2: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 2

Overview Modeling Animation Data structures

for interactive graphics

CSG-tree BSP-tree Quadtrees and Octrees Visibility precomputation

Many figures and examples in this set of lectures are from The Art of 3D Computer Animation and Imaging, by I. Kerlow

Page 3: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 3

Modeling The modeling problem Modeling primitives

Polygon Sphere, ellipsoid, torus, superquadric NURBS, surfaces of revolutions, smoothed polygons Particles Skin & bones

Approaches to modeling complex shapes Tools such as extrude, revolve, loft, split, stitch,

blend Constructive solid geometry (CSG) Hierarchy; kinematic joints Inverse kinematics Keyframes

Page 4: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 4

Representing objects Objects represented as symbols Defined in model coordinates;

transformed into world coordinates (M = TRS)glMatrixMode(GL_MODELVIEW);

glLoadIdentity(); glTranslatef(…);

glRotatef(…); glScalef(…);

glutSolidCylinder(…);

Page 5: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 5

Primitives The basic sort

of primitive is the polygon

Number of polygons: tradeoff between render time and model accuracy

Page 6: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 6

Page 7: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 7

SplineCurves Linear spline Cardinal spline B-spline Bezier curve NURBS (non-

uniform rational b-spline)

Page 8: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 8

Mesh

Page 9: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 9

Mesh deformations

Page 10: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 10

Sweep Sweep a shape over a path to form a

generalized cylinder

Page 11: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 11

Revolution Revolve a shape around an axis to

create an object with rotational symmetry

Page 12: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 12

Extrusion Extrude: grow a 2D shape

in the third dimension Shape is created with a (1D)

b-spline curves Hole was created by

subtracting a cylinder

Page 13: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 13

Page 14: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 14

Joining Primitives Stitching, blending

Page 15: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 15

Modifying Primitives

Page 16: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 16

Subdivision Surfaces Can set level of polygon subdivision

Page 17: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 17

Page 18: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 18

Page 19: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 19

Page 20: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 20

Skin and Bones Skeleton with joined “bones” Can add “skin” on top of bones Automatic or

hand-tunedskinning

Page 21: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 21

Page 22: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 22

Particles

Page 23: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 23Algorithmi

c PrimitivesAlgorithms for trees, mountains, grass, fur, lightning, fire, …

Page 24: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 24

Page 25: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 25

Geometric model file formats .obj: Alias Wavefront .dxf: Autocad .vrml: Inventor Dozens more Can convert

between formats Converting to a

common format may lose info…

Page 26: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 26

Hierarchical models When animation is desired, objects may

have parts that move with respect to each other Object represented as hierarchy Often there are joints with motion

constraints E.g. represent wheels of car as sub-objects

with rotational motion (car moves 2 pi r per rotation)

Page 27: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 27

Page 28: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 28

DAG models Could use tree to

represent object Actually, a DAG

(directed acyclicgraph) is better: can re-use objects

Note that each arrow needs aseparate modeling transform

In object-oriented graphics, alsoneed motion constraints with eacharrow

Page 29: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 29

Example: Robot Traverse DAG using DFS (or BFS) Push and pop matrices along the way

(e.g. left-child right-sibling)(joint position parameters?)

Page 30: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 30

Page 31: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 31

Modeling Programs Moray

Shareware Limited functionality Easy

Lightwave, Maya NOT shareware Very full-featured Difficult to learn and use

Moray, Maya demos; Lightwave video

Page 32: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 32

Animation Suppose you want

the robot to pick up a can of oil to drink. How?

You could set the joint positions at each moment in the animation (kinematics)

Page 33: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 33

Inverse Kinematics You can’t just invert the

joint transformations Joint settings aren’t even

necessarily unique for a hand position!

Inverse kinematics: figure out from the hand position where the joints should be set.

Page 34: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 34

Using Inverse Kinematics Specify joint

constraintsand priorities

Move end effector(or object pose)

Let the system figureout joint positions

[IK demo]

Page 35: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 35

Keyframe Animation In traditional key frame animation the

animator draws several important frames, and helpers do the “inbetweening” or “tweening”

Computer animation is also key-frame based At key frames, animator positions objects and

lights, sets parameters, etc. The system interpolates parameter values

linearly or along a curve To get from one object pose to the next,

inverse kinematics determine joint motions [Keyframe animation demo]

Page 36: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 36

Motion Capture More realistic

motion sequences can be generated by Motion Capture

Attach joint position indicatorsto real actors

Record live action

Page 37: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 37

Page 38: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 38

Morphing Morphing: smoothly shifting from one

image to another First popularized in a Michael Jackson

video Method: a combination of

Warping both images, gradually moving control points from location in first image to location in the second

Cross-fading from first image sequence to second

Page 39: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 39

3D Morphing Define 3D before and

after shapes as e.g. NURBS surfaces with same number ofcontrol points

Gradually move control points fromfirst setting to second

Specify key poses: e.g. smile, frown, 12 frames of walking motion

Page 40: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 40

Combined approaches

Page 41: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 41

Example: virtual puppetry Suppose you want to display virtual

puppet shows How could you animate puppet

movements? How could you control the animations

externally?

Page 42: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 42

Character Animation To make computer graphics

(or cartoon drawings) come alive…

Page 43: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 43Personality through Pose,

Expression, Motion, Timing

Page 44: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 44

Page 45: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 45

Object-oriented Graphics Higher in the programming hierarchy:

control models with object-oriented programs

robot robbie;

robbie.smile();

robbie.walk(270, 5, 3);

Page 46: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 46

Data Structures for Modeling This part of chapter: how some

example applications be done efficiently (i.e. topics without a better home…)

Tree-based subdivisions of space Example 1: how to represent complex

objects made up of union, intersection, difference of other objects

Page 47: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 47

CSG Tree

Page 48: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 48

Application 2: HSR How to render in 3D with hidden

surface removal when you don’t have a hardware depth-buffer?

Can you think of any other ways of removing hidden surfaces quickly?

Principle: a polygon can’t be occluded by another polygon that is behind it.

Page 49: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 49

BSP-tree The painter’s algorithm for hidden

surface removal works by drawing all faces, from back to front

How to get a listing of the faces in back-to-front order?

Put them into a binary tree and traverse the tree (but in what order?)

Page 50: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 50

BSP Tree Figures Right is “front” of polygon; left is

“back” In and Out nodes show regions of space

inside or outside the object (Or, just store split pieces of polygons

at leaves)

Page 51: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 51

Traversing a BSP tree Binary Space Partition tree: a binary

tree with a polygon at each node Children in left subtree are behind polygon Children in right subtree are in front of polygon

Traversing a BSP-tree: If null pointer, do nothing Else, draw far subtree, then polygon at current

node, then near subtree Far and near are determined by location of

viewer Runtime of traversal? Drawbacks?

Page 52: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 52

Building a BSP tree Inserting a polygon:

If tree is empty make it the root If polygon to be inserted intersects plane of

polygon of current node, split and insert half on each side recursively.

Else insert on appropriate side recursively Problem: the number of faces could

grow dramatically Worst case (O(n2))…but usually it doesn’t grow too badly

in practice…

Page 53: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 53

BSP-tree Summary Returns polygons not necessarily in

sorted order, but in an order that is correct for back-to-front rendering

Widely used when Z-buffer hardware may not be available (e.g. game engines)

Guarantees back-to-front rendering for alpha blending

Works well (linear-time traversals) in the number of split polygons

[And we hope the number of polygons doesn’t grow too much through splitting]

Page 54: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 54

Application 3: Handling Large Spatial Data Sets Example application: image-based

rendering Suppose you have many digital images of a

scene, with depth information for pixels How to find efficiently the points that are in

front? Other applications:

Speeding up ray-tracing with many objects Rendering contours of 3D

volumetric data such as MRI scans

Page 55: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 55

Quadtree Quadtree: divide space into four

quadrants. Mark as Empty, Full, or Partially full.

Recursively subdivide partially full regions

Saves much time, space over 2D pixel data!

Page 56: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 56

Quadtree Structure

Page 57: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 57

Octrees Generalize to cutting up a cube into 8

sub-cubes, each of which may be E, F, or P (and subdivided)

Much more efficientthan a 3D array ofcells for 3Dvolumetric data

Page 58: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 58

Quadtree Algorithms How would you

render a quadtree shape? find the intersection of a ray with a

quadtree shape? Take the union of two quadtrees? Intersection? Find the neighbors of a cell?

Page 59: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 59

Applications of Octrees Contour finding in MRI data 3D scanning and rendering Efficient ray tracing Intersection, collision testing

Page 60: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 60

Research in Visibility Can we figure out in advance what will

be visible from each viewpoint?

Page 61: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 61

Viewer-centered representation Viewer-centered object representations:

representation not of volume of space filled but appearance from all viewpoints

Page 62: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 62

Occlusion in view space Occlusion in view space is subtraction

Page 63: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 63

Events Events: boundaries in viewpoint space

where faces appear or disappear

Page 64: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 64

Aspect Graph Aspect graph: a graph with a node for

every topologically distinct view of an object, with edges connecting adjacent views

Page 65: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 65

Aspect graph varieties Aspect graphs can be constructed for

3D: space 2D: multiple axis rotations or planar

motions 1D: single-axis rotations

Page 66: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 66

1D Aspect Graph for Rotation

Page 67: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 67

1D Aspect Graph Results Useful for rotations without Z-buffer

hardware! Not so useful for more viewer freedom,

modern graphics hardware

Page 68: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 68

Conservative Visibility Preprocessing Q. can we take advantage of z-buffer? Definition: weak visibility. A polygon

is weakly visible from a region if any part of the polygon is visible from any viewpoint in the region

Conservative visibility preprocessing: computing in advance a (super-)set of the polygons that are weakly visible from some region

Rendering with Z-buffer yields correct image, but it’s faster since fewer polygons are drawn

Page 69: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 69

Weak Visibility Subdivision Given an object and a wall, find the

region of space from which the wall occludes the object

Divide space into regions, where each edge represents some object appearing or disappearing

Page 70: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 70

Conservative Visibility Preprocessing on a Grid Divide viewing

space into a 3D (or 2D) grid

Compute a conservative display list for each cell

Page 71: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 71

Conservative visibility algorithm Initialize a display list for each grid cell Algorithm: for each object, wall, and

cell If the object is not weakly visible from the

cell, remove from cell’s display list

You can churn away at this computation as long as you like, increasing runtimes, but you can stop at any time with usable results. (Results improve over time!)

Page 72: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 72

Perspective What good did this visibility research do

for the world? It wasn’t enough for me

I left graphics research and went into digital libraries

Left University of Pittsburgh and went to Wheaton College

Page 73: CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

Interactive Computer GraphicsChapter 9 - 73

Summary 3D modeling uses advanced primitives and

ways of cutting, joining them Inverse kinematics determines joint

position from end effector motions Keyframe animation involves important

poses and inbetweening 3D morphing animates surface control

points 3D spatial subdivision trees include CSG-

trees, BSP-trees, Quadtrees, and Octrees Visibility preprocessing speeds walkthrough