S1560i2 - dexsummerresearch

Download Report

Transcript S1560i2 - dexsummerresearch

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
 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 YOU
Demo #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
Z
The Relative Wind
Y
X
Global Frame

Va.c.

Vwind

Vr .w.



Vr .w.  Vwind  Va.c.
= Aerodynamic Center
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/4

Vr .w.
C = Chord length
Local Pressure – Free-stream Pressure
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 primitive: drag and lift




Daero  Drag  Xw ; Laero  Lift  Zw

Torques arise as consequence of force, and we
will not treat them explicitly
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:



1 
Drag   Vr .w. Vr .w. S ref C D
2
24
6
CD , sphere 

 0.4
Re 1  Re
Sref  r 2
www.fluidmech.net/jscalc/cdcal26.htm
r
Parameter: “Reynold’s Number”
(Ratio of inertial to viscous fluid forces)
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: cylinder
Aerodynamic Center: center 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 (demo)
 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: rectangular flat plate
A. C.: 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
dC L
CL  a
(For SMALL 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.
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…
Leading Edge
Leading Edge
Leading Edge
Time
Etc…
Lift
Drag
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


Aero primitives not conveniently located or aligned relative
to center-of-mass or local obj. coordinate frame




Ex: Airplane = slender body + 2 horizontal flat plates + 1 vertical flat
plate
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-Game
1.
2.
3.
4.
5.
Compute wind velocity in global frame
Determine A.C. location (varies for lifting bodies)
Compute A.C. velocity in global frame
Compute relative wind and Xw in global frame
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
6.
Compute Drag
Game Integration: For Each
Physics Step In-Game
7.
Compute drag and lift forces in global frame:




Daero  Drag  Xw ; Laero  Lift  Zw
8.
9.
10.
Apply drag force @ game object center-ofmass
Apply lift force @ A.C. for each aero primitive
Repeat 1-9 for each aerodynamic primitive,
then perform physics integration
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-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.


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


[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 (at geometric center)
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.

r
 a .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

Vr .w.


Va.c.
Drag
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/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
Abrupt drop due to burst
separation bubble
CL
Early nonlinearities are
possible (e.g., due to
laminar separation
bubble)
Aerodynamic
hysteresis, post-stall
0
a
Representing Nonlinear Lift
and Stall



There are numerous ways to represent nonlinear lift and stall
One way: simply model CL vs. a using a truncated sinusoidal
function…
…note that CL should = 0 for a >= 90 deg and a <= -90 deg
Match the theoretical dCL/da slope
at a = 0.
CL
0
45
90
a (degrees)
Representing Nonlinear Lift
and Stall

Problems with sinusoidal representation




FAR from ideal…
Max CL occurs at too large an a
Dropoff after stall may be too slow
Can fixup sinusoidal representation…for a cost

Multiply by exponential decay:



CL *= K1* exp(-(1 + (abs(a)/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 a = +/- 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 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 (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