3D Computer Animation 2008 09 18 2008.09.18 박경주 Rm 602(tel.5823) 중앙대학교 첨단영상대학원 박 경 주
3D Computer Animation
2008 09 182008.09.18박경주
Rm 602(tel.5823)
중앙대학교 첨단영상대학원 박 경 주
1 주, 09/04 Introduction,
2 주, 09/11 Keyframe Animation, Affine Geometry Review
3 주, 09/18 Interpolation, Hierarchical Modeling
4 주, 09/25 Forward kinematics/ Inverse Kinematics/Mocap 소개pHW 1 out
5 주, 10/02 예술 모캡사용, 공학설명 (Affine Transformations, Quaternion)
6 주, 10/09 Project1 Out, 공학설명 (Spline, VL 라이브러리)6 주, 10/09 Project1 Out, 공학설명 (Spline, VL 라이브러리)
7 주, 10/16 Project 1(예술 (Rigging & Posing), 공학 애니메이터 프로그램)
8 주, 10/23 Project1 Due,
9 주 10/309 주, 10/30
10 주, 11/06
11 주, 11/13
12 주, 11/20
13 주, 11/27
14 주, 12/04
중앙대학교 첨단영상대학원 박 경 주
주,
15 주, 12/11
Splines DefinitionInterpolation
Hierarchical ModelingHierarchical Modeling
중앙대학교 첨단영상대학원 박 경 주
SplinesSplines
S h i h l• Smooth curves in the plane or in 3D
• Many usages– 2D illustration (e.g. Adobe Illustrators)2D illustration (e.g. Adobe Illustrators)– Fonts– 3D modeling– 3D modeling– Color ramps
Animation: t ajecto ies– Animation: trajectories– In general, interpolate keyframes
중앙대학교 첨단영상대학원 박 경 주ACM © 1987 “Principles of
traditional animation applied to 3D computer animation”
Two definitions of curvesTwo definitions of curves
A i f i h l /i• A continuous set of points on the plane/in space
• A mapping from an interval of R onto the plane– That is, P(t) is the point of the curve at
parameter t
• Big difference: the second definition can describe trajectories, the speed at which we move on the curve
중앙대학교 첨단영상대학원 박 경 주
General principleGeneral principle
• User specifies control points• Defines a smooth curveDefines a smooth curve
중앙대학교 첨단영상대학원 박 경 주
Physical splinesPhysical splines
중앙대학교 첨단영상대학원 박 경 주www.abm.org
Two ways to look at the problemTwo ways to look at the problem
• Approximation/interpolation– We have data points, how can we e a e data po ts, o ca e
interpolate?
• User interface/modeling• User interface/modeling– What is an easy way to specify a smooth
curve– The main perspective today
중앙대학교 첨단영상대학원 박 경 주
UI/modelingUI/modeling
• How can we specify a curve?– Provide parametric function (x,y) = f(t)o de pa a et c u ct o ( ,y) (t)
• Like a trajectory overt time
– Analytical implicit description f(x y)=0– Analytical implicit description f(x,y)=0– Draw it with mouse!
id f i– Provide a few points• That’s what we will do today
중앙대학교 첨단영상대학원 박 경 주
SplinesSplines
S ifi d b f l i• Specified by a few control points– Good for UI– Good for storage
• Results in a smooth parametric curve P(t)p– Defined in Cartesian coordinates by x(t) and y(t)– Polynomial in practice– Convenient for animation where t is time– Convenient for tesselation because we can
discretize t and approximate the curve with smalldiscretize t and approximate the curve with small linear segments
중앙대학교 첨단영상대학원 박 경 주
Interpolation vs approximationInterpolation vs. approximation
• Interpolation– Goes through all specified pointsg p p– Sounds more logical
Interpolation
• ApproximationDoes not go through all points– Does not go through all points
Approximation
중앙대학교 첨단영상대학원 박 경 주
pp
Interpolation vs approximationInterpolation vs. approximation
• Interpolation– Goes through all specified pointsg p p– Sounds more logical– But can be more unstable, ringing
Interpolation
g g
• ApproximationDoes not go through all points– Does not go through all points
– Turns out to be convenientThis is what we’ll focus on– This is what we’ll focus on
Approximation
중앙대학교 첨단영상대학원 박 경 주
Questions?Questions?
중앙대학교 첨단영상대학원 박 경 주
Cubic Bezier splinesCubic Bezier splines
• User specifies 4 control points Pi• Curve goes through the two extremitiesCurve goes through the two extremities• Approximates the two other ones• Cubic polynomial
중앙대학교 첨단영상대학원 박 경 주
Cubic Bezier splinesCubic Bezier splinesThat is:• P(t) = (1-t)3 P1
+ 3t(1-t)2 P2
That is: x(t) = (1-t)3 x1
+3t (1-t)2x2+3t2(1-t)x3
( ) 2+ 3t2(1-t) P3+ t3 P4
+3t (1 t)x3+t3x4
x(t) = (1-t)3 y1+3t2(1-t)y2+ t P43t (1 t)y2
+3t2(1-t)y3+t3y4
중앙대학교 첨단영상대학원 박 경 주
Cubic Bezier splinesCubic Bezier splinesVerify what happens
• P(t) = (1-t)3 P1+ 3t(1-t)2 P2
Verify what happens for t=0 and t=1
( ) 2+ 3t2(1-t) P3+ t3 P4+ t P4
중앙대학교 첨단영상대학원 박 경 주
Cubic Bézier CurveCubic Bézier Curve
l• 4 control points• Curve passes through first & last control point
• Curve is tangent at P0 to (P1-P2) and at P4 to (P4-P3)
A Bézier curve is bounded by the convex
중앙대학교 첨단영상대학원 박 경 주
yhull of its control points.
Questions?Questions?
중앙대학교 첨단영상대학원 박 경 주
InterpolationInterpolation
중앙대학교 첨단영상대학원 박 경 주
Endpoints of B splinesEndpoints of B-splines
• We can see that B-splines don’t interpolate the Boor pointsp p
• It would be nice if we could at least control the endpoints of the splinescontrol the endpoints of the splines explicitly
• There’s a trick to make the spline begin and end at the de Boor points byand end at the de Boor points by repeating them
중앙대학교 첨단영상대학원 박 경 주
Endpoints of B splinesEndpoints of B-splines
• How many B0’s need to be repeated?
중앙대학교 첨단영상대학원 박 경 주
Wrapping the curvesWrapping the curves
• Wrapping is an important features that makes the animation restart smoothly ywhen looping back to the beginning
• Create “phantom” control points before• Create phantom control points before and after the first and the last control
ipoints
중앙대학교 첨단영상대학원 박 경 주
Speed ControlSpeed Control
• Simplest form is to have constant velocity along the pathy g p
x
t중앙대학교 첨단영상대학원 박 경 주
t
Arclength Time functionArclength-Time function
• In the linear interpolation case, we can use time (t) as the parameter, increment ( ) p ,it a constant amount, and evaluate the new positionnew position
• But there is a problem in the cubic polynomial casepolynomial case
중앙대학교 첨단영상대학원 박 경 주
Non Uniform parametersNon-Uniform parameters
Th bl i th t if t i th• The problem is that uniform steps in the parameter (u) don’t corresponds to uniform path distancesuniform path distances
• We need a relationship between theWe need a relationship between the parameters (u) and the distance traveled
중앙대학교 첨단영상대학원 박 경 주
Arclength reparameterizationArclength reparameterization
• We have a function Length(u) which evaluates the arclength for a given u, but g g ,we also want a way to find u given a particular arclength Sparticular arclength S
• Not possible analytically for most curves (e.g. B-splines)(e.g. B splines)
중앙대학교 첨단영상대학원 박 경 주
Finite DifferencesFinite Differences
• Sample the curve at small intervals of the parameter and determine the pdistance between samples
• Use these distances to build a table of• Use these distances to build a table of arclength for this particular curve
index parametric value arclength01
0.000 05
0.0000 0801
234
0.050.100.150 20
0.0800.1500.2300 320
중앙대학교 첨단영상대학원 박 경 주4 0.20 0.320
Speed control recipeSpeed control recipe
Gi i l k h di• Given a time t, lookup the corresponding arclength S in the speed curve
• For S look up the corresponding valueFor S, look up the corresponding value of u in the reparameterization table
• Evaluate the curve at u to obtain the correct interpolated position for the animated object for the given time t중앙대학교 첨단영상대학원 박 경 주
Ease in Ease out curveEase-in Ease-out curve
• Assume that the motion slows down at the beginning and end of the motion g gcurve
xx
t중앙대학교 첨단영상대학원 박 경 주
t
Ease in Ease outEase-in Ease-out
• What about rotation?• Can we interpolate rotation using theCan we interpolate rotation using the
these same techniques?Q t i i t l ti SLERP– Quaternion interpolation SLERP
중앙대학교 첨단영상대학원 박 경 주
Open QuestionsOpen Questions
• What should the key values be?• When should the key values occur?When should the key values occur?• What kind of bad things can occur from
i l i ? H d h ?interpolation? How do we prevent them?– Invalid configurations (pass through walls)g p g– Unnatural motions (painful twists)
중앙대학교 첨단영상대학원 박 경 주
Hierarchical ModelingHierarchical Modeling
중앙대학교 첨단영상대학원 박 경 주
Hierarchical ModelingHierarchical Modeling
• Create a character composed of primitive shapes (box, generalized cylinder, sphere, p ( , g y , p ,and triangle)
• Most graphics APIs support a few g p ppgeometric primitives
중앙대학교 첨단영상대학원 박 경 주
A Robot ArmA Robot Arm
• Consider this robot arm with 3 degress of freedom (DOFs):– Base rotates about its vertical axis by theta– Upper arm rotates in its x-y plane by phi– Lower arm rotates in its x-y plane by psi
중앙대학교 첨단영상대학원 박 경 주
Robot arm implementationRobot arm implementationb t ()
Matrix M_model;
Main(){
robot_arm(){
M_model = R_y(theta);base();
{…robot_arm();…
base();M_model = R_y(theta) *T(0, h1, 0)*R_z(phi);upper_arm();M_model = R_y(theta) *T(0,h1,0)*R_z(phi)*T(0, h2, 0)*R_z(psi);l ()
…}
lower_arm();}
• Do the matrix computation seem wasteful?
중앙대학교 첨단영상대학원 박 경 주
Better ImplementationBetter Implementation
• Instead of recalculating the global matrix each time, we can just update it in place by concatenating matrices on the right:
Matrix M_model;
Main(){
robot_arm(){
M_model *= R_y(theta);b (){
…M_model = Identity(); robot arm();
base();M_model *= T(0, h1, 0)*R_z(phi);upper_arm();M model *= T(0, h2, 0)*R z(psi); _ ();
…}
_ ( , , ) _ (p );lower_arm();
}
중앙대학교 첨단영상대학원 박 경 주
OpenGL implementationOpenGL implementation
• OpenGL maintains a global state matrix called the model-view matrix, which is update by concatenating matrices on the right:
robot arm()Matrix M_model;
Main(){
robot_arm(){
glRotatef(theta, 0.0, 1.0, 0.0);base();
{…
glMatrixMode(GL_MODELVIEW); glLoadIdentity();
glTranslatef(0.0, h1, 0.0);glRotatef(phi, 0.0, 0.0, 1.0); upper_arm();glTranslatef(0 0 h2 0 0);g y();
robot_arm();…
}
glTranslatef(0.0, h2, 0.0);glRotatef(psi, 0.0, 0.0, 1.0);lower_arm();
}
중앙대학교 첨단영상대학원 박 경 주
Hierarchical modelingHierarchical modeling
• Hierarchical models can be composed of instances using trees or DAGs:g– Edges contain geometric transformation
Nodes contain geometry and drawing– Nodes contain geometry and drawing
chassis
Right-frontwheel
Right-rearwheel
Left-frontwheel
Left-rearwheel
중앙대학교 첨단영상대학원 박 경 주wheel wheel wheel wheel
A Human ModelA Human Model
pelvis
Right upper leg
Left upper leg
torso
Right lower leg
Left lower leg
Right upper arm
Left upperarm
head
Right lowerarm
Left lowerarmarm arm
중앙대학교 첨단영상대학원 박 경 주What is the most sensible way to traverse the tree?
KinematicsKinematics
k l• How to animate skeletons– Articulated figures
Ki ti i th t d f ti ith t d t• Kinematics is the study of motion without regard to the forces that caused it
• Joints• Joints– Revolute (hinge) joint allows rotation about a fixed axis– Prismatic joint allows translation along a linePrismatic joint allows translation along a line– Ball-and-socket joint allows rotation about an arbitrary axis
중앙대학교 첨단영상대학원 박 경 주
Human JointsHuman Joints
• Human joints are much more complicatedp
중앙대학교 첨단영상대학원 박 경 주
Project Requirements (I)Project Requirements (I)
• The character should use at least ten primitives and at least four levels of phierarchy
중앙대학교 첨단영상대학원 박 경 주
Project Requirements (I)Project Requirements (I)
K f i iKeyframe animation• The pose is determined by the control p y
parameters (degrees of freedom) of the model
• Each parameter has a separate curve describing how it changes over timedescribing how it changes over time
중앙대학교 첨단영상대학원 박 경 주
Project: TimingProject: Timing
• Timing is very, very important
• Consider timing before you bother to ifi b j i iget specific about joint rotations or
object positions
중앙대학교 첨단영상대학원 박 경 주