Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
ALICE experiment wikipedia , lookup
Double-slit experiment wikipedia , lookup
Future Circular Collider wikipedia , lookup
Standard Model wikipedia , lookup
ATLAS experiment wikipedia , lookup
Electron scattering wikipedia , lookup
Relativistic quantum mechanics wikipedia , lookup
Identical particles wikipedia , lookup
Compact Muon Solenoid wikipedia , lookup
Theoretical and experimental justification for the Schrödinger equation wikipedia , lookup
CS559: Computer Graphics Lecture 36: Animation Li Zhang Spring 2008 Many slides from James Kuffner’s graphics class at CMU Today • Traditional Animation, Computer Animation • Reading • (Optional) Shirley, ch 16, overview of animation Animation • Traditional Animation – without using a computer Animation • Computer Animation Types of Animation • Cartoon Animation Types of Animation • Cartoon Animation • Key Frame Animation Types of Animation • Cartoon Animation • Key Frame Animation • Physics based animation Nguyen, D., Fedkiw, R. and Jensen, H., "Physically Based Modeling and Animation of Fire", SIGGRAPH 2002 Types of Animation • Cartoon Animation • Key Frame Animation • Physics based animation Enright, D., Marschner, S. and Fedkiw, R., "Animation and Rendering of Complex Water Surfaces", SIGGRAPH 2002 Types of Animation • • • • Cartoon Animation Key Frame Animation Physics based animation Data driven animation Types of Animation • • • • Cartoon Animation Key Frame Animation Physics based animation Data driven animation Types of Animation • • • • Cartoon Animation Key Frame Animation Physics based animation Data driven animation Types of Animation • • • • Cartoon Animation Key Frame Animation Physics based animation Data driven animation Principles of Animation • Goal: make characters that move in a convincing way to communicate personality and mood. • Walt Disney developed a number of principles. – ~1930 • Computer graphics animators have adapted them to 3D animation. John Lasseter. Principles of traditional animation applied to 3D computer animation. Proceedings of SIGGRAPH (Computer Graphics) 21(4): 35-44, July 1987. Principles of Animation • The following are a set of principles to keep in mind: 1. Squash and stretch 2. Staging 3. Timing 4. Anticipation 5. Follow through 6. Overlapping action 7. Secondary action 8. Straight-ahead vs. pose-to-pose vs. blocking 9. Arcs 10. Slow in, slow out 11. Exaggeration 12. Appeal Squash and stretch • Squash: flatten an object or character by pressure or by its own power. • Stretch: used to increase the sense of speed and emphasize the squash by contrast. • Note: keep volume constant! • • http://www.siggraph.org/education/materials/HyperGraph/animation/character_ animation/principles/squash_and_stretch.htm http://www.siggraph.org/education/materials/HyperGraph/animation/character_ animation/principles/bouncing_ball_example_of_slow_in_out.htm Squash and stretch (cont’d) Squash and stretch (cont’d) Anticipation • An action has three parts: anticipation, action, reaction. • Anatomical motivation: a muscle must extend before it can contract. • Prepares audience for action so they know what to expect. • Directs audience's attention. • Watch: bugs-bunny.virtualdub.new.mpg Anticipation (cont’d) • Amount of anticipation (combined with timing) can affect perception of speed or weight. Arcs • Avoid straight lines since most things in nature move in arcs. Slow in and slow out • An extreme pose can be emphasized by slowing down as you get to it (and as you leave it). • In practice, many things do not move abruptly but start and stop gradually. Exaggeration • Get to the heart of the idea and emphasize it so the audience can see it. Exaggeration • Get to the heart of the idea and emphasize it so the audience can see it. Appeal • • • • The character must interest the viewer. It doesn't have to be cute and cuddly. Design, simplicity, behavior all affect appeal. Example: Luxo, Jr. is made to appear childlike. Appeal (cont’d) • Note: avoid perfect symmetries. Appeal (cont’d) • Note: avoid perfect symmetries. Particle Systems • http://en.wikipedia.org/wiki/Particle_system What are particle systems? • A particle system is a collection of point masses that obeys some physical laws (e.g, gravity, heat convection, spring behaviors, …). • Particle systems can be used to simulate all sorts of physical phenomena: Particle in a flow field • We begin with a single particle with: x x y – Position, v x – Velocity, dx / dt dx dt dy / dt x g(x,t ) y g(x,t) • Suppose the velocity x is actually dictated by some driving function g: x Vector fields • At any moment in time, the function g defines a vector field over x: • How does our particle move through the vector field? Diff eqs and integral curves • The equation x g(x,t ) • is actually a first order differential equation. • We can solve for x through time by starting at an Start Here initial point and stepping along the vector field: Euler’s method • One simple approach is to choose a time step, x(t Dt ) x(t ) Dt x(t ) Dt, and take linear steps along the flow: x(t ) Dt g(x ,t ) x iteration: x Dt v • Writing as a time i 1 i i • This approach is called Euler’s method and looks like: Particle in a force field • Now consider a particle in a force field f. • In this case, the particle has: dv d x a x v 2 – Mass, m – Acceleration, dt dt 2 f ma mx • The particle obeys Newton’s law: x f (x , x ,t ) m • The force field f can in general depend on the position and velocity of the particle as well as time. • Thus, with some rearrangement, we end up with: Second order equations This equation: x f (x , v ,t ) m is a second order differential equation. Our solution method, though, worked on first order differential equations. We can rewrite this as: x v f (x , v ,t ) v m where we have added a new variable v to get a pair Phase space x v x v x v v f / m • Concatenate x and v to make a 6-vector: position in phase space. • Taking the time derivative: another 6-vector. • A vanilla 1st-order differential equation. Differential equation solver Starting with: x v v f / m Applying Euler’s method: x(t Dt ) x(t ) Dt x(t ) x(t Dt ) x(t ) Dt x(t ) And making substitutions: x(t Dt ) x(t ) Dt v(t ) v(t Dt ) x(t ) Dt f (x , x ,t ) m Writing this as an iteration, we have: x i 1 x i Dt v i v i 1 fi v Dt m i Again, performs poorly for large Dt. Particle structure How do we represent a particle? x v f m Position in phase space position velocity force accumulator mass Single particle solver interface x v f m getDim getState setState derivEval 6 x v v f / m Particle systems In general, we have a particle system consisting of n particles to be managed over time: particles n x1 x2 v v 1 2 f1 f2 m m 1 2 time xn v n fn m n Particle system solver interface For n particles, the solver interface now looks like: particles n time get/setState derivEval getDim 6n x1 v1 v1 f1 m1 x2 v2 v2 f2 m2 xn vn vn fn mn Particle system diff. eq. solver We can solve the evolution of a particle system again using the Euler method: x1i 1 x1i v1i i 1 i i v v f / m 1 1 1 1 Dt i 1 i i x x v n n n i 1 i i vn vn fn / mn Forces • Each particle can experience a force which sends it on its merry way. • Where do these forces come from? Some examples: – Constant (gravity) – Position/time dependent (force fields) – Velocity-dependent (drag) – N-ary (springs) • How do we compute the net force on a particle? Particle systems with forces • Force objects are black boxes that point to the particles they influence and add in their contributions. nf forces n time the particle particles • We can now visualize system with force objects: F1 x1 x2 v v 1 2 f1 f2 m m 1 2 xn v n fn m n F2 Fnf Gravity and viscous drag The force due to gravity is simply: fgrav mG p->f += p->m * F->G Often, we want to slow things down with viscous drag: fdrag kdrag v p->f -= F->k * p->v Damped spring A spring is a simple examples of an “N-ary” force. Recall the equation for the force due to a spring: f kspring ( x r ) [kspring ( x r ) kdampv ] We can augmentfthis with damping: The resulting force equations become: r = rest length x1 p1 v1 x2 p2 v2 derivEval 1. Clear forces • Loop over particles, zero force accumulators 2. Calculate forces • Sum all forces into accumulators 3. Return derivatives x1 x2 v • Loop v over 1 2 f1 0 f2 0 m m 1 2 xn v particles, n fn 0 m n Clear return v and f/mforce 1 accumulators F1 Apply forces to particles v1 v2 f f 1 2 m1 m2 vn f n mn 2 3 F2 x1 x2 v v 1 2 f1 f2 m m 1 2 Return derivatives to solver Fnf F3 xn v n fn m n Bouncing off the walls • Handling collisions is a useful add-on for a particle simulator. • For now, we’ll just consider simple point-plane collisions. N x v P A plane is fully specified by any point P on the plane and its normal N. Collision Detection How do you decide when you’ve made exact contact with the plane? N x v P Normal and tangential velocity To compute the collision response, we need to consider the normal and tangential components of a particle’s velocity. N x P v vT vN v vN (N v)N vT v vN Collision Response vT kresitution vN v’ vT v vN after before The response to collision is then to immediately replace the current velocity with a new velocity: v vT krestitution vN The particle will then move according to this velocity in the next timestep. Collision without contact • In general, we don’t sample moments in time when particles are in exact contact with the surface. • There are a variety of ways to deal with this problem. • The most expensive is backtracking: determine if a collision must have occurred, and then roll back the simulation to the moment of contact. • A simple alternative is to determine if a collision must have occurred in the past, and then pretend that you’re currently in exact Very simple collision response • How do you decide when you’ve had a collision? N v3 x1 v1 x2 P v2 x3 A problem with this approach is that particles will disappear under the surface. We can reduce this problem by essentially offsetting the surface: Also, the response may not be enough to bring a particle to the other side of a wall In that case, detection should include a velocity check: More complicated collision response • Another solution is to modify the update scheme to: – detect the future time and point of collision N x – reflect the particle within the time-step v P Particle frame of reference • Let’s say we had our robot arm example and we wanted to launch particles from its tip. • How would we go about starting the particles from the right place? • First, we have to look at the coordinate systems in the OpenGL pipeline… The OpenGL geometry pipeline Projection and modelview matrices • Any piece of geometry will get transformed by a sequence of matrices before drawing: • p’= Mproject Mview Mmodel p • The first matrix is OpenGL’s GL_PROJECTION matrix. • The second two matrices, taken as a product, are maintained on OpenGL’s GL_MODELVIEW stack: • Mmodelview = Mview Mmodel Robot arm code, revisited • Recall that the code for the robot arm looked something like: • • • • • • • • glRotatef( theta, 0.0, 1.0, 0.0 ); base(h1); glTranslatef( 0.0, h1, 0.0 ); glRotatef( phi, 0.0, 0.0, 1.0 ); upper_arm(h2); glTranslatef( 0.0, h2, 0.0 ); glRotatef( psi, 0.0, 0.0, 1.0 ); lower_arm(h3); • All of the GL calls here modify the modelview matrix. • Note that even before these calls are made, the modelview matrix has been modified by the viewing transformation, Mview. Computing the particle launch point • To find the world coordinate position of the end of the robot arm, you need to follow a series of steps: Mat4f matCam = glGetModelViewMatrix(); • 1. Figure out what Mview is before drawing your model. Mmodel M -1 view Mmodelview Mat4f particleXform = getWorldXform(matCam); 2.Draw your model and add one more transformation to the tip of the robot arm. • glTranslatef( 0.0, h3, 0.0 ); Vec3f particleOrigin = particleXform * Vec3f(0,0,0); • 3. Compute • 4. Transform a point at the origin by the resulting Types of Animation • Easier to render, 3d model, and mocap, physical simulation Timing • Lip sync? Character animation • FK? • IK?