1 / 68

Why Physics?

Explore the concepts of game physics, collision detection, and collision response to create more realistic and interactive gaming experiences. Learn about the techniques used to detect and respond to collisions between objects, and how to simplify complex geometry and optimize object pair tests. This guide covers topics such as fluid dynamics, deformable models, ragdoll physics, and more.

kevinh
Download Presentation

Why Physics?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Why Physics? • More interactivity • Looks cool (explosions) • More realistic • More variety and easier animations (rag doll physics for death animations) • Better gameplay (space fighter, driving games)

  2. Game Physics • What is meant by Physics in games (old)? • Collision Detection (testing) • But want the physical effect of hitting an immovable object. • Also needed to provide the input (forces) for physical simulations (equations) of moveable or deformable objects. • More intelligent (automated) interpolation • Particle systems – Artistically defined generation with Newtonian-based controls.

  3. Game Physics • What is meant by Physics in games (new)? • Fluid dynamics • Deformable models • Ragdoll (non-scripted) articulation • (More) Accurate simulation

  4. Dead Reckoning • Given the current state of a single entity, integrate it in time assuming there are no other influences. • The state consists of: • Position • Velocity • Acceleration (optional) • Angular Momentum (optional)

  5. Collisions • Collision Detection • Collision detection is a geometric problem • Given two moving objects defined in an initial and final configuration, determine if they intersected at some point between the two states • Collision Response • The response to collisions is the actual physics problem of determining the unknown forces (or impulses) of the collision

  6. Collision Detection • ‘Collision detection’ is really a geometric intersection detection problem • Main subjects • Intersection testing (triangles, spheres, lines…) • Optimization structures (octree, BSP…) • Pair reduction (reducing N2 object pair testing)

  7. Intersection Testing • General goals: given two objects with current and previous orientations specified, determine if, where, and when the two objects intersect • Alternative: given two objects with only current orientations, determine if they intersect • Sometimes, we need to find all intersections. Other times, we just want the first one. Sometimes, we just need to know if the two objects intersect and don’t need the actual intersection data.

  8. Collision Detection Complicated for two reasons 1. Geometry is typically very complex, potentially requiring expensive testing 2. Naïve solution is O(n2) time complexity, since every object can potentially collide with every other object

  9. Collision Detection Two basic techniques 1. Overlap testing • Detects whether a collision has already occurred 2. Intersection testing • Predicts whether a collision will occur in the future

  10. Overlap Testing • Facts • Most common technique used in games • Exhibits more error than intersection testing • Concept • For every simulation step, test every pair of objects to see if they overlap • Easy for simple volumes like spheres, harder for polygonal models

  11. Overlap Testing:Useful Results • Useful results of detected collision • Time collision took place • Collision normal vector

  12. Overlap Testing:Collision Time • Collision time calculated by moving object back in time until right before collision • Bisection is an effective technique

  13. Overlap Testing:Limitations • Fails with objects that move too fast • Unlikely to catch time slice during overlap • Possible solutions • Design constraint on speed of objects • Reduce simulation step size

  14. Intersection Testing • Predict future collisions • When predicted: • Move simulation to time of collision • Resolve collision • Simulate remaining time step

  15. Intersection Testing:Swept Geometry • Extrude geometry in direction of movement • Swept sphere turns into a “capsule” shape

  16. Intersection Testing:Sphere-Sphere Collision

  17. Intersection Testing:Sphere-Sphere Collision • Smallest distance ever separating two spheres: • If there is a collision

  18. Intersection Testing:Limitations • Issue with networked games • Future predictions rely on exact state of world at present time • Due to packet latency, current state not always coherent • Assumes constant velocity and zero acceleration over simulation step • Has implications for physics model and choice of integrator

  19. Collision Resolution:Examples • Two billiard balls strike • Calculate ball positions at time of impact • Impart new velocities on balls • Play “clinking” sound effect • Rocket slams into wall • Rocket disappears • Explosion spawned and explosion sound effect • Wall charred and area damage inflicted on nearby characters • Character walks through wall • Magical sound effect triggered • No trajectories or velocities affected

  20. Dealing with Complexity Two issues 1. Complex geometry must be simplified 2. Reduce number of object pair tests

  21. Collision Detection Methods • Many different methods • We will focus on two of them: • Grid method: good for many simple moving objects of about the same size (e.g., many moving discs with similar radii) • Bounding Volume Hierarchy (BVH) method: good for few moving objects with complex geometry

  22. d Grid Method • Subdivide space into a regular grid cubic of square bins • Index each object in a bin

  23. d Grid Method Running time is proportional tonumber of moving objects

  24. Bounding Volume Hierarchy Method • Enclose objects into bounding volumes (spheres or boxes) • Check the bounding volumes first

  25. Bounding Volume Hierarchy Method • Enclose objects into bounding volumes (spheres or boxes) • Check the bounding volumes first • Decompose an object into two

  26. Bounding Volume Hierarchy Method • Enclose objects into bounding volumes (spheres or boxes) • Check the bounding volumes first • Decompose an object into two • Proceed hierarchically

  27. Bounding Volume Hierarchy Method • Enclose objects into bounding volumes (spheres or boxes) • Check the bounding volumes first • Decompose an object into two • Proceed hierarchically

  28. Bounding Volume Hierarchy Method • BVH is pre-computed for each object

  29. BVH in 3D

  30. A A C C B B E F E F D D G G Collision Detection Two objects described by their precomputed BVHs

  31. pruning Collision Detection Search tree AA A A

  32. A C B E F D G BB BC CB CC Collision Detection Search tree AA A A

  33. A C B E F D G pruning Collision Detection Search tree AA BB BC CB CC

  34. A C B E F D G FD FE GD GE G D Collision Detection Search tree AA BB BC CB CC If the pieces contained in G and D overlap  collision

  35. Performance Several thousand collision checks per second for 2 three-dimensional objects each described by 500,000 triangles, on a 1-GHz PC

  36. Desirable Properties of BVs and BVHs BVs: • Tightness • Efficient testing • Invariance • BVH: • Separation • Balanced tree ?

  37. Desirable Properties of BVs and BVHs BVs: • Tightness • Efficient testing • Invariance • BVH: • Separation • Balanced tree

  38. Spheres • Invariant • Efficient to test • But tight?

  39. Axis-Aligned Bounding Box (AABB)

  40. Axis-Aligned Bounding Box (AABB) • Not invariant • Efficient to test • Not tight

  41. Oriented Bounding Box (OBB)

  42. Oriented Bounding Box (OBB) • Invariant • Less efficient to test • Tight

  43. Comparison of BVs No type of BV is optimal for all situations

  44. Why a Physics Engine? • Physics simulation is hard • Requires very stable integrator • Articulated bodies especially take difficult math • Optimization is important • Spring systems explode easily

  45. Major Features • Collision detection • Newtonian forces and collision response • Buoyant forces • Friction • Articulation and jointed characters (rag doll) • Prebuilt objects for simulation

  46. Physics Toolkits • ODE (Open Dynamics Engine) • Ageia PhysX • Newton Game Dynamics • Havok • Havok FX • Tokamak Game Physics

  47. Rigid Body Dynamics • What is involved in this: • http://www.youtube.com/watch?v=NM0bY_IFoes&feature=related

  48. More Complicated? • What about this one? • http://www.youtube.com/watch?v=Q7HLWrldgLQ&feature=related

  49. Ragdoll Physics • YouTube • http://www.youtube.com/watch?v=gbuA-HEbROk • Demo • http://www.2dplay.com/ragdoll-physics-2/ragdoll-physics-2-play.htm

  50. Fluid Dynamics • Water and other fluids are governed by the Navier Stokes equations. • http://gameplanets.blogspot.com/2007/06/physics-simulations.html • nVidia demo • http://www.youtube.com/watch?v=wWlaD_2gsIM&feature=related

More Related