Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc. .

58

Transcript of Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc. .

Page 1: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .
Page 2: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

Dancing with the Wind

22 March 2006

Graham RhodesApplied Research Associates, Inc.

http://www.ara.com/sed/SED_VisTechnologies.htmhttp://www.gsrhodes.com

Page 3: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 4: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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)

Page 5: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

Motivation for YOUDemo #1: business cards

dropped from sky

Page 6: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 7: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 8: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 9: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

Lets jump into the geometry & math of wind dynamics!

Page 10: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 11: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

The Relative WindX

Z

Y

Global Frame

= Aerodynamic Center

..caV

windV

Wind Dire

ction

..wrV

.... cawindwr VVV

Page 12: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 13: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

Example: Thin Airfoil/Flat Plate

C = Chord length

C/4

Local Pressure – Free-stream Pressure

..wrV

Page 14: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

The Wind Coordinate FrameX

Z

Y

Global Frame

..wrV

Xw

Page 15: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

The Wind Coordinate FrameX

Z

Y

Global Frame

Xw

Zw

Yw

Page 16: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 17: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

The Wind Coordinate FrameX

Z

Y

Global Frame

Xw

Zw

Yw

zwzwzw

ywywyw

xwxwxw

gw

ZYX

ZYX

ZYX

,,,

,,,

,,,

2R

The Wind-to-GlobalRotational Transformation

Page 18: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

The Classic Aerodynamic Forces

Xw

Zw

Yw

Drag

Lift SideForce

Page 19: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

The Classic Aerodynamic Torques

Xw

Zw

Yw

RollingMoment

YawingMoment Pitching

Moment

Page 20: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

;

Page 21: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 22: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 23: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 24: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 25: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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,

Page 26: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 27: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 28: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

....

Page 29: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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”

Page 30: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 31: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

e

Xw

Xw

Lifting Surfaces

Zw

eVeVZ wrwrw ˆˆ ....

Page 32: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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 )

Page 33: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

There are some subtle issues that you should be aware of…

Page 34: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 35: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 36: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

A Break from The Tedious Stuff

More Demos

Page 37: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

Emergence of Gentle Flutter Consider a business card dropped flat in still air…

Tim

e

Leading Edge

Leading Edge

Leading Edge

Etc…LiftDrag

Page 38: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

Emergence of Violent Tumbling Consider a business card dropped steeply in still air…

Tim

e

Leading Edge

Leading Edge

Leading Edge

Leading Edge

Page 39: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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…

Page 40: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 41: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 42: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 43: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

;

Page 44: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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(…)

Page 45: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 46: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 47: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 48: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

Backup Slides

Page 49: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 50: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 51: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 52: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 53: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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!!!!!

Page 54: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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)

Page 55: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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.

Page 56: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 57: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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

Page 58: Dancing with the Wind 22 March 2006 Graham Rhodes Applied Research Associates, Inc.  .

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