Behavioral animation
-
Upload
hyatt-dotson -
Category
Documents
-
view
39 -
download
1
description
Transcript of Behavioral animation
![Page 1: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/1.jpg)
Behavioral animation
CSE 3541Matt Boggus
![Page 2: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/2.jpg)
Material recap and trajectory
• Geometric– Artist specifies translation and rotation over time
• Physically based– Artist specifies forces acting on objects– Motion equations dictate movement
• Behavioral– Artist directs autonomous agents
• Interpolation– Artist draws the scene at the beginning and end of a an
interval of time– Intermediate positions are calculated
![Page 3: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/3.jpg)
Behavioral Animation
• Control the motion of one or more objects using virtual actors
• Goal: realistic or believable motion so that the object appears to be autonomous
• Matt Lewis’ page on BA http://accad.osu.edu/~mlewis/Class/behavior.html
![Page 4: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/4.jpg)
Behavioral animation
• Character or object motion based on:
– Knowledge of the environment– Aggregate behavior– Primitive behavior– Intelligent behavior– Crowd management
![Page 5: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/5.jpg)
Actor properties (position only)
Position (x, y)
Goal (xg, yg)
V = Goal - Position
Next Position = Position + V * dt
![Page 6: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/6.jpg)
Actor properties (position and orientation)
Position (x, y)
Goal (xg, yg)
Vtarget = Goal - Position
Orientation (ox, oy) = transform.forward
Rotate(θ)
In Unity, you can use RotateTowards()
Rotate(-θ)Determine which rotation (±θ) orients the actor closer to the goal using dot product
![Page 7: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/7.jpg)
Sample codeclass OrientedAgent2D {
// DataVector3 position;GameObject model; // Use this for geometry and orientation
// MethodsUpdate(float deltaTime);TurnLeft();TurnRight();MoveForward();MoveBackward();
};
![Page 8: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/8.jpg)
Knowing the environment
•Vision and other senses– Information available now
•Memory– Information stored from the past
![Page 9: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/9.jpg)
Vision
•General vision– What can the actor see? – What is everything in sight now?•Targeted vision– Can the actor see object X?
• Computation vs. accuracy– How much of an object needs to be seen to be
identified?– Do we need to model visual perception?
![Page 10: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/10.jpg)
Omniscience
Everything in the scene is known
![Page 11: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/11.jpg)
Field of view
![Page 12: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/12.jpg)
Field of view – example
Orientation Vector (O)
Vector from agent to vertex (V)
Inside the cone when the angle between O and V is less then or equal to θ/2
Angle of cone = θ
![Page 13: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/13.jpg)
Field of view – sample code
Vector3 agentPosition, orientation, objectPosition;float visionLimit;
Vector3 agentToVertex = objectPosition – agentPosition;
agentToVertex.Normalize();if(Vector3.Dot(agentToVertex,orientation) > visionLimit)
// agent can see object
![Page 14: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/14.jpg)
Occluded Vision
Ray casting with collision detectionSample the environment
![Page 15: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/15.jpg)
Target-testing vision (per object)
Can the actor see X?Cast a ray
How well can the actor see X?Use multiple rays
![Page 16: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/16.jpg)
Target-testing vision (alternative)Sample the vision cone
Cast multiple rays
![Page 17: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/17.jpg)
Lab4 – predator-prey simulation
•Unbalanced abilities– Vision
• Distance• Field of view
– Linear speed (moving forward)– Angular or rotational speed (turning)
![Page 18: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/18.jpg)
Spatial Occupancy
![Page 19: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/19.jpg)
Other senses
•Hearing•Smell
•Sensors & signal propagation•Spatial occupancy approach•Applications
![Page 20: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/20.jpg)
Memory
•What is recorded about the environment
•Spatial occupancy
•Transience of objects: time-stamps
•Memory hierarchy: short-term, long-term
![Page 21: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/21.jpg)
Spatial Occupancy
doorway
doorway
transiency
wal
l
![Page 22: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/22.jpg)
Aggregate Behavior:Emergent Behavior
Type Elements Physics
Env/Others
Intelligence
Particles 102-104 Much/none None
Flocking 101-103 Some/some Limited
Crowds 101-102 Little/much Little-much
Typical qualities
![Page 23: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/23.jpg)
Emergent behavior
• Complex systems and patterns arising out of simple rules
• Aints – AI ants http://www.youtube.com/watch?v=rsqsZCH36Hk
![Page 24: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/24.jpg)
Predator Prey vision anatomy
![Page 25: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/25.jpg)
Prey-Predator (vision)
![Page 26: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/26.jpg)
Prey-Predator (movement – speed and turning)
![Page 27: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/27.jpg)
Motion – force based
Apply a force on the predator towards the prey when in view
Force = c * posprey - pospred
![Page 28: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/28.jpg)
Motion – kinematic based
Determine the closest prey in view then turn towards it and increase forward velocity
voldvnew
![Page 29: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/29.jpg)
Prey-Predator – environment forces
Using pure forcesMay not prevent object penetrationPrey can be ‘hidden’ by environmental repulsive forces
![Page 30: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/30.jpg)
Flocking, Swarming, Flying
Boidshttp://www.red3d.com/cwr/boids/
![Page 31: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/31.jpg)
Local control
Rules defined to stay with friends, but avoid bumping into each other
Need additional rules for collision avoidance with obstacles
![Page 32: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/32.jpg)
Local information
![Page 33: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/33.jpg)
Other flocking issues•Global control– script flock leader– global migratory urge
•Negotiating the motion– Separation, alignment, and cohesion may compete/contradict
•Collision avoidance– Once an object is in sight, start steering to avoid
•Splitting and rejoining (difficult)– Collision avoidance too strong – flock may never rejoin after split– Flock membership too strong – flock does not split and formation changes
•Modeling flight
![Page 34: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/34.jpg)
Negotiating the motion
ForcesOr “Reasoning”(e.g. rule-based)
![Page 35: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/35.jpg)
Navigating obstacles
Problems with repulsive forces
![Page 36: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/36.jpg)
Navigating using bounding sphere
![Page 37: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/37.jpg)
NavigatingTesting for being on a collision path with
(bounding) sphere
rt
kst
PCs
V
VPCk
22
)(
Given: P, V, C, r
![Page 38: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/38.jpg)
Finding closest non-colliding point
sWUtPCPB
UVU
UVUW
PC
PCU
trs
PC
PCrkt
ttPCPCtrk
tPCsk
tsr
rPCk
)(
2
2
)(
22
222
22222
222
222
22
Calculate s,t
![Page 39: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/39.jpg)
Modeling flight – common in flocking
![Page 40: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/40.jpg)
Modeling flight
Geometric flight – dynamic, incremental rigid transformation of an object moving along a tangent to a three dimensional curve
![Page 41: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/41.jpg)
Modeling Flight – Lift
Air passing above wing most travel longer than air below it. Less pressure above wing = lift
![Page 42: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/42.jpg)
Modeling Flight – turn by rolling
![Page 43: Behavioral animation](https://reader036.fdocuments.us/reader036/viewer/2022062309/5681386c550346895da01e0e/html5/thumbnails/43.jpg)
Modeling Flight – summary
• Turning is effected by horizontal lift
• Increasing pitch increases drag
• Increasing speed increases lift