boids by craig reynolds cs 527 computer animation. dr. robert kenyon. vaidyasubramanian...

33
BOIDS BOIDS by by Craig Reynolds Craig Reynolds Cs 527 Computer Animation. Cs 527 Computer Animation. Dr. Robert Kenyon. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Upload: whitney-daniels

Post on 16-Dec-2015

217 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

BOIDS BOIDS byby Craig Reynolds Craig Reynolds

Cs 527 Computer Animation.Cs 527 Computer Animation.Dr. Robert Kenyon.Dr. Robert Kenyon.

Vaidyasubramanian ChandrasekharVaidyasubramanian Chandrasekhar

Page 2: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

IntroductionIntroduction“… and the thousands off fishes moved as a huge beast , piercing the water. They appeared united, inexorably bound to a common fate. How comes this unity?.. “

-Anonymous.

BOIDS

- explores an approach based on simulation as an alternative to scripting the paths of each bird individually

Page 3: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

FlocksFlocks

- Exhibits many contrasts

- Made of discrete birds yet overall motion seems fluid

- Randomly arrayed , yet magnificently synchronized

- Intentional centralized control

- Local perception of the worldBasic Features

• Flocking

• Avoid Obstacles

• React to predators

Page 4: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Need for BoidsNeed for Boids• Scripting of the path of various objects using traditional computer animation techniques is tedious.

• The editing of the model for small changes is hard

• The maintenance of the model is also toughEarlier models birds trace along “phase portrait”

• Force Fields

• Rejection Forces

• Object interaction, by bounding box tests.

• Animator sets initial conditions, orientation and velocities.

Page 5: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Particle systemsParticle systemsCollection of large number of individual particles each having own behavior. - "sub object system,"

The boids model similar to particle systems.

Partical system -1

Partical system -2

Page 6: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Particle systemsParticle systems• Used to describe a method used to create a sequence of images for the movie Star Trek II: The Wrath of Khan.

• The effect was that of a bomb exploding on the surface of a planet and fire spreading out from

the point of impact to eventually engulf the planet.

Each Particle has the following

1. Position 5. Velocity (speed and direction)

2. Color 6. Lifetime3. Age 7. Shape4. Size 8. Transparency

Page 7: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Particle systemsParticle systemsMajor differences

• Each boid is an entire polygonal object rather than a graphical primitive

• Each boid has a local coordinate system.

• There are a fixed number of boids - they are not created or destroyed.

• Traditional rendering methods can be used because there are a small number of boids.

• Boids behavior is dependent on external as well as internal state. In other words, a boid reacts to what other boids are doing around it.

Page 8: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Boids ApproachBoids Approach

Approach

• Behavior depicted as rules in the program

• All models are actors, that communicate with peers by passing messages.

• Internal state of each boid must be held in some sort of data structure

• Robust self- organizing distributed systems.

Page 9: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Behavioral AnimationBehavioral Animation

-Traditional Cel Animation vs. Computer Animation

- Story told by motion of characters

-Interpolate between specified key frames

-Cannot tell ‘act happy’- has to be done in expressions

-The Charming aspect is that one cannot know how the simulation is going to proceed from the initial conditions

Page 10: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Geometry in FlightGeometry in FlightEach boid has its own local coordinate system

• X axis is left/right • Y axis is up/down • Z axis is ahead/back • rotation about X is pitch • rotation about Y is yaw • rotation about Z is roll

Boids move along their local positive Z axis. Pitching and yawing realign the global orientation of the local Z axis.

Page 11: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Geometry in FlightGeometry in Flight

• Momentum is conserved• Viscous speed damping to give a maximum speed, a specified maximum acceleration.• Gravity only used for banking- not very realistic for birds flying a lot• Buoyancy is aligned against gravity, but aerodynamic lift is aligned with the boid's local "up" direction and related to velocity • Steering-> directing thrust in appropriate direction

Page 12: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

BankingBanking

Page 13: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

BankingBanking• Limiting case – Y points at center of curvature

• Banking behavior in the absence of gravity.

Banking Uses.

• Keeps lift from the airfoil of the wings pointed in the most efficient direction.

• Simply reversing the angle bank we obtain a cartoon motion – like objects flung outward

Page 14: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Natural FlocksNatural Flocks1. Natures 2 opposing Forces

a. Stay closer to flock

• Protection from predators

• Easy availability and detection of food

b. Avoid collisions with peers.

2. Flocks do not become Full or overloaded as new birds join in.

3. Individual bird has localized and filtered perception of the rest of the flock.

Page 15: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Behavioral ModelsBehavioral ModelsObjects can be

• Static

• Periodic (Flame flickering)

• User controlled- have some degree of autonomy

• Maps character environment to character actions.

- If Fuel Low different behavior.

Page 16: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Simulated FlocksSimulated Flocks1. Start with a boid model supporting geometric flight.

2. Add behaviors that correspond to the opposing forces of collision avoidance and urge to join the block.

The Rules are stated as

a. Collision avoidance

b. Velocity Matching

c. Flock Centering

Page 17: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Collision Avoidance Collision Avoidance

The Neighborhood is usually around 3-4 birds.

The metrics are

a. Distance between birds

b. Offset Vector.

Collision Avoidance

Avoid collisions with nearby flock mates.

Page 18: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Collision Avoidance Collision Avoidance

Velocity matching: steer towards the average velocity of local flock mates

Flock centering: Attempt to stay close to nearby flock mates.

Page 19: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Collision Avoidance vs. Velocity Collision Avoidance vs. Velocity MatchingMatching

• Collision avoidance based on the Position and ignores the velocity.

• Velocity matching based on speed and ignores the position.

• Center of flock means center of the nearby flock mates.

• If deep inside a flock, flock centering urge is small

Page 20: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Avoiding ObstaclesAvoiding Obstacles

• Increases complexity

• Force Field Model.

• Easy to model

• Exactly opposite- No turning away.

• Too weak far away. (long term planning required).

• Steer – to –Avoid

• Only obstacles directly in front of it.

• Calculates for one body length beyond the silhouette edge.

Page 21: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Splitting and RejoiningSplitting and Rejoining

• Boids split to go around the obstacles.

• Central Force Model.

• Follow designated leader model

• If individual boid stays close to neighbors it doesn’t care if other boids stay or fly away. ( this helps in splitting)

• Flock centering urge not localized Long Range vision to get back after splits.

No splits allowed

Page 22: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Arbitrating DecisionsArbitrating Decisions

• Combine, prioritize and arbitrate between potentially conflicting urges.

• Taking weighted average - easiest way

• Easy implementation.

• Fails in crucial situations

• In critical situation conflicts must be resolved in a timely manner.

• Prioritized acceleration is based on strict ordering of all component behaviors.

• Acceleration accumulated till it exceeds the max value.

Page 23: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Simulated PerceptionSimulated Perception

• Boids model does not directly simulate the senses used by real animals during flocking.

• Simulated boids have access to all other boid’s data unlike real flocks. Even lesser in herds as 2-D

• Fish schools visual perception limited by scattering and absorption of light by the murky water.

• Wrong to give all details – even dangerous.

• Aggregate behavior like flocking depends only on localized view.

• Neighborhood is a spherical zone of sensitivity centered at a boid’s local origin.

Page 24: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Simulated PerceptionSimulated Perception

• Forward weighted sensitivity zone – to avoid accidents at high speed.

• Attraction, Repulsion by distance Spring like action ,more suited for cartoons.

• A boid is more influenced by the close neighbors than by the distant ones.

• Boid with vision- Far better. E.g.: in cases like with mazes

Page 25: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Impromptu flockingImpromptu flocking

• The initial position, heading, velocity, and various other parameters of the boid model are initialized to values randomized within specified distributions

• First action is a reaction to the initial conditions

• Scripting done to have more control rather than aimless wandering.

• Script to set up and animate backgrounds, lighting, camera and other visible objects.

• Urge - Some global target. – sets global position, direction vector.

Page 26: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Pigeons in ParkPigeons in Park

Page 27: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Pigeons in ParkPigeons in Park

• Moving car worries birds panic and Fly

• Annoyance value.

• Panic is contagious

• Objects

•Pigeons

•Car

•Spherical Object

•Terrain

• Initially Small distance moved, next annoyance . More motion

Page 28: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Dynamic NeighborhoodDynamic Neighborhood

•Based on speed of predator speed varies

•Pigeons try to move away from the car.

Page 29: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Spatial Data StructureSpatial Data Structure

•Locality Queries

•Spatial binning

Page 30: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

ApplicationsApplications

• Study schools , herds

• Traffic patterns

• Simulate mass behavior

• Mixing and matching

• A traffic jam of spaceships

• Low cost duplication in movies.

Page 31: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Algorithmic considerationAlgorithmic consideration

• O(n^2). Since decision has to be made for all boids.

• But , based on neighborhood – O(k.n) or O(n).

• Space partitioning into bins based on position

• Incremental collision detection.

Performance• A flock of 80 boids, O(N2) algorithm , on a

single Lisp Machine without any special hardware accelerators, the simulation ran for about 95 seconds per frame.

Page 32: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

ConclusionsConclusions

• A Model of polarized, non-colliding aggregate motion

• Difficult to objectively measure and rate the simulation

• Current development.

• Internal animation, sync.

• Interaction between simulation and script based flocks

• More interesting will be taking into account – hunger, predators, need to sleep and so on.

Page 33: BOIDS by Craig Reynolds Cs 527 Computer Animation. Dr. Robert Kenyon. Vaidyasubramanian Chandrasekhar Vaidyasubramanian Chandrasekhar

Questions?Questions?