Applied Research Associates, Inc.
Download
Report
Transcript Applied Research Associates, Inc.
(Draft 2 – 5 March 2006)
Dancing with the Wind
22 March 2006
Graham Rhodes
Applied Research Associates, Inc.
http://www.ara.com/sed/SED_VisTechnologies.htm
http://www.gsrhodes.com
Outline
Motivation and Goals
The Wind Coordinate Frame
Aerodynamic Forces and Torques
Aerodynamic Primitives
Computing Forces/Torques
Subtle But Important Details (in brief)
Game Integration
Final Comments
Personal Motivation for this Talk
Prior Eye Candy (some examples)
Soul Calibur on Dreamcast
Black & White
Stranger’s Wrath on XBox
Technology in Emerging Games
Increased use of physics middleware/PPU
Escalation of flora (Speedtree, NatFX)
Trends in procedural environment generation
(Mojoworld, Spore)
Motivation for YOU
Demo #1: TBD – stack of paper
dropped from sky or leaves
fluttering in wind
Goals
Up the ante for realism in simulated worlds
Provide toolbox for wind-driven dynamics
simulation in games
Encourage use of simulation to produce
emergent animation, wherever possible
Physics in Games: What’s Missing?
Tumbling/Colliding Objects are Nice, but…
Game worlds can look dead except when player is
blowing things up
The addition of wind effects can make game
worlds appear more alive
Wind effects in games to date have been
simplistic, but more realistic wind dynamics are
easily simulated
Wind Dynamics for Games
Fluid drag is all well and good, but….
No rotational or tumbling effects
Can’t simulate the gentle oscillation or flutter of paper or
leaves
Can’t simulate objects being flipped by wake of passing fighter
jet
For realism we need:
Lifting forces + aerodynamic torques
Representation of “stall”
Rotational damping
Lets jump into the math &
geometry of wind dynamics!
The Wind Coordinate Frame (WCF)
All Aerodynamic Forces/Torques are Computed
in this Frame
Orientation is a function of object orientation and
the relative wind
Origin is the Aerodynamic Center, dependent on
shape of object
Z
The Relative Wind
Y
X
Global Frame
Va.c.
Vwind
Vr .w.
Vr .w. Vwind Va.c.
= Aerodynamic Center
Z
The Wind Coordinate Frame
Y
X
Global Frame
Xw
Vr .w.
Z
The Wind Coordinate Frame
Y
X
Global Frame
Zw
Yw
Xw
The Wind Coordinate Frame (WCF)
By definition, Xw is aligned with relative wind
By definition, Zw is perpendicular to relative wind
Zw and Yw depend on object orientation
Actual determination of Zw and Yw is shape
dependent…
…More later on this
Z
The Wind Coordinate Frame
The Wind-to-Global
Rotational Transformation
R w2 g
X w, x
X w, y
X w, z
Yw, x
Yw, y
Yw, z
Z w, x
Z w, y
Z w, z
Y
X
Global Frame
Zw
Yw
Xw
The Classic Aerodynamic Forces
Lift
Side
Force
Zw
Yw
Drag
Xw
The Classic Aerodynamic Torques
Yawing
Moment
Pitching
Moment
Zw
Yw
Xw
Rolling
Moment
Generalized Aerodynamic
Forces and Torques
Keep track of 3 forces and 3 moments??
No way, too tedious
We can treat them in a generalized way
Two force components per object: drag and lift
Faero Drag Xw Lift Zw
Torques arise as consequence of force, and we
will not treat them explicitly
Computing Lift and Drag
Formulas are simple algebra
Produce compelling animation, but…
Very approximate
Subsonic flow only
Technically, developed for static objects in a steady
wind or no wind
Don’t explicitly treat object-object interactions or
interference
Not too accurate for rapid, spastic motion such as
plunging
Not too accurate for highly deformable shapes
Aerodynamic Primitives
Simple shapes that approximate game
objects
Used to compute aerodynamic forces
Analogous to Collision Bounding
Volumes
Three types
Bluff bodies
Lifting bodies
Slender bodies
Bluff Bodies
Blobby shapes that are not very streamlined
Generate lots of parasite, or pressure drag
Can generate a little bit of lift
Game Examples:
Baseball, football, soccer ball, etc.
Hot air balloon, water balloon
Crates
Buoy
Tumbleweeds
Tree trunk, flag pole
Lifting Bodies
Shapes that are thin or streamlined, but that
have large surface area along one axis
Think “thin flat plank” or “airplane-wing-like”
Generate lots of lift, but little drag, when
approximately aligned with the wind
Game Examples:
Airplane wings, frisbee/flying disc
Boat sail
Tree leaves (free fluttering or attached to tree)
Mattress tied to the top of volkswagon on Autobahn
Slender Bodies
Shapes that are thin and streamlined, but that
do not have large surface area along any axis
Think missile/rocket shaped
Generate less drag than bluff bodies, and only a
small amount of lift
Not enough time to discuss,
Bluff Body Drag
Primitive Shape: The Sphere
Aerodynamic Center Location: Center of Sphere
The Formulas:
1
Drag Vr .w. Vr .w. S ref CD
2
24
6
CD , sphere
0.4
Re 1 Re
Sref r 2
www.fluidmech.net/jscalc/cdcal26.htm
r
Parameter: “Reynold’s Number”
Re
Vr.w. lref
= Fluid density
1.225 kg/m3 for air at sea level
1000 kg/m3 for water at 20°C
= Fluid dynamic viscosity
1.789 x 10-5 Newton-seconds/m2 for air
1.0 x 10-3 Newton-seconds/m2 for water
lref
= a reference length, in meters (use radius for sphere)
Bluff Body Lift – Magnus Force
Primitive Shape: The flat-capped Cylinder
Aerodynamic Center Location: Centroid of Cylinder
Formulas:
Lift 1.57 l r Vr .w. ω
2
Vr .w.
Z w Vr .w. ω Vr .w. ω
= angular velocity (rad/sec)
r = radius of cylinder
l = length of cylinder
l
Bluff Body Forces in Games…
Wind-blown
Drag
particles
alone often sufficient
Spinning
Choose
Baseball
a bounding cylinder
Align with spin axis
Compute bluff body drag and lift
For spinning ball, bluff body lift
approximates the “Magnus Force”
Lifting Surfaces
Primitive Shape: The rectangular flat plate
A. C. Location: Midpoint of Quarter-Chord Line
Vr .w.
L= sweep angle
a = angle of attack
L
c/4
c
c
a
Vr .w.
b
This is a Top View!
This is a Side View!
Lifting Surfaces
Zw
ê
Xw
Z w Vr .w. eˆ Vr .w. eˆ
Xw
Lifting Surface Forces
Formulas (a in radians)
Lift
1
V 2 S ref C L
2
Drag
1
V 2 S ref C D
2
dCL
CL a
da
1 2
C D C Do
CL
Ae
dCL
A
da 1 1 A / 2 cos L 2
V Vr .w.
CDo = parasite drag coefficient (Use 0.045)
e = Oswald Span Efficiency Factor (Use 0.8)
A = aspect ratio = b/c
Sref = bc
There are some subtle issues
that you should be aware of…
Subtleties in Brief
Details, details, grrrrrr.
Aerodynamic Torque
Rotational Damping
Be careful to include current object rotational velocity
when computing kinematic velocity of A.C.
Nonlinear Lift
Handled automatically by physics engine if force
applied at proper A.C.
Critical when objects can be aligned arbitrarily with
wind
See backup slides in proceedings for a bit more
illustrated detail
A Break from The Tedious Stuff
More Demos: Interactive Wind
Emergence of Gentle Flutter
Consider a Business Card Dropped Flat in Still Air…
Leading Edge
Leading Edge
Leading Edge
Time
Etc…
Emergence of Violent Tumbling
Consider a Business Card Dropped Steeply in Still Air…
Leading Edge
Leading Edge
Leading Edge
Time
Leading Edge
Representation of the Wind
Unfortunately, not enough time to go into this in detail
One possibility is to use another fluid simulation to predict wind
Simple examples that are easy to implement:
No wind at all
Uniform/steady wind
Occasional periodic breeze
Slightly fancy example: Wingtip vortices from fighter jet
But it is expensive to represent wind field for large game level in this
way
A simplistic model is to use a potential vortex with its axis aligned
parallel to the wingtips
See Tornado example in my Game Programming Gems 5 chapter
for brief introduction to use of potential vortex in games
See me after class if interested…
Game Integration: Simple Objects
One Aero Primitive per Game Object
This should be your goal, since there’s far less
book-keeping
Less data, faster computation
Minimizing Storage + Computation
Align Aero Primitive Shape with Geometry
Align Local Obj. Coordinates with aero primitive
Its really nice if center-of-mass happens to lie at center
of aero primitive
At most need per-object aero primitive dimensions
For uniform particles, zero extra data per particle
Game Integration: Compound
Objects
Multiple Aero Primitives per Game Object
Compound objects are complex shapes
Aero primitives not conveniently located or aligned relative
to center-of-mass or local obj. coordinate frame
More transformations to locate A.C. in obj space and compute
A.C. kinematic velocity in world space
For example, using these techniques to model a glider or
simple airplane
Minimizing Storage + Computation
….much harder to do
At least try to align aero primitives with local obj coordinate
system
Game Integration: For Each
Physics Step In-Game
1.
2.
3.
4.
5.
Compute wind velocity in global frame
Compute A.C. velocity in global frame
Compute relative wind and Xw in global frame
Compute Drag
If computing lift:
1.
2.
3.
For bluff bodies, compute Zw using spin axis
For lifting bodies, compute Zw using leading edge
and quarter-chord line
Compute Lift using appropriate formula
Else
Let Lift = 0
Game Integration: For Each
Physics Step In-Game
6.
Compute total aero force in global frame:
Faero Drag Xw Lift Zw
7.
8.
Apply global force to body at object local frame
aerodynamic center
Repeat 1-7 for each aerodynamic primitive,
then perform physics integration
Game Integration: Physics
Engine Integration
Aero forces/torques are computed in the global
frame
Aero forces are applied at aerodynamic center,
defined in local frame of object
Be sure to use correct physics API call, so that
torques are computed correctly by the engine
Example for Open Dynamics Engine:
dBodyAddForceAtRelPos(…)
dBodyAddTorque(…)
Game Integration: Tuning and
Optimization
To minimize cost of computing Zw and
aerodynamic center velocity:
Build visual models such that aerodynamic
primitives can be aligned with local object
frame
Game Integration: Tuning and
Optimization
Location of aerodynamic center can be
tweaked
Zero-a lift curve slope can be tweaked
Many things can be precomputed and
cached
Lift curve slopes
Reynold’s #’s/CD’s (as an approximation)
Etc.
Final Comments
References
“Back-of-the-Envelope Aerodynamics for
Game Physics,” Game Programming Gems
5, February 2005
“Real-time Game Physics,” Introduction to
Game Development, June 2005
How to Contact Me
[email protected]
Math & Physics forum @ www.gamedev.net
Backup Slides
Origin of Aerodynamic Torque
Aerodynamic torques arise when lift/drag
applied away from center-of-mass
If you apply the aero forces at the correct
body location via a physics engine API
call, the aero torques will be generated
naturally
Lift
Drag
Resulting Torque
Rotational Damping
It is necessary to deal with rotational
aerodynamic damping for realism and
simulation stability
Fortunately, this is handled in an intuitive and
physically-meaningful manner:
Va.c. Vc.m. ω ra.c.
ra .c. is the vector from the center-of-mass to the
aerodynamic center, represented in the global
frame
Rotational Damping: Example
Object is plunging without rotating:
Lift
Vwind
Va.c.
Drag
Vr .w.
Angle of attack is large, resulting in large lift,
drag, pitching moment, and rotational
acceleration
Rotational Damping: Example
Object is rotating clockwise about center-of-mass:
Vwind
Vr .w.
Va.c.
Lift
Drag
Smaller angle of attack generates less lift, less drag
Smaller resulting pitching moment yields slower pitch acceleration
If rotation is very fast….pitching moment can be reversed
Representing Nonlinear Lift
and Stall
Lift is approximately linear when a flat plate is
nearly parallel to the relative wind
Becomes nonlinear when it is more than about 10 degrees
from parallel
Maximum lift occurs around 15 degrees, plus-or-minus,
depending on the actual object shape, dimensions,
Reynold’s #
Lift is essentially zero when flat plate is perpendicular to
relative wind
For games, we must represent the nonlinear
behavior of lift
Otherwise, objects can go haywire
Representing Nonlinear Lift
and Stall
There is a quite easy way to represent nonlinear
lift and stall
Simply model CL vs. a using a sinusoidal
function:
Match the theoretical dCL/da slope
CL
at f(a = 0.
0
45
90
f(0) = 0, f(15) = 45, f(90) = 90
fa (degrees)
Representing Nonlinear Lift
and Stall
Er…..even though lift maxes out and drops
back to zero
Drag does not. It continues to increase with a.
Simple way to deal with this: treat lifting body as
a bluff body when lift goes to zero
Use bluff body drag calculator to find a CD
www.fluidmech.net/jscalc/cdcal26.htm
Lifting Surfaces: Which edge is the
leading edge?
Without really going into it…the equations
presented here break down for severe sweep
angles
To make this work in a game, pick the edge that
has the smallest sweep angle for each physics
step