Post on 18-Jan-2016
Dancing with the Wind
22 March 2006
Graham RhodesApplied Research Associates, Inc.
http://www.ara.com/sed/SED_VisTechnologies.htmhttp://www.gsrhodes.com
Outline Motivation and goals The Wind Coordinate Frame Aerodynamic forces and torques Aerodynamic primitives Computing forces/torques Subtle but important details Game integration Final comments
Personal Motivation for this Talk Prior eye candy
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 YOUDemo #1: business cards
dropped from sky
Goals
Up the ante for realism in simulated worlds
Provide a partial 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 geometry & math of wind dynamics!
The Wind Coordinate Frame (WCF)
A coordinate frame that is attached to a rigid body and is a function of object orientation and the relative wind
We compute all aerodynamic forces and torques in this frame
Origin located at the aerodynamic center
The Relative WindX
Z
Y
Global Frame
= Aerodynamic Center
..caV
windV
Wind Dire
ction
..wrV
.... cawindwr VVV
The Aerodynamic Center Point about which the aerodynamic torque is independent
of the direction of relative wind
Aerodynamic surface loads (pressure + skin friction) are equivalent to a concentrated force at the aerodynamic center + a constant torque The concentrated force varies with relative wind direction …But the torque about the A.C. does not
For complex flows, location is difficult to predict, does not even exist for highly separated flows…
But we can guestimate/approximate intelligently… theoretical placement for a thin airfoil or flat plate… geometric center of a bluff body
Example: Thin Airfoil/Flat Plate
C = Chord length
C/4
Local Pressure – Free-stream Pressure
..wrV
The Wind Coordinate FrameX
Z
Y
Global Frame
..wrV
Xw
The Wind Coordinate FrameX
Z
Y
Global Frame
Xw
Zw
Yw
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
The Wind Coordinate FrameX
Z
Y
Global Frame
Xw
Zw
Yw
zwzwzw
ywywyw
xwxwxw
gw
ZYX
ZYX
ZYX
,,,
,,,
,,,
2R
The Wind-to-GlobalRotational Transformation
The Classic Aerodynamic Forces
Xw
Zw
Yw
Drag
Lift SideForce
The Classic Aerodynamic Torques
Xw
Zw
Yw
RollingMoment
YawingMoment Pitching
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 primitive: drag
and lift
Torques arise as consequence of force, and we will not treat them explicitly
waerowaero LiftLDragD ZX
;
Computing Lift and Drag Formulas are simple algebra A quasi-steady representation 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 Inaccurate for highly deformable shapes
Not appropriate for cloth, in the form presented here
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. Water balloon Crates Buoy Tumbleweeds
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 Volkswagen 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: sphere Aerodynamic Center: center of sphere The Formulas:
Drefwrwr CSVVDrag 2
1....
4.01
624,
eesphereD
RRC
2rSref
r
www.fluidmech.net/jscalc/cdcal26.htm
Parameter: “Reynold’s Number”(Ratio of inertial to viscous fluid forces)
= 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)
refr.w.
e
lVR
Bluff Body Lift – Magnus Force
ωVrlLift wr
..
2 57.1
Primitive shape: cylinder Aerodynamic Center: center of cylinder
Formulas:
..wrV
l = angular velocity (rad/sec)r = radius of cylinderl = length of cylinder
ωVωVZ wrwrw
....
Bluff Body Forces in Games… Wind-blown particles
Drag alone often sufficient (demo) Spinning baseball
Choose 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: rectangular flat plate A. C.: midpoint of quarter-chord line
c
b
..wrV
This is a Top View!
c/4
This is a Side View!
c
..wrV
= sweep angle= angle of attack
e
Xw
Xw
Lifting Surfaces
Zw
eVeVZ wrwrw ˆˆ ....
Lifting Surface Forces Formulas ( in radians)
CDo = parasite drag coefficient (Use 0.045) e = Oswald span efficiency factor (Use 0.8) A = aspect ratio = b/c Sref = bc
Lref CSVLift 2
2
1
2cos2/11
A
A
d
dCL
21LDoD C
AeCC
d
dCC L
L
Dref CSVDrag 2
2
1
..wrVV
(For SMALL )
There are some subtle issues that you should be aware of…
Subtleties in Brief Details, details, grrrrrr. Lift: apply at A.C.;
Drag: apply at geometric center of aero primitive*
Aerodynamic torque Handled automatically by physics engine if lift
applied at proper A.C. Rotational damping
Be careful to include current object rotational velocity when computing kinematic velocity of A.C.
*A hack
Subtleties in Brief Nonlinear lift (!!!)
Gotta have a nonlinear lift model to deal with tumbling
Critical when objects can be aligned arbitrarily with wind
Tuning this is the biggest headache But its important cannot be overstated! See backup slides for more discussion
See backup slides in proceedings for a bit more illustrated detail
*A hack
A Break from The Tedious Stuff
More Demos
Emergence of Gentle Flutter Consider a business card dropped flat in still air…
Tim
e
Leading Edge
Leading Edge
Leading Edge
Etc…LiftDrag
Emergence of Violent Tumbling Consider a business card dropped steeply in still air…
Tim
e
Leading Edge
Leading Edge
Leading Edge
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 But it is expensive to represent wind field for large game level in this way
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 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 Ex: Airplane = slender body + 2 horizontal flat plates + 1 vertical flat
plate
Aero primitives not conveniently located or aligned relative to center-of-mass or local obj. coordinate frame
More transformations to locate A.C. per primitive Multiple Lift/Drag computations per game object Really ought to consider interference effects (downwash/upwash)
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-Game1. Compute wind velocity in global frame2. Determine A.C. location (varies for lifting bodies)3. Compute A.C. velocity in global frame4. Compute relative wind and Xw in global frame5. If computing lift:
1. For bluff bodies, compute Zw using spin axis
2. For lifting bodies, compute Zw using leading edge and quarter-chord line
3. Compute Lift using appropriate formula
ElseLet Lift = 0
6. Compute Drag
Game Integration: For Each Physics Step In-Game7. Compute drag and lift forces in global frame:
8. Apply drag force @ game object center-of-mass
9. Apply lift force @ A.C. for each aero primitive10. Repeat 1-9 for each aerodynamic primitive,
then perform physics integration
waerowaero LiftLDragD ZX
;
Game Integration: Physics Engine Integration Aero forces/torques are computed in the global frame
Lift forces are applied at aerodynamic center
Drag forces are applied at the geometric center of the aerodynamic primitive
Be sure to use correct physics API call, so that torques are computed correctly by the engine
Example for Open Dynamics Engine: dBodyAddForceAtPos(…) vs.
dBodyAddForceAtRelPos(…) dBodyAddTorque(…)
Game Integration: Tuning and Optimization To minimize cost of locating A.C.,
computing Zw and A.C. velocity, etc.: Build visual models such that
aerodynamic primitives can be aligned with local object frame
This way, may incur zero additional storage requirements
Game Integration: Tuning and Optimization Location of aerodynamic center can be
tweaked Zero- 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.
Ignore things like sweep angle to simplify
Final Comments Look for updated slides @ gdconf.com References
Anderson, A. et al., “Unsteady aerodynamics of fluttering and tumbling plates,” to be published in Journal of Fluid Mechanics, submitted May 2005
Hoerner, Sighard, Fluid-Dynamic Drag, Hoerner Fluid Dynamics
Hoerner, Sighard, Fluid-Dynamic Lift, Hoerner Fluid Dynamics
Raymer, Daniel P., Aircraft Design: A Conceptual Approach, AIAA, 1992.
Rhodes, G., “Back-of-the-Envelope Aerodynamics for Game Physics,” Game Programming Gems 5, Charles River Media, February 2005
How to Contact Me grhodes@ara.com 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 naturallyDrag (at geometric center)Lift
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:
is the vector from the center-of-mass to the aerodynamic center, represented in the global frame
...... camcca rωVV
..car
Rotational Damping: Example
Object is plunging without rotating:
Angle of attack is large, resulting in large lift, drag, pitching moment, and rotational acceleration
..caV
windV
..wrV Drag
Lift
Rotational Damping: Example
Object is rotating clockwise about center-of-mass:
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
..caV
windV
..wrV
Drag
Lift
Representing Nonlinear Lift and Stall Lift is approximately linear when a flat
plate/airfoil 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, simulation can be unstable This is VERY important!!!!!
Representing Nonlinear Lift and Stall In real life…lift curve can be bizarre once
it goes nonlinear
0
CL
Aerodynamic hysteresis, post-stall
Abrupt drop due to burst separation bubble
Early nonlinearities are possible (e.g., due to laminar separation bubble)
Representing Nonlinear Lift and Stall There are numerous ways to represent nonlinear lift and
stall One way: simply model CL vs. using a truncated
sinusoidal function… …note that CL should = 0 for >= 90 deg and <= -90
deg
0 (degrees)
CL
45 90
Match the theoretical dCL/d slopeat = 0.
Representing Nonlinear Lift and Stall Problems with sinusoidal representation
FAR from ideal… Max CL occurs at too large an Dropoff after stall may be too slow
Can fixup sinusoidal representation…for a cost Multiply by exponential decay:
CL *= K1* exp(-(1 + (abs()/K2))) But tuning the decay is difficult
Custom function stored in table with interpolation a better
Idea is to drop close to zero soon after stall (15 degrees or so)
Asymptotically reach CL = 0 at = +/- 90 deg, but have enough lift close to 90 to induce flutter
Representing Nonlinear Lift and Stall Er…..even though lift maxes out and
drops back to zero Drag does not. It continues to increase
with . 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 CDwww.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 (see per-slide notes for more)
To make this work in a game, pick the edge that has the smallest sweep angle for each physics step