2/15/20111Simple Keyframe Animationfor Scientific and Engineering ConceptualizationMike [email protected] – February 15, 2011Oregon State UniversityComputer GraphicsOregon State UniversityThe Problem• Sometimes “visualization” means explaining an idea or a concept or a process to someone• Often, this idea is not data-driven or equation-driven, but rather is general concept-driven•How can we create such an animation without doing a lot of work?mjb – February 15, 2011Oregon State UniversityComputer Graphics•How can we create such an animation without doing a lot of work?Approaches to Animation1. Use the laws of physics2. Use functional (goal-driven) animation3. Use keyframingmjb – February 15, 2011Oregon State UniversityComputer GraphicsKeyframingPixarKeyframing involves creating certain key positions for the objects in the scene, and then later developing the animation frames in between the key frames.In traditional animation, the key frames were developed by the senior animators, and the in-between frames were developed by the junior animators.In our case, you are going to be the senior animator, and the computer will do the in-betweening.mjb – February 15, 2011Oregon State UniversityComputer GraphicsPixarBut, first we need to look into the mathematics of smooth curves . . .Bézier Curves: the Derivation01 0 1(1 )PtP tP P11 1mjb – February 15, 2011Oregon State UniversityComputer GraphicsP0Bézier Curves: the Derivation01 0 112 1 2(1 )(1 )PtP tPPtPtPP11 1mjb – February 15, 2011Oregon State UniversityComputer Graphics12 1 2(1 )PtPtPP0P22/15/20112Bézier Curves: the Derivation01 0 112 1 2(1 )(1 )PtPtPPtPtP P11 11 2 1mjb – February 15, 2011Oregon State UniversityComputer Graphics12 1 222012 01 12 0 1 2(1 )(1 ) (1 ) 2 (1 )PtPtPPtP tP t P t tP tP P0P2Bézier Curves: the Derivation01 0 112 1 2(1 )(1)PtPtPPtP tPP1P31 11 2 1mjb – February 15, 2011Oregon State UniversityComputer Graphics12 1 222012 01 12 0 1 222123 12 23 1 2 3()(1 ) (1 ) 2 (1 )(1) (1) 2(1)PtP tP t P t tP tPPtP tP t P t tP tP P0P2Bézier Curves: the Derivation01 0 112 1 2(1 )(1)PtPtPPtP tP P1P31 11 2 113 31mjb – February 15, 2011Oregon State UniversityComputer Graphics12 1 222012 01 12 0 1 222123 12 23 1 2 3()(1 ) (1 ) 2 (1 )(1) (1) 2(1)PtP tP t P t tP tPPtP tP t P t tP tP 32230123 012 123 0 1 2 3(1) (1) 3(1) 3(1)PtP tP t P t t P t tP tP P0P21 3 3 132230123( ) (1 ) 3 (1 ) 3 (1 )Pt t P t t P t tP tP Bézier Curves: Drawing and Sculptingt = 0., .02, .04, .06, …, .98, 1.0mjb – February 15, 2011Oregon State UniversityComputer Graphics3223( ) (1 ) 3 (1 ) 3 (1 )Pt t P t t P t tP tP The General Form of Cubic Curves23()Pt A Bt Ct Dt In this form, you need to determine 4 quantities (A, B, C, D) in order to use the equation. That means you have to provide 4 pieces of information. In the Bézier curve, this happens by specifying the 4 points.mjb – February 15, 2011Oregon State UniversityComputer Graphics0123( ) (1 ) 3 (1 ) 3 (1 )Pt t P t t P t tP tP00101201233336333APBPPCPPPDPPPP Rearranging gives:Coons (also called Hermite) Cubic CurvesAnother approach to specifying the 4 pieces of information would be to give a start point, an end point, a start slope, and an end slope.P00dPPdt11dPPdt●●mjb – February 15, 2011Oregon State UniversityComputer Graphics000101010133222APBPCPPPPDPPPP 23PABtCt Dt If we do this, then the equation of the curve is:0P1Pwhere:●●●●●2/15/20113Now, Let’s Apply this to the Y Translation of the Keyframe Animationmjb – February 15, 2011Oregon State UniversityComputer GraphicsYThe Y vs. Frame Curve Looks Like Thismjb – February 15, 2011Oregon State UniversityComputer GraphicsFrame #3000 525450 800600200Computing the End Slopes for the Y Translation00001dY dY dFYdt dF dt11011YYdYdF F F20120YYdYdF F FFFdF1dY dY dFYddFd●●mjb – February 15, 2011Oregon State UniversityComputer Graphics000101010133222AYBYCYYYYDYYYY 23YABtCt Dt 1010011. 0.FFdFFFdt11101dtdF dt●●●●●Y650400650650Getting the Two End Slopesmjb – February 15, 2011Oregon State UniversityComputer GraphicsFrame #3000 5254502001iiiidY dY dFdt dF dt111iiiidY dY dFdt dF dtY650400650650Getting the Two End Slopesii-1 i+1 i+2mjb – February 15, 2011Oregon State UniversityComputer GraphicsFrame #3000 5254502001111iiiiiYYdYdF F F212iiiiiYYdYdF F F1iidFdtY650400650650Getting the Two End Slopesii-1 i+1 i+2mjb – February 15, 2011Oregon State UniversityComputer GraphicsFrame #3000 5254502001111650 650450 200iiiiiYYdYdF F F212650 400525 300iiiiiYYdYdF F F111450 300 1501. 0.iiiiiiFFdFFFdt2/15/20114Y650400650650Getting the Two End Slopesmjb – February 15, 2011Oregon State UniversityComputer GraphicsFrame #3000 52545020010150 0250iiiidY dY dFdt dF dt111250150 166.7225iiiidY dY dFdt dF dtDo This Same Thing for the X, Y, and Z Translations and the X, Y, and Z Rotationsmjb – February 15, 2011Oregon State UniversityComputer Graphicsif( AnimationIsOn ){// # msec into the cycle ( 0 - MSEC-1 ):int msec = glutGet( GLUT_ELAPSED_TIME ) % MSEC;// turn that into the current frame number:NowFrame = (int) ( (float)MAXFRAME * (float)msec / (float)MSEC );// look through the keyframes and figure out which two keyframes this is between:Using the System Clock in Animate( ) for Timingmjb – February 15, 2011Oregon State UniversityComputer Graphicsfor( int i = 0; i < maxKeyframes -1; i++ ){if( ????? ){KeyFrameBefore = ?????;KeyFrameAfter = ?????;break;}}// get the t (0.-1.) for that frame in that interval:NowT = ?????// determine the A, B, C, and D for all the interpolation curves in that interval:Ax, Bx, Cx, Dx = ?????Ay, By, Cy, Dy = ?????. . .// use the coefficients and t to
View Full Document