220 likes | 632 Vues
Algorithmic Animation & Particle Systems. Key Frame Animation. Hand-drawn animation was straight-ahead (start at one position, and animate each small movement Computer Animation is usually based on key frames – a frame for the starting position and a frame for the end position.
E N D
Key Frame Animation • Hand-drawn animation was straight-ahead (start at one position, and animate each small movement • Computer Animation is usually based on key frames – a frame for the starting position and a frame for the end position
Key Frame Animation • How do you calculate the frame positions in between key frames? • Interpolation: Approximation of a function between two known points
Why interpolation? • Attributes (position, size, color) change as a function over time • Function often given by physics f = ma • Why approximate a known function? • Solving function at certain point requires solving differential equations
Interpolation • Idea: Don’t want to solve equation at each point • Approximate some points and connect them with • Lines • Arcs • Other functions (trig)
Euler Integration • Use first derivative to get the direction of the curve at a point. • Draw lines in direction of first derivative • Accuracy depends on the frequency with which you re-evaluate the derivative
Linear Interpolation • Use a line to connect 2 way points • In C#: • Mathf.Lerp(from, to, percent) • Vector3.Lerp • Quaternion.Lerp • Color.Lerp
Example – Moving between way points private Vector3 start; private Vector3 end; private float startTime; private float speed; void Start() { startTime = Time.time; } void Update() { float journeyLength = Vector3.Distance(start, end); float distCovered = (Time.time - startTime)* speed; float fracJourney = distCovered / journeyLength; transform.position = Vector3.Lerp(start, end, fracJourney); }
More on Approximation • Collision Detection: • Can’t always calculate every collision • Isolate groups of things that may collide • Approximate the result
Example: Springs • Hooke’s law: • f = – kx • k is “springiness” constant • x is extension • Also know f = ma • Spring forces acton other elements(&other springs)
Particle Systems • Create one simple object • Objects follow rules of behavior • Many instances of the simple object create an interesting overall effect
Examples: • Small spheres • Fireworks • Waterfalls
Particle Systems: • Springs • Hair • Cloth
Distributed Computation • De-centralized control • Aggregate behavior emerges • Simple rules for the individual lead to complex behavior for the group • Often very natural-looking
Distributed ComputationExamples • Braitenberg Vehicles • Light lover • Light fear • Aggression • Traffic Patterns
Distributed Computation Examples • Boids: three rules • Separation • Alignment • Cohesion
Distributed ComputationExamples • Fish • Virtual Fishtank • Xiaoyuan Tu
Artificial Life • Ants • Know “home” • Look for food • If they find food source, pick it up and head home • Drop pheromones – chemicals “smelled” by antennae • Result: All food gets taken home
Artificial Life • Termites • Rules • If you reach food and don’t have any, pick some up • If you reach food and have some already, put it down • Move randomly • Result: food in one place
Artificial Life • Creatures • Random joints with degrees of freedom • Try to move • Learn to move from one place to the other