1 / 21

Computer Game Design and Development

Computer Game Design and Development. Mathematics, Collision, and Physics. Havok Destruction. Basic Problem. Without physics: There’s no gravity There’s no friction There are no collisions Objects pass through one another We must determine: If objects collide (collision detection)

tedson
Download Presentation

Computer Game Design and Development

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. Computer Game Design and Development Mathematics, Collision, and Physics Havok Destruction

  2. Basic Problem • Without physics: • There’s no gravity • There’s no friction • There are no collisions • Objects pass through one another • We must determine: • If objects collide (collision detection) • Where/when they collided (collision resolution)

  3. Collision Detection • Bullets (very fast) • Characters (very complex) • Naïve algorithms run in O(n2) • Two primary methods: • Overlap testing (most common) • Intersection testing (sweeping)

  4. Overlap Testing • Determines if two objects overlap (duh!) • Check each vertex of an object inside another? • Exhibits the most error • Is discrete (i.e. checks an exact point in time) • Results: • Give a time of collision • Give a normal of collision • Uses bisection…

  5. Overlap Bisection

  6. Limitations of Overlap Testing Design constraint? Speed of objects * time step < size of all objects? Reduce time step?

  7. Intersection Testing • “Sweep” an object from one pointto another (i.e. “extrude” – sphere • becomes capsule). • Can calculate t with an equation-> • See book for equation • Doesn’t work well for network games

  8. Collision ApproximationsMinkowski Sum – sweep origin of X across Y Intersection technique. These are the same!

  9. Bounding Volumes and Boxes AABB OBB

  10. About Bounding Volumes • Simplest is sphere • Next is capsule (2 spheres and a cylinder), • Next are AABBs • What can we do about character collisions?

  11. Performance(avoiding O(n2)) Possible collisionbetween R and B since overlap in all axis (2 in this case) • Subdivide such that on averageone object in each cell. • Test against neighboring cells • What if all are in one cell? • Variable-sized objects? “Plane sweep” needs to be sorted! Which algorithm? Quicksort?Bubblesort?

  12. Terrain Collision • Determine which quad is easy • Heightmap (x and z are fixed, y is variable) • Which triangle in the quad? • Compare x with z http://creators.xna.com/en-US/sample/collision3dheightmap

  13. Resolving Collision • Gross collision & subdivide if needed • Three phases • Prologue – ignore or trigger other events • Collision – objects moved to point of impact, new velocities, calculate normal and penetration • Epilogue – destroy object, effects, damage, etc

  14. Particle Physics Basics • Use consistent units (SI) – or bad stuff happens • Particle kinematics • Position (p) in 3-space, vector3 (x,y,z) = p(t) • Velocity (v) = change in position over time, V(t) • Acceleration (a) = change in velocity over time, a(t) • Force (f) = results in change in acceleration over time, F(t) = ma(t) • Calculus • Derivatives and integrals go from one to another

  15. Center of Mass

  16. Collision Response (frictionless)

  17. Other Definitions • Kinematic objects: those that move • Static objects: those that don’t, but affect those that do (terrain) • Rigid bodies: objects that do not deform • Soft bodies: • those that do • Center of gravity changes • Cloth, deflated ball…

  18. Rigid Body CollisionCenter of Mass Consideration

  19. More Definitions • Constraints: • Limitations on what objects can do • Joint types: ball joint, hinge joint, sliding joint • Ragdoll physics: • Animated bones replaced by rigid bodies • Good for violent death animations • http://www.youtube.com/watch?v=4gR_dP4HaF8

  20. Physics Engines • Commercial • Game Dynamics SDK (Havok) • Renderware Physics • PhysX (NVIDIA) • NovodeX SDK • Free/Shareware • Open Dynamics Engine (ODE) • Tokamak Game Physics SDK • Newton Game Dynamics SDK • Bullet SDK

  21. Demos http://www.havok.com/content/view/584/96/ http://www.tokamakphysics.com/index.htm

More Related