1 / 75

CSCE 590E Spring 2007

CSCE 590E Spring 2007. Collision Detection. By Jijun Tang. Announcements. Final game demo will be held at 2:00pm, Tuesday, May 8 th Homework 4 will be given today Second presentation will be held on April 16 th and 18 th April 16 th : Space Banditos, Slackers, Psychosoft

tansy
Télécharger la présentation

CSCE 590E Spring 2007

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. CSCE 590E Spring 2007 Collision Detection By Jijun Tang

  2. Announcements • Final game demo will be held at 2:00pm, Tuesday, May 8th • Homework 4 will be given today • Second presentation will be held on April 16th and 18th • April 16th: Space Banditos, Slackers, Psychosoft • April 18th: Project Gnosis, Cheeze Puffs!, Team Swampus

  3. Needs to do • Two groups need to send me the first presentation after the class • Some people didn’t send me the members in their small project. • Please send the membership of the small project to stahlj@cse.sc.edu

  4. Real-time Physics in Game at Runtime: • Enables the emergent behavior that provides player a richer game experience • Potential to provide full cost savings to developer/publisher • Difficult • May require significant upgrade of game engine • May require significant update of asset creation pipelines • May require special training for modelers, animators, and level designers • Licensing an existing engine may significantly increase third party middleware costs

  5. Engines • Commercial • Game Dynamics SDK (Havok.com) • Renderware Physics (renderware.com) • NovodeX SDK (novodex.com) • Free • Open Dynamic Engine (ODE) (ode.org) • Tokamak Game Physics SDK (tokamakphysics.com) • Newton Game Dynamics SDK (newtondynamics.com)

  6. Particle Physics • What is a Particle? • A sphere of finite radius with a perfectly smooth, frictionless surface • Experiences no rotational motion (or assume the sphere has no size) • Particle Kinematics • Defines the basic properties of particle motion • Position, Velocity, Acceleration

  7. Particle Position • Location of Particle in World Space • SI Units: meters (m) • Changes over time when object moves

  8. Particle Velocity and Acceleration • Velocity (SI units: m/s) • First time derivative of position: • Acceleration (SI units: m/s2) • First time derivative of velocity • Second time derivative of position

  9. Newton’s 2nd Law of Motion • Paraphrased –“An object’s change in velocity is proportional to an applied force” • The Classic Equation: • m = mass (SI units: kilograms, kg) • F(t) = force (SI units: Newtons)

  10. What is Physics Simulation? • The Cycle of Motion: • Force, F(t), causes acceleration • Acceleration, a(t), causes a change in velocity • Velocity, V(t) causes a change in position • Physics Simulation: • Solving variations of the above equations over time to emulate the cycle of motion

  11. Concrete Example: Target Practice Projectile Launch Position, pinit Target

  12. Target Practice • Choose Vinit to Hit a Stationary Target • ptarget is the stationary target location • We would like to choose the initial velocity, Vinit, required to hit the target at some future time, thit. • Here is our equation of motion at time thit: • Solution in general is a bit tedious to derive… • Infinite number of solutions! • Hint: Specify the magnitude of Vinit, solve for its direction

  13. Example 1 Vinit = 25 m/s Value of Radicand of tanf equation: Launch angle f: 19.4 deg or 70.6 deg 969.31

  14. Finite Difference Methods • The Explicit Euler Integrator: • Properties of object are stored in a state vector, S • Use the above integrator equation to incrementally update S over time as game progresses • Must keep track of prior value of S in order to compute the new • For Explicit Euler, one choice of state and state derivative for particle:

  15. Finite Difference Methods • The Verlet Integrator: • Must store state at two prior time steps, S(t) and S(t-Dt) • Uses second derivative of state instead of the first • Valid for constant time step only (as shown above) • For Verlet, choice of state and state derivative for a particle:

  16. Generalized Rigid Bodies • Key Differences from Particles • Not necessarily spherical in shape • Position, p, represents object’s center-of-mass location • Surface may not be perfectly smooth • Friction forces may be present • Experience rotational motion in addition to translational (position only) motion

  17. Additional forces • Linear Spring • Viscous Damping • Aerodynamic Drag • Friction • …

  18. Linear Springs

  19. Viscous Damping

  20. Aerodynamic Drag S: projected front area CD: drag coefficient

  21. Friction

  22. Collision Detection and Resolution

  23. What is Collision Detection • A fundamental problem in computer games, computer animation, physically-based modeling, geometric modeling, and robotics. • Including algorithms: • To check for collision, i.e. intersection, of two given objects • To calculate trajectories, impact times and impact points in a physical simulation.

  24. Collision Detection • Complicated for two reasons • Geometry is typically very complex, potentially requiring expensive testing • Naïve solution is O(n2) time complexity, since every object can potentially collide with every other object • Two basic techniques • Overlap testing: Detects whether a collision has already occurred • Intersection testing: Predicts whether a collision will occur in the future

  25. Overlap Testing (a posteriori) • Overlap testing: Detects whether a collision has already occurred, sometime is referred as a posteriori • Facts • Most common technique used in games • Exhibits more error than intersection testing • Concept • For every (small) simulation step, test every pair of objects to see if they overlap • Easy for simple volumes like spheres, harder for polygonal models

  26. Overlap Testing Results • Useful results of detected collision • Pairs of objects will have collision • Time of collision to take place • Collision normal vector • Collision time calculated by moving object back in time until right before collision • Bisection is an effective technique

  27. Bisect Testing: collision detected

  28. Bisect Testing: Iteration I

  29. Bisect Testing: Iteration II

  30. Bisect Testing: Iteration III

  31. Bisect Testing: Iteration IV

  32. Bisect Testing: Iteration V Time right before the collision

  33. Overlap Testing: Limitations • Fails with objects that move too fast (compared to the object) • Thin glass vs. bulltes • Unlikely to catch time slice during overlap

  34. Solution for This Limitation • Speed of the fastest object multiplies the time step should be smaller than the smallest objects in the scene • Possible solutions • Design constraint on speed of objects • Hard to apply without affecting the play • Reduce simulation step size • Too expensive

  35. Intersection Testing (a priori) • Predict future collisions • When predicted: • Move simulation to time of collision • Resolve collision • Simulate remaining time step

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

  37. Intersection Testing:Sphere-Sphere Collision d

  38. Special Cases • No collision: • B2 = 0: both objects are stationary, or they are traveling at parallel • When will collision occur?

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

  40. 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

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

  42. Simplified Geometry • Approximate complex objects with simpler geometry, like this ellipsoid or bounding boxes

  43. Minkowski Sum • By taking the Minkowski Sum of two complex volumes and creating a new volume, overlap can be found by testing if a single point is within the new volume

  44. Minkowski Sum

  45. Using Minkowski Sum

  46. Bounding Volumes • Bounding volume is a simple geometric shape • Completely encapsulates object • If no collision with bounding volume, no more testing is required • Common bounding volumes • Sphere • Box

  47. Box Bounding Volumes

  48. More Examples

  49. Using Bounding Box in Game • Complex objects can have multiple bounding boxes • Human object can have one big bounding box for the whole body • Human object can have one bounding box per limb, head, etc • Bounding box can be hierarchical: • Test the big first • if possible collision, test the smaller ones

  50. Reduce Number of Detections O(n) Time Complexity can be achieved. One solution is to partition space

More Related