Havok Xtra Training - PowerPoint PPT Presentation

havok xtra training n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Havok Xtra Training PowerPoint Presentation
Download Presentation
Havok Xtra Training

play fullscreen
1 / 38
Havok Xtra Training
128 Views
Download Presentation
venus
Download Presentation

Havok Xtra Training

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
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. r(t0+ h) estimated new position h v(t0) real new position r(t0) Step ?

  5. Step Simulated position • Improve by: • decreasing step size • introducing sub steps 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. W3D Files HKE Files Havok Xtra Workflow • Content Creation • Setup • Control

  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. Geometry • Representations

  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 • Integrator CPU Accuracy • Havok Xtra members use Euler • Max Havok defaults to Runga Kutta

  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. 5 20 7.5 Scale • Box falls in: • ~1 second if units are meters • ~40 seconds if units are in kilometers

  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 Setup Initial Conditions: Define Geometry Initial position and velocity, gravity, wind, air resistance, Time step = h = 1/60 seconds Display: Draw object at specified new location. Update System: Update State: Calculate forces, velocity, acceleration... Call LINGO: LINGO specific updates applied. Advance time to t = t + h: Integrate Calculate new position & orientation 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. Detect Collision: Determine all colliding objects. Use physics parameters to Determine appropriate response

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

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

  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 ! force applied at center of mass induces spin

  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 set position ! DANGER ! Interpenetrations = not good set orientation

  30. Rigid Bodies desired new position • 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 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. Time t Time t+h Region of interpenetration Collision Detection • Back-stepping

  34. tolerance 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

  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. B A Collision Detection • Details • Name of Rigid Body A • Name of Rigid Body B • Contact Point • Contact Normal • Normal Relative Velocity

  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