Animacja Komputerowa - PowerPoint PPT Presentation

1 / 31
About This Presentation
Title:

Animacja Komputerowa

Description:

The mechanism has 3 degrees of freedom, each of which can be ... This function might be called from the display callback ... Tony de Peltrie, a jazz pianist ... – PowerPoint PPT presentation

Number of Views:36
Avg rating:3.0/5.0
Slides: 32
Provided by: rick238
Category:

less

Transcript and Presenter's Notes

Title: Animacja Komputerowa


1
Animacja Komputerowa
  • Barbara Strug
  • Elektroniczne Przetwarzanie Informacji
  • Semestr IV, Lato 2005

2
Wstep
  • Rózne podejscia do tworzenie modeli obiektów
    geometrycznych na potrzeby animacji.
  • Rozszerzenia standardowych transformacji do
    struktur hierarchicznych.
  • Metody, które mozna wykorzystac w zastosowanaich
    takich jak budowa robotów i animacja postaci, w
    szczególnosci uwzglednimy systuacje gdzie
    zachowanie calosci obiektu jest mocno
    uzaleznione od relacji pomiedzy jego czesciami

3
Symbole i instancje
  • Jak reprezentowac i przechowywac obiekt/model,
    który moze skladac sie z wielu zlozonych obiektów
    geometrycznych.
  • Dwa problemy
  • Co to jest obiekt zlozony?
  • Jak reprezentowac zbiór takich obiektów?
  • Czy daloby sie zrobic taka reprezentacje bez
    uzycia hierarchii? Symbole i zbiory symboli ?

4
  • Symbole mozemy reprezentowac w pasujacym nam
    rozmiarze i orientacji.
  • Walec
  • W OpenGL nalezy ustawic wlasciwa transformacje z
    przestrzeni symbolu (lokalnej) do przestrzeni
    swiata (globalnej) przed wywolaniem kodu symbolu.

5
  • Przyklad transformacja
  • M TRS
  • zlozenie translacji, rotacji (obrotu) i
    skalowania
  • Kod OpenGL
  • glMatrixMode(GL_MODELVIEW)
  • glLaodIdentity()
  • glTranslatef(...)
  • glRotatef(...)
  • glScalef(...)
  • glutSolidCylinder(...)

6
  • Mozna taki model potraktowac takze jako tablice
  • Tablica nie zawiera informacji o relacjach
    pomiedzy obiektami, ale pozwala je narysowac.
  • Taka struktura danych pozwala na wiele
    zastosowan, ale ciagle nie mozemy dotrzec do
    relacji/wspólzaleznosci.

7
Modele Hierarchiczne
  • Budujemy np.. Samochód na potrzeby animacji.
  • Niech sklada sie z nadwozia i 4 kól

8
  • Klatki animacji
  • Mozna obliczyc jak daleko przesunelo sie kolo np.
    tak
  • calculate(speed, distance)
  • draw_right_front_wheel(speed, dist)
  • draw_left_front_wheel(speed, dist)
  • draw_right_rear_wheel(speed, dist)
  • draw_left_rear_wheel(speed, dist)
  • draw_chassis(speed, dist)

9
  • Ale nie calkiem o to nam chodzi.
  • Taki zapis jest liniowy i nie pokazuje relacji
    pomiedzy poszczególnymi elementami kola nie
    jada kazde inaczej !
  • There are two types of relationships we wish to
    convey
  • First, we cannot separate the movement of the car
    from the movement of the wheels
  • If the car moves forward, the wheels must turn.
  • Second, we would like to note that all the wheels
    are identical and just located and oriented
    differently.
  • We typically do this with a graph.
  • Def node, edge, root, leaf, ...

10
  • Tree Representation
  • DAG Representation

11
A Robot Arm
  • Robotics provides many opportunities for
    developing hierarchical models.
  • Consider this arm
  • It consists of 3 parts

12
  • The mechanism has 3 degrees of freedom, each of
    which can be described by a joint angle between
    the components
  • In our model, each joint angle determines how to
    position a component with respect to the
    component to which it is attached
  • q - rotation of the base
  • f - rotation of first arm
  • y - rotation of second arm piece.

13
  • We could write it as follows
  • display()
  • glRotatef(theta, 0.0, 1.0, 0.0)
  • base()
  • glTranslatef(0.0, h1, 0.0)
  • glRotatef(phi, 0.0, 0.0, 1.0)
  • lower_arm()
  • glTranslatef(0.0, h2, 0.0)
  • glRotatef(0.0, 0.0, 1.0)
  • upper_arm()

14
  • Note that we have described the positioning of
    the arm independently of the details of the
    individual parts.
  • We have also put it into a tree structure
  • This makes it possible to write separate programs
    to describe the components and animate the robot.
  • Drawing an object stored in a tree requires
    performing a tree traversal (you must visit every
    node)

15
4. Tree Traversal
  • Here we have a box-like representation of a human
    figure.
  • We can represent this figure as a tree

16
  • If we put the matrices with each node we can
    specify exactly how to draw the robot
  • The issue is how to traverse the tree...
  • Typically you do a pre-order traversal.
  • This can be done in two ways
  • with code and a stack
  • recursively (implicit stack)

17
  • 4.1 A Stack-Based Traversal
  • Consider the code necessary to draw the Robot.
  • This function might be called from the display
    callback
  • The Model-View matrix, M, in effect when the
    function is invoked determines the position of
    the robot relative to the rest of the scene.

18
  • The function must manipulate the model-view
    matrix before each part of the robot is drawn.
  • In addition to the usual OpenGL functions for
    rotation, translation, and scaling, the functions
    glPushMatrix and glPopMatrix are particularly
    helpful for traversing our tree.
  • The first glPushMatrix duplicates the current
    model-view matrix
  • assuming that we have done a previous
    glMatrixMode(GL_MODELVIEW)
  • When we have finished with changes we can do a
    glPopMatrix to get back the original one saved
  • Note we must do another glPushMatrix to leave a
    copy that we can later go back to.

19
(No Transcript)
20
(No Transcript)
21
(No Transcript)
22
(No Transcript)
23
(No Transcript)
24
5. Use of Tree Data Structures
  • The second approach is to use a standard tree
    data structure to represent our hierarchy and
    then to render it with a traversal algorithm that
    is independent of the mode of traversal.

25
  • At each node we must store the information
    necessary to draw the object
  • a function that defines the object
  • the homogeneous coordinate matrix that positions
    the object relative to the parent.
  • Typedef struct treenode
  • Glfloat m16
  • void (f)()
  • struct treenode sibling
  • struct treenode child

26
  • Traversing the tree in a preorder traversal can
    be accomplished
  • void traverse (treenode root)
  • if(root NULL) return
  • glPushMatrix()
  • glMultMatrix(root-gtm)
  • root-gtf()
  • if(root-gtchild! NULL) traverse(root-gtchild)
  • glPopMatrix()
  • if(root-gtsibling! NULL) traverse(root-gtsibling
    )

27
6. Animation
  • Our robot example is articulated
  • consists of rigid parts connected by joints
  • We can make such models change their positions in
    time - animate them - by altering a small set of
    parameters.
  • Hierarchical models allow us to reflect correctly
    the compound motions incorporating the physical
    relationships among parts of the model.

28
  • Of the many approaches to animation, a few basic
    techniques are of particular importance when we
    work with articulated figures.
  • Kinematics
  • describing the position of the parts of the model
    based on only their joint angles.
  • Inverse kinematics and inverse dynamics
  • given a desired state of the model, how can we
    adjust the angles so as to achieve this position?
  • key-frame animation
  • position the objects at a set of times.
  • Inbetweening
  • then fill in (interpolate).

29
Animating Articulated Structures
  • The desire to use human beings as synthetic
    actors in three-dimensional computer animation
    environments
  • Lachapelle, Bergeron, and Robidoux, Tony de
    Peltrie, a jazz pianist
  • Magnenat-Thalmann and Thalmann, Rendezvous a
    Montreal, Marilyn Monroe and Humphrey Bogart

30
Terminologies of Articulated Figure Animation
  • Definition, textbook, page 370
  • Kinematics
  • Articulated figure
  • Degrees of freedom (DOF)
  • End effector
  • State vector, q(q1, , qN)
  • example any unconstrained rigid body has 6 DOFs,
    3 translational and 3 rotational,
    q(x,y,z,m,f,F).

31
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com