Computer Graphics Matrix Hierarchies Animation - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Computer Graphics Matrix Hierarchies Animation

Description:

However, now we will focus on manipulating (animating) geometry that is: ... Two people carrying a stretcher. Need more complex solution for these cases ... – PowerPoint PPT presentation

Number of Views:186
Avg rating:3.0/5.0
Slides: 16
Provided by: lauren80
Category:

less

Transcript and Presenter's Notes

Title: Computer Graphics Matrix Hierarchies Animation


1
Computer GraphicsMatrix Hierarchies / Animation
  • CO2409 Computer Graphics
  • Week 21

2
Lecture Contents
  • Model Animation
  • Model/Matrix Hierarchies
  • Limitations of Hierarchies
  • Rendering a Model Hierarchy
  • Matrix Stacks
  • Process

3
Model Animation
  • So far we have looked at individual models
  • Each a fixed piece of geometry
  • No moving parts
  • We have animated these models
  • By moving and rotating them each frame
  • However, now we will focus on manipulating
    (animating) geometry that is
  • Made of several rigid parts or
  • Flexible with an underlying skeleton

4
Rigid Body Animation
  • We start with models made up of several rigid
    parts that can move with respect to each other
  • Mainly mechanical models, such as vehicles,
    doors, guns, robots etc.
  • A common assumption for such models is that the
    parts form a hierarchy
  • A tree structure defining how the parts are
    connected

5
Matrix Hierarchies
  • In such a hierarchy
  • Each part has a parent (or is the root of the
    tree)
  • A part can have any number of children (including
    0)
  • Each part in the hierarchy has a world matrix
  • Defining its position and orientation - just like
    a model
  • But the world matrix for each part is stored
    relative to its parent
  • So each part is defined in the local space of its
    parent
  • Root is stored in world space
  • Implies that child parts inherit their parents
    movement

6
Matrix Hierarchy Diagram
  • Such hierarchies are sometimes called Matrix
    Hierarchies or Transform Hierarchies

7
Building Hierarchies
  • The position of a childs origin determines where
    it will pivot relative to its parent
  • The orientation of its axes will determines how
    it will rotate (in X, Y and Z)
  • So the parts matrix defines the joint with its
    parent
  • Must ensure that we (or the artists) build the
    hierarchies and part matrices correctly
  • To allow required animation

8
Limitations of Hierarchies
  • Most multi-part objects fit naturally into a
    hierarchical form, but not all
  • A bicycle chain which link is the root?
  • Also assumes each part has only one parent that
    controls its movement
  • Not true when multiple forces involved
  • Train carriage with two engines
  • Two people carrying a stretcher
  • Need more complex solution for these cases
  • Use soft body methods or physics engine

9
Rendering Hierarchies
  • Need to render a hierarchy of model parts
  • Each with its own parent-relative world matrix
  • Can simply make the existing rendering code
    recursive the code for each part is
  • Get world matrix by combining this parts matrix
    with the parents world matrix
  • Render part with combined matrix
  • Repeat process for each child part
  • This process dictates a depth-first traversal of
    the hierarchy tree structure
  • To pass matrices from parent to child easily (see
    lab)

10
Rendering Hierarchies Matrix Stack
  • Recursion is inefficient for a real-world app
    that has many models with many parts
  • We can convert this recursive process into an
    iterative process
  • To help us we use a Matrix Stack
  • To store the matrices for ancestors of the
    current part
  • DirectX provides such a feature
  • Not difficult to write our own if necessary
  • This is an efficient LIFO structure for pushing
    and popping matrices

11
Rendering Hierarchies Efficiently
  • Put parts into a list in depth-first order
  • Done in advance
  • Also store depth in the hierarchy of each part
  • Each part has its parent-relative world matrix
  • Call it the local matrix
  • In the example will use L0, L1 etc.

12
Rendering Hierarchies Efficiently
  • Iterating through the list is now the same as
    traversing the tree depth-first
  • At each step, will keep track of
  • Absolute world matrix call it W
  • Current depth in hierarchy call it CurrentDepth
  • Initialise the process
  • Set W the identity / unit matrix
  • Set CurrentDepth 0
  • Start with empty matrix stack

13
Rendering Hierarchies cont
  • For each part x in the hierarchy list
  • Get depth of part x, call it NewDepth
  • If NewDepth gt CurrentDepth, push W onto stack
  • If NewDepth CurrentDepth, do nothing to stack
  • If NewDepth lt CurrentDepth, pop matrices from
    stack
  • Pop (CurrentDepth NewDepth) times
  • E.g. CurrentDepth 3, NewDepth 1, pop stack
    twice
  • Set W Matrix at top of stack Lx
  • Render part x using world matrix W
  • CurrentDepth NewDepth

14
Rendering Hierarchies Example
  • Starting with W identity(I) CurrentDepth 0
  • 0. NewDepth 1 gt CurrentDepth push W
    (StackI)
  • W Stack Top L0 L0 render base with
    world matrix L0
  • 1. NewDepth 2 gt current push W (StackI,L0)
  • W Stack Top L1 L0.L1 render arm
    with matrix L0.L1
  • 2. NewDepth 3 gt current push W
    (StackI,L0,L0.L1)
  • W Stack Top L2 L0.L1.L2 render grip1
    with matrix L0.L1.L2
  • 3. NewDepth 3 current no change
    (StackI,L0,L0.L1)
  • W Stack Top L3 L0.L1.L3 render grip2
    with matrix L0.L1.L3
  • 4. NewDepth 2 lt current pop stack 1 time
    (StackI,L0)
  • W Stack Top L4 L0.L4 render switch
    with matrix L0.L4

15
Rendering Hierarchies Example
  • Looking just at the render steps
  • Render base with world matrix L0
  • Render arm with matrix L0.L1
  • Render grip1 with matrix L0.L1.L2
  • Render grip2 with matrix L0.L1.L3
  • Render switch with matrix L0.L4
  • These are the correct combined matrices
Write a Comment
User Comments (0)
About PowerShow.com