ARVc 3
ARVc 3
&
VIRTUAL REALITY
2º Ciclo em:
Engenharia Informática
Design e Desenvolvimento de Jogos Digitais
DI – UBI 2014/2015
Program
! Computer Animation vs Traditional Animation
! Basic Techniques
! Advanced Techniques
! Modeling and Animating Articulated models
! Animating Natural Phenomena
! Virtual Reality/Virtual Environments
1
Chapter 3
! Advanced Techniques
! Automatic Camera Control
! Hierarchical Kinematic Modeling
! Forward Kinematics
! Inverse Kinematics
! Flexible Objects
2
Automatic Camera
Control (cont.)
Automatic Camera
Control (cont.)
! Center-of-interest
" Relative to the positions of one or more objects in the animation
3
Automatic Camera
Control (cont.)
! Predefined plane
" Keep the camera at a specified altitude so that it can capture the
action below.
Automatic Camera
Control (cont.)
4
Chapter 3
! Advanced Techniques
! Automatic Camera Control
! Hierarchical Kinematic Modelling
! Forward Kinematics
! Inverse Kinematics
! Flexible Objects
5
Hierarchical Kinematic Modeling (cont.)
! Prismatic join
" One link translates
relative to another
6
Hierarchical Kinematic Modeling (cont.)
! Complex joints
! Planar joint (2 DOF)
7
Hierarchical Kinematic Modeling (cont.)
8
Hierarchical Kinematic Modeling (cont.)
! Rotational Joints
" The point of rotation on the object part is made to coincide with the
origin.
9
Hierarchical Kinematic Modeling (cont.)
! TC=T0.T1.T2.T3 T0
T1
T2
T3
Chapter 3
! Advanced Techniques
! Automatic Camera Control
! Hierarchical Kinematic Modeling
! Forward Kinematics
! Inverse Kinematics
! Flexible Objects
10
Forward Kinematics
! Kinematics
! The motion of objects without reference to the forces which
cause the motion.
11
Forward Kinematics (cont.)
12
Local Coordinate Frames
Local Coordinate
Frames (cont.)
! Denavit-Hartenberg Notation
! Is a particular way of describing the relationship of a
parent coordinate frame to a child coordinate frame.
" This convention is commonly used in robotics and often adopted
for use in computer animation.
13
Local Coordinate
Frames (cont.)
Local Coordinate
Frames (cont.)
14
Local Coordinate
Frames (cont.)
! DH Notation (general case)
! di+1 and θi+1 are the translation and rotation of the i+1 joint
relative to the ith joint with respect to the ith joint’s z-axis.
! ai and αi are the translation and rotation of the
i+1 joint with respect to the ith joint’s x-axis.
Local Coordinate
Frames (cont.)
! DH Notation
Example:
! Point Vi+1 in coordinate system of joint i+1
! The coordinates in terms of joint i are:
15
Local Coordinate
Frames (cont.)
! DH Notation (example)
Vi = TX (ai ) RX (α i )TZ (d i +1 ) RZ (θ i +1 )Vi +1
⎡cos(θ i +1 ) − sin(θ i +1 )
0 0⎤ ⎡1 0 0 0 ⎤
⎢ sin(θ ) cos(θ ) 0 0⎥⎥ ⎢0 1 0 0 ⎥⎥
i +1 i +1
RZ (θ i +1 ) = ⎢ TZ (d i +1 ) = ⎢
⎢ 0 0 1 0⎥ ⎢0 0 1 d i +1 ⎥
⎢ ⎥ ⎢ ⎥
⎣ 0 0 0 1⎦ ⎣0 0 0 1 ⎦
⎡1 0 0 0⎤ ⎡1 0 0 ai ⎤
⎢0 cos(α i ) − sin(α i ) 0⎥⎥ ⎢0 1 0 0 ⎥⎥
RX (α i ) = ⎢ TX (ai ) = ⎢
⎢0 sin(α i ) cos(α i ) 0⎥ ⎢0 0 1 0 ⎥
⎢ ⎥ ⎢ ⎥
⎣0 0 0 1⎦ ⎣0 0 0 1 ⎦
Local Coordinate
Frames (cont.)
! DH Notation (example)
Vi = TX (ai ) RX (α i )TZ (d i +1 ) RZ (θ i +1 )Vi +1
⎡ cos(θ i +1 ) − sin(θ i +1 ) 0 ai ⎤
⎢cos(α ). sin(θ ) cos(α ). cos(θ ) − sin(α ). − d . sin(α )⎥
i i +1 i i +1 i i +1 i ⎥
M ii +1 = ⎢
⎢ sin(α i ). sin(θ i +1 ) sin(α i ). cos(θ i +1 ) cos(α i ) d i +1. cos(α i ) ⎥
⎢ ⎥
⎣ 0 0 0 1 ⎦
Vi = M ii +1Vi +1 (
Vi +1 = M ii +1 Vi
−1
)
16
Local Coordinate
Frames (cont.)
! Simple manipulator using three Revolute Joint
Local Coordinate
Frames (cont.)
! Including a
Ball-and-Socket
Joint
17
Chapter 3
! Advanced Techniques
! Automatic Camera Control
! Hierarchical Kinematic Modeling
! Forward Kinematics
! Inverse Kinematics
! Flexible Objects
Inverse Kinematics
18
Inverse Kinematics (cont.)
19
Inverse Kinematics (cont.)
20
Inverse Kinematics (cont.)
! The first step is to make sure that the position of the goal is
within the reach of the end effector.
L1− L2 ≤ X 2 + Y 2 ≤ L1+ L2
Cosine Rule
2 2 2
C = A + B − 2 ⋅ A ⋅ B ⋅ cos(θ )
2 2 2
A +B −C
cos(θ ) =
B 2⋅ A ⋅ B
θ
A
C
21
Inverse Kinematics (cont.)
X
cos(θT ) =
X2 +Y2
X
θT = acos( 2 2
)
X +Y
2
cos(θ1 − θT ) =
L12 + ( X2 +Y2 ) − L2 2
(cosine rule)
2 2
2 ⋅ L1⋅ X € +Y
⎛ L12 + X 2 + Y 2 − L2 2 ⎞
θ1 = acos⎜ ⎟ + θT
⎝ 2 ⋅ L1⋅ X 2 + Y 2 ⎠
cos(180 − θ 2 ) =
L12 + L2 2 − ( X2 +Y2 ) (cosine rule)
2 ⋅ L1⋅ L2
⎛ L12 + L2 2 − (X 2 + Y 2 ) ⎞
θ 2 = acos⎜ ⎟
⎝ 2 ⋅ L1⋅ L2 ⎠
€
22
Inverse Kinematics (cont.)
! Example
Consider the simple three-revolute-joint
23
Inverse Kinematics (cont.)
gi = ri × vi
cross product
r2
24
Chapter 3
! Advanced Techniques
! Automatic Camera Control
! Hierarchical Kinematic Modeling
! Forward Kinematics
! Inverse Kinematics
! Flexible Objects
25
Rigid Body Simulation (cont.)
26
Rigid Body Simulation (cont.)
! To update the position of the point over time, its position x(t),
velocity v(t), and acceleration a(t), are used.
27
Rigid Body Simulation (cont.)
28
Rigid Body Simulation (cont.)
! Modeling of a
point position at
discrete time
intervals.
29
Rigid Body Simulation (cont.)
! Second-order Runge-Kutta
" Which uses derivative information from the midpoint of the stepping
interval.
! Higher-order Runge-Kutta methods are more accurate (e.g.,
fourth- or fifth-order Runge-Kutta).
! Fourth-order Runge-Kutta
30
Rigid Body Simulation (cont.)
31
Rigid Body Simulation (cont.)
32
Rigid Body Simulation (cont.)
! Center of Mass
! In computer graphics, the mass distribution of an object
is typically modeled by individual points, which is usually
implemented by assigning a mass value to each of the
object’s vertices.
! If the individual masses are given by mi, then the total
mass of the object is given by
M = ∑ mi
! Center of Mass
! Assuming that x(t ) is the center of mass of an object.
! If the location of each mass point in world space is given
by qi(t ), then the center of mass is represented by:
x(t ) =
∑ m ⋅ q (t )
i i
33
Rigid Body Simulation (cont.)
! Forces
! A linear force, F, applied to a mass, m, gives rise to a linear
acceleration, a.
F = m⋅a
! This fact provides a way to calculate acceleration from the
application of forces.
F
a=
m
! Forces
! The various forces acting on a point can be summed to form the
total external force, F(t ).
F (t ) = ∑ f i (t )
! The rotational equivalent of linear force is torque. The torque
that arises from the application of forces acting on a point of
an object is given by:
τ (t ) = ∑τ t (t )
34
Rigid Body Simulation (cont.)
35
Rigid Body Simulation (cont.)
L = r× p
36
Rigid Body Simulation (cont.)
! Inertia Tensor
! Angular momentum is related to angular velocity in much the
same way that linear momentum is related to linear velocity,
P(t)=M . v(t ).
! So, L(t ) = I (t ) ⋅ ω (t )
! In the case of angular momentum, a 3x3 matrix is needed to
describe the distribution of mass of the object in space, the
inertia tensor, I(t ).
37
Rigid Body Simulation (cont.)
I xz ⎤ I xx = ∑ mi ⋅ (yi + zi )
2 2
⎡ I xx I xy I xy = ∑ mi ⋅ xi ⋅ yi
⎢ ⎥
I object = ⎢ I xy I yy I yz ⎥ I yy = ∑ mi ⋅ (xi2 + zi2 ) I xz = ∑ mi ⋅ xi ⋅ zi
⎢ I xz
⎣ I yz I zz ⎥⎦ I zz = ∑ mi ⋅ (xi2 + yi2 ) I yz = ∑ mi ⋅ yi ⋅ zi
! The inertia tensor for a transformed object depends on the
orientation. Thus, it is dependent on time.
! The Equations
! The state of an object can be kept in a vector, S(t ), consisting
of:
" Position; ⎡ x(t ) ⎤
" Orientation;
⎢ R(t )⎥
" Linear momentum; S (t ) = ⎢ ⎥
⎢ P(t )⎥
" Angular momentum.
⎢ ⎥
⎣ L(t ) ⎦
! Object attributes which not change over time are:
" Mass, M
" Object-space Inertia tensor, Iobject
38
Rigid Body Simulation (cont.)
! The time derivate of the object’s state vector can now be formed:
⎡ x(t ) ⎤ ⎡ v(t ) ⎤
⎢ ⎥ ⎢ ⎥
d d ⎢ R(t )⎥ ⎢ω (t ) × R(t )⎥
S (t ) = =
dt dt ⎢ P(t )⎥ ⎢ F (t ) ⎥
⎢ ⎥ ⎢ ⎥
⎣ L(t ) ⎦ ⎣ τ (t ) ⎦
! This is enough information to run a simulation with numerical
method (e.g, Euler, Runge-Kutta).
! Care must be taken in updating the orientation of an object!
(Rotation matrix can quickly becomes
nonorthogonal and not of unit length)
39
Chapter 3
! Advanced Techniques
! Automatic Camera Control
! Hierarchical Kinematic Modeling
! Forward Kinematics
! Inverse Kinematics
! Flexible Objects
Flexible Objects
! Plasticity
! Fracture
40
Flexible Objects (cont.)
! Spring-Mass-Damper
! Model each vertex of an object as a point mass
! Each edge of the object as a spring
" Each spring’s rest length is set equal to the original length of the edge;
" A mass can be arbitrarily assigned
to an object;
V1
" Spring constants are assigned E12
throughout the object to some
user-specified value.
E31 V2
E23
V3
41
Flexible Objects (cont.)
! Drawbacks
" The number of vertices used to model an object and the length of
edges used have an effect on the object’s reaction to forces.
! Dampers
" A damper introduces an additional force in the spring that works
against the velocity of the spring length, thus helping to limit the
speed at which a spring changes length.
" A damper imparts a force in the direction opposite to the velocity
of the spring length and is proportional to that velocity.
" Additional spring dampers can help
to stabilize the shape of an object.
42
Flexible Objects (cont.)
! Virtual Springs
" Introduces forces into the system that do not directly model physical
elements.
" Virtual spring with zero rest lengths can be used to constrain one
object to lie on the surface of another;
" Virtual spring with non zero rest lengths, to maintain separation
between moving objects.
" Proportional derivative controllers are another type of virtual spring
used to keep a control variable and its derivative within the
neighborhood of desired values (e.g., to maintain a joint angle).
Chapter 3
! Advanced Techniques
! Automatic Camera Control
! Hierarchical Kinematic Modeling
! Forward Kinematics
! Inverse Kinematics
! Flexible Objects
43
Controlling Groups of Objects
Some with
Flock Some environment Limited
and other
elements
44
Controlling Groups of Objects (cont.)
! Particle Systems
! Particle Systems
! A particle system is a large collection of individual elements,
which taken together, represent a conglomerate, fuzzy object.
! Both the behavior and the appearance of each individual
particle are very simple.
! The individual particles typically behave according to simple
physical principles with respect to their environment but not
with respect to other particles of the system.
45
Controlling Groups of Objects (cont.)
! Particle Systems
! When viewed together, the particles create the impression
of a single, dynamic, complex object.
! Particle Systems
! Because typically there are a large number of elements in a
particle system, simplifying assumptions are used in both the
rendering and the calculation of their motions.
" Particles do not collide with other particles;
" Particles do not cast shadows, except in an aggregate sense;
" Particles only cast shadows on the rest of the environment;
" Particles do not reflect light - they are modeled as point light sources.
46
Controlling Groups of Objects (cont.)
47
Controlling Groups of Objects (cont.)
! Particle Generation
! Particles are typically generated according to a controlled
stochastic process.
! For each frame, a random number of particles is generated
using some user-specified distribution centered at the desired
average number of particles per frame.
# particles = average + Rand() * range
! Particle Attributes
! The attributes of a particle determine its motion status, its
appearance, and its life in the system.
" Position
" Velocity
" Shape parameters
" Color
" Transparency
" Lifetime
48
Controlling Groups of Objects (cont.)
! Particle Animation
! Each active particle is animated throughout its life.
! To animate the particle’s position in space, the user considers
forces and computes the resultant particle acceleration.
" The forces are: gravity, global forces (e.g., wind), local forces field,
and collisions with other objects.
! The velocity of a particle is updated from its acceleration,
and then the average velocity is computed and used to
update the particle’s position.
! Particle Animation
! The particle’s color and transparency can be function of a
global time, its height, and so on.
! The particle’s shape can be a function of its velocity:
" For example:
- an ellipsoid can be used to represent a moving particle where the
major axis of the ellipsoid is aligned with the direction of travel and
- the ratio of the ellipsoid’s length to the radius of its circular cross
section is related to its speed.
49
Controlling Groups of Objects (cont.)
! Flocking Behavior
! Flocking Behavior
! Flocking can be characterized as having a moderate number
of members (relative to particle systems).
! Each member is controlled by a relatively simple set of rules
that operate locally.
! The members exhibit limited intelligence and are governed
by relatively simple physics.
! As compared to particle systems, there are few elements and
there is usually more interelement interaction modeled.
50
Controlling Groups of Objects (cont.)
! Flocking Behavior
! As with particle systems, aggregate behavior emerges from
the local behavior of members of the flock;
" It is emergent behavior.
! The flocking behavior manifests itself as a goal-directed
body, able to split into sections and re-form, creating
organized patterns of flock members that can perform
coordinated maneuvers.
! Example: birds-in-flight.
! Flocking Behavior
51
Controlling Groups of Objects (cont.)
! Flocking Behavior
52
Controlling Groups of Objects (cont.)
53
Controlling Groups of Objects (cont.)
54
Controlling Groups of Objects (cont.)
55
Controlling Groups of Objects (cont.)
56
Controlling Groups of Objects (cont.)
Flight module
Flight articulation
57
Controlling Groups of Objects (cont.)
58
Controlling Groups of Objects (cont.)
! Drawbacks
" It prevents a flock member from traveling close and parallel to the
surface of an object.
" The repelling force is as strong for a flock member moving parallel
to a surface as it is for a flock member moving directly toward the
surface.
59
Controlling Groups of Objects (cont.)
60
Controlling Groups of Objects (cont.)
! Autonomous Behavior
! Autonomous behavior refers to the motion of an object that
results from modeling its cognitive processes.
61
Controlling Groups of Objects (cont.)
62
Controlling Groups of Objects (cont.)
! Simple model
" The object simply has access to the environment database.
! Complex model
" Involve sensors, including the vision and memory.
63
Controlling Groups of Objects (cont.)
! Internal state
! Internal state is modeled partially by intentions.
" Intentions take on varied importance depending on the urges they
are meant to satisfy.
! Most important intention is:
" The instinct of survive.
! Internal state also includes things as:
" Inhibitions;
" Identifications of areas of interest;
" Emotional state.
64
Controlling Groups of Objects (cont.)
! Levels of behavior
65
Controlling Groups of Objects (cont.)
! Crowds
66