CS 352 Computer Graphics Hierarchical Graphics Modeling And

  • Slides: 73
Download presentation
CS 352: Computer Graphics Hierarchical Graphics, Modeling, And Animation

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

2 Interactive Computer Graphics Overview n n n Modeling Animation Data structures for interactive

2 Interactive Computer Graphics Overview n n n Modeling Animation Data structures for interactive graphics n n n CSG-tree BSP-tree Quadtrees and Octrees Visibility precomputation Many figures and examples in this set of lectures are from The Art of 3 D Computer Animation and Imaging, by I. Kerlow

3 Interactive Computer Graphics Modeling n n The modeling problem Modeling primitives n n

3 Interactive Computer Graphics Modeling n n The modeling problem Modeling primitives n n n Polygon Sphere, ellipsoid, torus, superquadric NURBS, surfaces of revolutions, smoothed polygons Particles Skin & bones Approaches to modeling complex shapes n n n Tools such as extrude, revolve, loft, split, stitch, blend Constructive solid geometry (CSG) Hierarchy; kinematic joints Inverse kinematics Keyframes

4 Interactive Computer Graphics Representing objects n n Objects represented as symbols Defined in

4 Interactive Computer Graphics Representing objects n n Objects represented as symbols Defined in model coordinates; transformed into world coordinates (M = TRS) gl. Matrix. Mode(GL_MODELVIEW); gl. Load. Identity(); gl. Translatef(…); gl. Rotatef(…); gl. Scalef(…); glut. Solid. Cylinder(…);

5 Interactive Computer Graphics Primitives n n The basic sort of primitive is the

5 Interactive Computer Graphics Primitives n n The basic sort of primitive is the polygon Number of polygons: tradeoff between render time and model accuracy

6 Interactive Computer Graphics

6 Interactive Computer Graphics

7 Interactive Computer Graphics Spline Curves n n n Linear spline Cardinal spline B-spline

7 Interactive Computer Graphics Spline Curves n n n Linear spline Cardinal spline B-spline Bezier curve NURBS (nonuniform rational b-spline)

8 Interactive Computer Graphics Mesh

8 Interactive Computer Graphics Mesh

9 Interactive Computer Graphics Mesh deformations

9 Interactive Computer Graphics Mesh deformations

10 Interactive Computer Graphics Sweep n Sweep a shape over a path to form

10 Interactive Computer Graphics Sweep n Sweep a shape over a path to form a generalized cylinder

11 Interactive Computer Graphics Revolution n Revolve a shape around an axis to create

11 Interactive Computer Graphics Revolution n Revolve a shape around an axis to create an object with rotational symmetry

12 Interactive Computer Graphics Extrusion n Extrude: grow a 2 D shape in the

12 Interactive Computer Graphics Extrusion n Extrude: grow a 2 D shape in the third dimension Shape is created with a (1 D) b-spline curves Hole was created by subtracting a cylinder

13 Interactive Computer Graphics

13 Interactive Computer Graphics

14 Interactive Computer Graphics Joining Primitives n Stitching, blending

14 Interactive Computer Graphics Joining Primitives n Stitching, blending

15 Interactive Computer Graphics Modifying Primitives

15 Interactive Computer Graphics Modifying Primitives

16 Interactive Computer Graphics Subdivision Surfaces n Can set level of polygon subdivision

16 Interactive Computer Graphics Subdivision Surfaces n Can set level of polygon subdivision

17 Interactive Computer Graphics

17 Interactive Computer Graphics

18 Interactive Computer Graphics

18 Interactive Computer Graphics

19 Interactive Computer Graphics

19 Interactive Computer Graphics

20 Interactive Computer Graphics Skin and Bones n n n Skeleton with joined “bones”

20 Interactive Computer Graphics Skin and Bones n n n Skeleton with joined “bones” Can add “skin” on top of bones Automatic or hand-tuned skinning

21 Interactive Computer Graphics

21 Interactive Computer Graphics

22 Interactive Computer Graphics Particles

22 Interactive Computer Graphics Particles

23 Interactive Computer Graphics Algorithmic Primitives Algorithms for trees, mountains, grass, fur, lightning, fire,

23 Interactive Computer Graphics Algorithmic Primitives Algorithms for trees, mountains, grass, fur, lightning, fire, …

24 Interactive Computer Graphics

24 Interactive Computer Graphics

25 Interactive Computer Graphics Geometric model file formats n . obj: Alias Wavefront. dxf:

25 Interactive Computer Graphics Geometric model file formats n . obj: Alias Wavefront. dxf: Autocad. vrml: Inventor n Dozens more n n Can convert between formats Converting to a common format may lose info…

26 Interactive Computer Graphics Hierarchical models n When animation is desired, objects may have

26 Interactive Computer Graphics Hierarchical models n When animation is desired, objects may have parts that move with respect to each other n n n 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)

27 Interactive Computer Graphics

27 Interactive Computer Graphics

28 Interactive Computer Graphics DAG models n n Could use tree to represent object

28 Interactive Computer Graphics DAG models n n Could use tree to represent object Actually, a DAG (directed acyclic graph) is better: can re-use objects Note that each arrow needs a separate modeling transform In object-oriented graphics, also need motion constraints with each arrow

29 Interactive Computer Graphics Example: Robot n n Traverse DAG using DFS (or BFS)

29 Interactive Computer Graphics Example: Robot n n Traverse DAG using DFS (or BFS) Push and pop matrices along the way (e. g. left-child right-sibling) (joint position parameters? )

30 Interactive Computer Graphics

30 Interactive Computer Graphics

31 Interactive Computer Graphics Modeling Programs n Moray n n Lightwave, Maya n n

31 Interactive Computer Graphics Modeling Programs n Moray n n Lightwave, Maya n n Shareware Limited functionality Easy NOT shareware Very full-featured Difficult to learn and use Moray, Maya demos; Lightwave video

32 Interactive Computer Graphics Animation n n Suppose you want the robot to pick

32 Interactive Computer Graphics Animation n n 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)

33 Interactive Computer Graphics Inverse Kinematics n n n You can’t just invert the

33 Interactive Computer Graphics Inverse Kinematics n n n 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.

34 Interactive Computer Graphics Using Inverse Kinematics n n Specify joint constraints and priorities

34 Interactive Computer Graphics Using Inverse Kinematics n n Specify joint constraints and priorities Move end effector (or object pose) Let the system figure out joint positions [IK demo]

35 Interactive Computer Graphics Keyframe Animation n n n In traditional key frame animation

35 Interactive Computer Graphics Keyframe Animation n n n 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]

36 Interactive Computer Graphics Motion Capture n n n More realistic motion sequences can

36 Interactive Computer Graphics Motion Capture n n n More realistic motion sequences can be generated by Motion Capture Attach joint position indicators to real actors Record live action

37 Interactive Computer Graphics

37 Interactive Computer Graphics

38 Interactive Computer Graphics Morphing n n n Morphing: smoothly shifting from one image

38 Interactive Computer Graphics Morphing n n n Morphing: smoothly shifting from one image to another First popularized in a Michael Jackson video Method: a combination of n n 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

39 Interactive Computer Graphics 3 D Morphing n n n Define 3 D before

39 Interactive Computer Graphics 3 D Morphing n n n Define 3 D before and after shapes as e. g. NURBS surfaces with same number of control points Gradually move control points from first setting to second Specify key poses: e. g. smile, frown, 12 frames of walking motion

40 Interactive Computer Graphics Combined approaches

40 Interactive Computer Graphics Combined approaches

41 Interactive Computer Graphics Example: virtual puppetry n Suppose you want to display virtual

41 Interactive Computer Graphics Example: virtual puppetry n Suppose you want to display virtual puppet shows n n How could you animate puppet movements? How could you control the animations externally?

42 Interactive Computer Graphics Character Animation n To make computer graphics (or cartoon drawings)

42 Interactive Computer Graphics Character Animation n To make computer graphics (or cartoon drawings) come alive…

43 Interactive Computer Graphics Personality through Pose, Expression, Motion, Timing

43 Interactive Computer Graphics Personality through Pose, Expression, Motion, Timing

44 Interactive Computer Graphics

44 Interactive Computer Graphics

45 Interactive Computer Graphics Object-oriented Graphics n Higher in the programming hierarchy: control models

45 Interactive Computer Graphics Object-oriented Graphics n Higher in the programming hierarchy: control models with object-oriented programs robot robbie; robbie. smile(); robbie. walk(270, 5, 3);

46 Interactive Computer Graphics Data Structures for Modeling n n n This part of

46 Interactive Computer Graphics Data Structures for Modeling n n n 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

47 Interactive Computer Graphics CSG Tree

47 Interactive Computer Graphics CSG Tree

48 Interactive Computer Graphics Application 2: HSR n n n How to render in

48 Interactive Computer Graphics Application 2: HSR n n n How to render in 3 D 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.

49 Interactive Computer Graphics BSP-tree n n n The painter’s algorithm for hidden surface

49 Interactive Computer Graphics BSP-tree n n n 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-tofront order? Put them into a binary tree and traverse the tree (but in what order? )

50 Interactive Computer Graphics BSP Tree Figures n n n Right is “front” of

50 Interactive Computer Graphics BSP Tree Figures n n n 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)

51 Interactive Computer Graphics Traversing a BSP tree n Binary Space Partition tree: a

51 Interactive Computer Graphics Traversing a BSP tree n Binary Space Partition tree: a binary tree with a polygon at each node n n n Traversing a BSP-tree: n n n Children in left subtree are behind polygon Children in right subtree are in front of polygon 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?

52 Interactive Computer Graphics Building a BSP tree n Inserting a polygon: n n

52 Interactive Computer Graphics Building a BSP tree n Inserting a polygon: n n 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 n Worst case (O(n 2))…but usually it doesn’t grow too badly in practice…

53 Interactive Computer Graphics BSP-tree Summary n n n Returns polygons not necessarily in

53 Interactive Computer Graphics BSP-tree Summary n n n Returns polygons not necessarily in sorted order, but in an order that is correct for backto-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]

54 Interactive Computer Graphics Application 3: Handling Large Spatial Data Sets n Example application:

54 Interactive Computer Graphics Application 3: Handling Large Spatial Data Sets n Example application: image-based rendering n n n 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: n n Speeding up ray-tracing with many objects Rendering contours of 3 D volumetric data such as MRI scans

55 Interactive Computer Graphics Quadtree n n n Quadtree: divide space into four quadrants.

55 Interactive Computer Graphics Quadtree n n n Quadtree: divide space into four quadrants. Mark as Empty, Full, or Partially full. Recursively subdivide partially full regions Saves much time, space over 2 D pixel data!

56 Interactive Computer Graphics Quadtree Structure

56 Interactive Computer Graphics Quadtree Structure

57 Interactive Computer Graphics Octrees n n Generalize to cutting up a cube into

57 Interactive Computer Graphics Octrees n n Generalize to cutting up a cube into 8 subcubes, each of which may be E, F, or P (and subdivided) Much more efficient than a 3 D array of cells for 3 D volumetric data

58 Interactive Computer Graphics Quadtree Algorithms n How would you n n n render

58 Interactive Computer Graphics Quadtree Algorithms n How would you n n n 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?

59 Interactive Computer Graphics Applications of Octrees n n Contour finding in MRI data

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

60 Interactive Computer Graphics Research in Visibility n Can we figure out in advance

60 Interactive Computer Graphics Research in Visibility n Can we figure out in advance what will be visible from each viewpoint?

61 Interactive Computer Graphics Viewer-centered representation n Viewer-centered object representations: representation not of volume

61 Interactive Computer Graphics Viewer-centered representation n Viewer-centered object representations: representation not of volume of space filled but appearance from all viewpoints

62 Interactive Computer Graphics Occlusion in view space n Occlusion in view space is

62 Interactive Computer Graphics Occlusion in view space n Occlusion in view space is subtraction

63 Interactive Computer Graphics Events n Events: boundaries in viewpoint space where faces appear

63 Interactive Computer Graphics Events n Events: boundaries in viewpoint space where faces appear or disappear

64 Interactive Computer Graphics Aspect Graph n Aspect graph: a graph with a node

64 Interactive Computer Graphics Aspect Graph n Aspect graph: a graph with a node for every topologically distinct view of an object, with edges connecting adjacent views

65 Interactive Computer Graphics Aspect graph varieties n Aspect graphs can be constructed for

65 Interactive Computer Graphics Aspect graph varieties n Aspect graphs can be constructed for n n n 3 D: space 2 D: multiple axis rotations or planar motions 1 D: single-axis rotations

66 Interactive Computer Graphics 1 D Aspect Graph for Rotation

66 Interactive Computer Graphics 1 D Aspect Graph for Rotation

67 Interactive Computer Graphics 1 D Aspect Graph Results n n Useful for rotations

67 Interactive Computer Graphics 1 D Aspect Graph Results n n Useful for rotations without Z-buffer hardware! Not so useful for more viewer freedom, modern graphics hardware

68 Interactive Computer Graphics Conservative Visibility Preprocessing n n Q. can we take advantage

68 Interactive Computer Graphics Conservative Visibility Preprocessing n n 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

69 Interactive Computer Graphics Weak Visibility Subdivision n n Given an object and a

69 Interactive Computer Graphics Weak Visibility Subdivision n n 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

70 Interactive Computer Graphics Conservative Visibility Preprocessing on a Grid n n Divide viewing

70 Interactive Computer Graphics Conservative Visibility Preprocessing on a Grid n n Divide viewing space into a 3 D (or 2 D) grid Compute a conservative display list for each cell

71 Interactive Computer Graphics Conservative visibility algorithm n n Initialize a display list for

71 Interactive Computer Graphics Conservative visibility algorithm n n Initialize a display list for each grid cell Algorithm: for each object, wall, and cell n n 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!)

72 Interactive Computer Graphics Perspective n n What good did this visibility research do

72 Interactive Computer Graphics Perspective n n What good did this visibility research do for the world? It wasn’t enough for me n n I left graphics research and went into digital libraries Left University of Pittsburgh and went to Wheaton College

73 Interactive Computer Graphics Summary n n n 3 D modeling uses advanced primitives

73 Interactive Computer Graphics Summary n n n 3 D 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 3 D morphing animates surface control points 3 D spatial subdivision trees include CSGtrees, BSP-trees, Quadtrees, and Octrees Visibility preprocessing speeds walkthrough