Collision Detection in VR applications

Download Report

Transcript Collision Detection in VR applications

BOIDS
by Craig Reynolds
Cs 527 Computer Animation.
Dr. Robert Kenyon.
Vaidyasubramanian Chandrasekhar
Introduction
“… 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
Flocks
- Exhibits many contrasts
- Made of discrete birds yet overall motion seems fluid
- Randomly arrayed , yet magnificently synchronized
- Intentional centralized control
- Local perception of the world
Basic Features
• Flocking
• Avoid Obstacles
• React to predators
Need 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 tough
Earlier models birds trace along “phase portrait”
•
Force Fields
•
Rejection Forces
•
Object interaction, by bounding box tests.
•
Animator sets initial conditions, orientation and
velocities.
Particle systems
Collection 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
Particle 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.
2.
3.
4.
Position
Color
Age
Size
5.
6.
7.
8.
Velocity (speed and direction)
Lifetime
Shape
Transparency
Particle systems
Major 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.
Boids 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.
Behavioral 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
Geometry in Flight
Each 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.
Geometry 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
Banking
Banking
•
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
Natural Flocks
1. 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.
Behavioral Models
Objects can be
• Static
• Periodic (Flame flickering)
• User controlled- have some
degree of autonomy
• Maps character environment
to character actions.
- If Fuel Low  different
behavior.
Simulated Flocks
1. 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
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.
Collision Avoidance
Velocity matching: steer
towards the average velocity
of local flock mates
Flock centering: Attempt to
stay close to nearby flock
mates.
Collision Avoidance vs. Velocity Matching
• 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
Avoiding 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.
Splitting 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
Arbitrating 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.
Simulated 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.
Simulated 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
Impromptu 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.
Pigeons in Park
Pigeons 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
Dynamic Neighborhood
•Based on speed
of predator speed
varies
•Pigeons try to
move away from
the car.
Spatial Data Structure
•Locality Queries
•Spatial binning
Applications
• Study schools , herds
• Traffic patterns
• Simulate mass behavior
• Mixing and matching
• A traffic jam of spaceships
• Low cost duplication in movies.
Algorithmic 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.
Conclusions
• 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.
Questions?