Download presentation
Presentation is loading. Please wait.
Published bySophia Potter Modified over 8 years ago
1
Animation Szirmay-Kalos László
2
Animation = time dependence T1(t)T1(t) T2(t)T2(t) TV(t)TV(t) Transformations shape color Optical attributes, etc.
3
Real-time animation and discrete time simulation void IdleFunc( ) { // idle call back static float tend = 0; const float dt = 0.01; // dt is ”infinitesimal” float tstart = tend; tend = glutGet(GLUT_ELAPSED_TIME)/1000.0f; for(float t = tstart; t < tend; t += dt) { float Dt = min(dt, tend – t); for (Object * obj : objects) obj->Control(Dt); for (Object * obj : objects) obj->Animate(Dt); } glutPostRedisplay(); } tstarttend dt
4
Realistic motion Physical laws: – Newton law – Collision detection and response: conservation of linear momentum and angular momentum No deformation of rigid bodies Physiological laws – Skeleton: bones meet in joints of given degrees of freedom – Skin is deformed with bone motion Principle of lazyness
5
Newton law r(t) = r L T M (t) F/m = r = r L d2dt2d2dt2 d2dt2d2dt2 TM(t)TM(t) Force acts via some elastic phenomenon, i.e. changes continously T M (t) C 2 continuous m
6
T M (t): Motion planning Requirement: generally C 2, sometimes (C 1,C 0 ) Matrix elements are not independent – Plan in the space of independent parameters p(t) axis+angle 1 TM=TM= sx sy sz 1 px py pz 1 R r’= r cos( )+w 0 (r w 0 )(1-cos( ))+w 0 r sin( ) 1. scaling:sx, sy, sz 2. orientation:wx, wy, wz, 3. position: px, py, pz
7
Motion definition in parameter space p(t) elements are of C 2, sometimes (C 1,C 0 ) p(t) definition: – splines – With formula: script animation – keyframe animation – With curves: path animation – With forces: physical animation – From measurements: motion capture animation
8
1. key Keyframe animáció 2.key3.key4.key5.key
9
Resulting animation curves
10
Additional spline animation
11
Path animation
12
Transformation in path animation Explicit up vectorFrenet frame: zm = r’(t)zm = r’(t) xm = zm upxm = zm r’’(t) ym = zm xmym = zm xm zm xm ym TM =TM = xm 0 (t) 0 ym 0 (t) 0 zm 0 (t) 0 r(t) 1 Vertical direction is the direction of the force r(t) curve: r(t)r(t) nose: z
13
Physical animation Forces (e.g. gravity, turbulence, etc.) Mass, inertia Linear momentum and angular mumentum Collision detection Collision response – Conservation laws wrong
14
Dynamics of point like objects F(r,v,t) force m for( t = 0; t < T; t += dt) { F = force (r, v) a = F/m v += a ·dt if ( CollisionDetection ) CollisionResponse r += v ·dt } v n = CollisionNormal v’ v’ = [v - n(v·n)]-[n(v·n)·bounce] v ray: r+v ·t intersection: t* If t* < dt Collision CollisionDetection CollisionResponse dr/dt = v dv/dt = F(r,v,t)/m -n(v·n) r v
15
Continuous-Discrete collision detection for a half-space r(ti)r(ti) r(t i+1 ) n · (r - r0) = 0 n · (r - r0) > 0 n · (r - r0) < 0 v sugár: r+v ·t metszés: t* Ha t* < dt Collision
16
Character animation r w = r L ·R hand ·T lowerarm ·R elbow ·T upperarm ·R shoulder ·T spline ·T man rwrw rLrL Homogeneous coordinates
17
Skeleton
18
Walking cycle
19
Transformation hierarchy 22 l1l1 l1l1 11 l1l1 (x,y,z) Translate(l 1, 0, 0); Rotate(theta 2, 0, 0, 1) * Translate(l 1, 0, 0) Translate(l 1, 0, 0) * Rotate(theta 1, 0, 0, 1)
20
Transformation hierarchy l1l1 22 11 l1l1 22 11 Rotate(theta 2, 0, 0, 1) * Translate(l 1, 0, 0) * Rotate(theta 1, 0, 0, 1); Rotate(theta 2, 0, 0, 1) * Translate(l 1, 0, 0) * Rotate(theta 1, 0, 0, 1) * Translate(x0, y0, z0); (x0,y0,z0)
21
PMan T0 = Pman moves ahead Translate(forward, up, 0) T1= shoulder position Translate(leftShoulderPos) T2 = arm swinging Rotate(armAngle, armRotAxis) … T3 = hand position Translate(armLength, 0, 0) T0 T1 T2 Pman HeadTorsoLeg1Leg2ArmArm2 T0 T1, T2 T1
22
Pman drawing and animation class Pman { float armAngle, dArmAngle, forward, up; const … armLength, armRotAxis, rightArmJoint, …; public: void DrawArm(float dt, mat4 M) { M = Rotate(armAngle, armRotAxis) * M; // T2 DrawRefArm(M); } void DrawPman( ) { // set matrices from animation parameters mat4 M = Translate(forward, up, 0); // T0 DrawRefBody(M); DrawArm(dt, Translate(rightArmJoint) * M); // T1 DrawLeg(dt, Translate(rightLegJoint) * M); … } void Animate(float dt) { // calculate animation parameters armAngle += dArmAngle * dt; if (armAngle > 0.5 || armAngle < -0.5) dArmAngle *= -1; forward += 5 * dt; } }; Pman Arm1Arm2Body Push/Pop
23
Inverse kinematics T0 = moves ahead (forward, up) ??? T2 = leg rotation (ang) Leg is not sliding forward += leg * fabs(sin(angNew) - sin(angOld)); up = leg * cos(angNew); leg forward up ang
24
Inverse kinematics l1l1 22 11 l2l2 up( 1, 2 ) = l 1 sin 1 + l 2 sin( 1 + 2 ) forward( 1, 2 ) = l 1 cos 1 + l 2 cos( 1 + 2 )
25
Skinning
26
3. hw: Spiderman in Torus The game is inside a torus that is procedurally textured and diffuse- specular. A textured spherical ball is rolling inside the torus (path animaton), and there are two bouncing light sources. When the ball comes, spiderman should jump into the direction given by a mouse click to avoid collision and death. We see the scene from the point of view of spiderman, who always looks at the direction of the ball. The scene is Phong shaded (per-pixel shading).
27
Torus x y z R r
28
Ball Rolling inside the Torus nn v v + (-n ) = 0 Torus parameter space r(u,v) u v u(t),v(t)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.