Presentation is loading. Please wait.

Presentation is loading. Please wait.

Havok Xtra Training

Similar presentations


Presentation on theme: "Havok Xtra Training"— Presentation transcript:

1 Havok Xtra Training http://www.havok.com/xtra xtra@havok.com

2 Introduction Physics Simulation? Havok Xtra Workflow – Tutorials – Gotchas

3 Physics Simulation Initialize Step – Advance simulation by h seconds 10 Apply Forces 20 Do Collision Detection 30 Do Collision Resolution 40 Go to 10 Shutdown

4 Step real new position estimated new position r(t 0 + h) r(t 0 ) h v(t 0 )

5 Step Improve by: – decreasing step size – introducing sub steps Simulated position Actual position

6 Step Sub steps

7 Step Stepping strategy – Fixed havok.step( 1.0 / the tempo ) – + system can be optimized for the time step – - less control over simulation level of detail – Variable havok.step( newTime - oldTime ) – + real-time if linked to system clock – - can introduce escalating, large time steps – Hybrid

8 Havok Xtra Workflow Content Creation Setup Control W3D Files HKE Files

9 Content Creation Shockwave 3D members – Rigid bodies must link to a visual equivalent – Geometry Lingo Exported from a modeling package – W3D – HKE

10 Geometry Implicit – Plane – Sphere Convex – Compound Concave Proxies

11 Representations Geometry

12 Proxies Representations – Physics – Display

13 max Havok Guidelines Supported – Rigid Bodies – Springs – Dashpots Unsupported – Deformable Bodies – Constraints – Display Information

14 max Havok Guidelines Compound Rigid Bodies – Groups should be open Rigid Body Collections – Check the integrator – Disable unnecessary collisions Proxy Geometry – Transforms must be aligned

15 max Havok Guidelines IntegratorCPUAccuracy Havok Xtra members use Euler Max Havok defaults to Runga Kutta Euler Low Back-Euler Medium Runga Kutta (RK45) High Midpoint MediumMedium-High

16 Setup Initialize – Blank HKE Scale Tolerance – Imported HKE

17 Setup Initialize – How is the simulation displayed? Physics objects must link to a visual equivalent – What is the mapping between the physics simulation and its display?

18 Scale Size matters – Physics units are meters, seconds and kilograms – Display unit may be different havok.initialize(member, tolerance, worldScale) – Examples: havok.initialize(1, 0.1, 1.0) -- meters havok.initialize(1, 4, 0.0254) -- inches havok.initialize(1, 10, 1000) -- kilometers

19 Box falls in: – ~1 second if units are meters – ~40 seconds if units are in kilometers Scale 7.5 5 20

20 Setup Initialize property hk, s on beginSprite me hk = member("HKE") s = member("W3D") hk.initialize( s ) end on exitFrame me hk.step() end on endSprite me hk.shutdown() s.resetWorld() end

21 Setup Rigid Body s = member(“W3D") hk = member(“HKE") mr = s.newModelResource(“MDLRes", #box) m = s.newModel(“MDL") m.addModifier(#meshdeform) if bWantFixed then rb = hk.makeMovableRigidBody(m.name, 10.0) else rb = hk.makeFixedRigidBody(m.name) end if

22 Control Input – Properties – Functions – Behaviors Step call backs Output – Properties – Collision Details Collision call backs

23 Control Collision Callback: Called when a certain pair of objects collide. Information about the collision is returned to the user here so that they may take appropriate action. Collision Callback: Called when a certain pair of objects collide. Information about the collision is returned to the user here so that they may take appropriate action. Setup Initial Conditions: Define Geometry Initial position and velocity, gravity, wind, air resistance, Time step = h = 1/60 seconds Setup Initial Conditions: Define Geometry Initial position and velocity, gravity, wind, air resistance, Time step = h = 1/60 seconds Update System: Advance time to t = t + h: Integrate Calculate new position & orientation Advance time to t = t + h: Integrate Calculate new position & orientation Call LINGO: LINGO specific updates applied. Call LINGO: LINGO specific updates applied. Detect Collision: Determine all colliding objects. Use physics parameters to Determine appropriate response Detect Collision: Determine all colliding objects. Use physics parameters to Determine appropriate response Display: Draw object at specified new location. Display: Draw object at specified new location. Update State: Calculate forces, velocity, acceleration... Update State: Calculate forces, velocity, acceleration...

24 Control Global Control – Time Step – Gravity – Deactivation Parameters – Drag Parameters Local Control – Rigid Bodies

25 Rigid Bodies Vectors: – position (m) – velocity (m/s) – angular velocity (rad/s) – momentum (kg m/s) – angular momentum (kg rad/s) – force (kg m/s 2 = N) – torque (kg m 2 /s 2 = Nm ) – acceleration (m/s 2 ) – angular acceleration (rad/m 2 ) Scalars: – mass (kg) – friction – restitution Use right hand rule for angular quantities: +ve  CCW rotation -ve  CW rotation

26 Rigid Bodies applyForce No immediate change in velocity applyImpulse Immediate change in velocity

27 Rigid Bodies Alter position: – rb.position = vector(2.0, 3.0, 4.0) Alter velocity: – rb.linearVelocity = vector(1.0, 0.0, 0.0) – rb.applyImpulse(vector(1.0, 0.0, 0.0)) – rb.applyImpulseAtPoint(impulse, point) Alter acceleration: – rb.applyForce(vector(1.0, 0.0, 0.0)) – rb.applyForceAtPoint(force, point) ! DANGER ! induces spin force applied at center of mass

28 Rigid Bodies Alter orientation: – body.rotation = [vector(0.0, 1.0, 0.0), 90] Alter angular velocity: – body.angularVelocity = vector(1.0, 0.0, 0.0) – body.applyAngularImpulse(vector(2.0, 0.0, 0.0)) Alter angular acceleration: – body.applyTorque(vector(2.0, 0.0, 0.0)) ! DANGER ! Axis = (1.0, 0.0, 0.0) Magnitude = 2.0

29 Rigid Bodies Problem with direct manipulation Interpenetrations = not good set position set orientation ! DANGER !

30 Rigid Bodies attemptMoveTo(pos, axis, angle) – moves object to position & orientation and checks for interpenetration – returns true if successful – returns false if move illegal and put back interpolatingMoveTo(pos, axis, angle) – positions object as close to desired location as possible – returns parametric distance – 1.0 if moved completely – 0.5 if moved halfway – 0.0 if not moved at all desired new position interpolatingMoveTo gets 70% there

31 Behaviors Apply Constant Acceleration on enterFrame me rb = hk.rigidBody( pModel ) if not voidP( rb ) then rb.applyForce( acc * rb.mass ) end if end enterFrame Anti-gravity behavior if force is negation of havok.gravity? rb.applyForce( acc * rb.mass * pHavok.substeps )

32 Behaviors Step callbacks – Anti-gravity on beginSprite me hk.registerStepCallback(#antigrav,me) end beginSprite on antiGrav me, newTime acc = -hk.gravity rb = hk.rigidBody( pModel ) if not voidP( rb ) then rb.applyForce( acc * rb.mass ) end if end antiGrav

33 Collision Detection Back-stepping Time t Time t+h Region of interpenetration

34 Collision Detection Tolerance – Physical simulations have a limited resolution – Tolerance accounts for numerical inaccuracies LOW  numerically instable HIGH  noticeable gaps between objects: – Rule of thumb: tolerance = world scale / 10.0 tolerance

35 Collision Detection Call me after a collision hk.registerInterest( rb1, #all, f, t, #handler, me ) Callback passed collision details on handler( me, details ) put details end Lost Interest hk.removeInterest( rb.name )

36 Collision Detection Details – Name of Rigid Body A – Name of Rigid Body B – Contact Point – Contact Normal – Normal Relative Velocity A B

37 Collision Detection Not all collisions are needed hk.disableCollision( rb1, rb2 ) Might not need any hk.disableAllCollision( rb1 ) Or maybe some hk.enableCollision( rb.name, “Ground” )

38 Gotchas Initialize:only ever one simulation activate Initialize:what the scaling


Download ppt "Havok Xtra Training"

Similar presentations


Ads by Google