CS计算机代考程序代写 algorithm Animation and Movie Making

Animation and Movie Making
1

Intended Learning Outcomes
 Distinguish two types of animation
 Describe the four steps of animation
 Describe key frame and intermediate frame generation techniques
 Able to model and program common animation effects such as acceleration, deceleration, and periodic motion
2

Two Types of Animation
 Real time animation
 Update parts of image in real time as soon as
 Frame by frame animation
 Use two frame buffers
 Display first buffer content
 Update on the second buffer
 Switch the two buffers when the new image has finished drawing on the second buffer
 Use in system that does not require real time e.g. movie production
available
3

Comparisons
 Real time animation
 Adv. Critical Information displayed as soon as
available
 Disadv. Refresh rate of each pixel must be at
least 16 frames/sec to avoid flickering
 Used in real time systems e.g. flight simulator, multi-player games
 Frame by frame animation
 Adv. No flickering even if the refresh rate is low  Disadv. Display of information may be delayed up
to one frame
 Used in non-real time systems e.g. movie
4

Designing an Animation
 Story Board
 outline of the action. Defines the motion sequence as a
set of basic events that are to take place
 Object Definitions
 choose the object representation and movement of each
object in the story
 Generation of Key Frames
 generate a detailed image of the scene at a certain time in the animation sequence
 More key frames are specified when the motion is intricate
 Generation of In-between Frames
 Intermediate frames between the key frames.
 The number of in-betweens needed is determined by the media to be used to display the animation.
5

Key frames
From comic “H2”
6

Generation of in-between frames from key frames
 Key frames can be generated by the CG pipeline
 Morphing can be used to generate in-between frames
 Morphing – short form for metamorphosis
 It is a transformation of object shape from one form to another
7

Morphing
 Step 1 : Equalize the number of vertices of the two shapes
 Step 2 : Find correspondence between each pair of vertices
 Step 3 : Find intermediate positions of the vertices by interpolation
8

Algorithm
Input : Key frames k and k+1
Algorithm
1. Let Vk be the number of vertices in key frame k. Compute
2.
Vmax = max(Vk ,Vk +1 ) Vmin = min(Vk ,Vk +1 ) and
Nls =(Vmax −1)mod(Vmin −1)
N p = int(Vmax −1) // int (x) takes the largest integer smaller than x
min
Add Np points to Nls line sections of keyframemin (the key frame with less number of vertices)
Add Np – 1 points to the remaining edges of keyframemin
// now both key frames have equal number of vertices
3.
Output: a set of in-between frames
Linearly interpolate for each pair of corresponding vertices in the two key frames to generate the in-between frames
9

10

11

Simulating Acceleration and Deceleration
 Idea : Adjust the time spacing of successive frames
 n in-between frames for two key frames at t = t1 and t2  Constant velocity
tBj =t1+ j∆t j=1,2,…,n ∆t=t2−t1 n+1
12

Empirical functions
 Acceleration: Use empirical function 1- cos θ π/2
0< θ < tBj=t1+∆t[1−cos jπ ] 2(n+1)  Deceleration: Use sin θ tBj=t1+∆t[sin jπ ] 2(n+1)  Accelerate then decelerate: Use 12 ( 1 − c o s θ ) 0 < θ < π 13 Acceleration 14 Deceleration 15 Acceleration then Deceleration 16 Specifying Motion (1)  For general motions, empirical functions are not accurate enough  Three ways to calculate motion  Direct Motion specification  Solve the motion equations, then just plot the trajectory  Example: simple harmonic motion  Kinematics and dynamics  Kinematics : calculate position, velocity and acceleration 1 2 v=u+at s=s0 +ut+2at 17 Simple harmonic motion 18 Specifying Motion (2)  Inverse Kinematics Specify the initial and final conditions, then the system solves for the motion  Dynamics Specify the forces : Physically based modelling F − kv − h(x − x0 ) = ma  Inverse Dynamics  Goal Directed System  Specify desired behaviour : “Walk”, “Run”  Converted into mathematical motion by the system 19 Periodic Motion  Motion must be synchronized with the frame rate, otherwise may result in incorrect motion  A typical example is shown in the figures below.  Solutions  Generate a frame after each fixed angle increment, but this may cause other problems if the periodic motion is too fast  Use timer and ask user to have a certain minimum graphics capability in their computer (common practice in games)  Periodically reset parameters to prevent numerical error build up 20 21 22 OpenGL Commands  Double Buffering  glutInitDisplayMode (GLUT_DOUBLE)  glutSwapBuffers ( );  To produce an animation  glutIdleFunc (animationFcn)  animationFcn is a procedure written by the user to update the animation parameters  glutPostRedisplay ( );  See example program in pg. 410  Using the timer  glutGet( GLUT_ELAPSED_TIME ) 23 References  Text: Ch. 12 24