1 / 11

Computer Game Design and Development

Computer Game Design and Development. Collision Detection. Havok Destruction. Overlap Bisection. Limitations of Overlap Testing. Intersection Testing. Collision Approximations Minkowski Sum – sweep origin of X across Y. Performance. Possible collision between R and B since overlap in

gadsden
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 Collision Detection Havok Destruction

  2. Overlap Bisection

  3. Limitations of Overlap Testing

  4. Intersection Testing

  5. Collision ApproximationsMinkowski Sum – sweep origin of X across Y

  6. Performance Possible collisionbetween R and B since overlap in all axis (2 in this case) Subdivide such that on averageone object in each cell.

  7. Per-Pixel Collision // The color data for the images; used for per-pixel collision Color[] personTextureData; Color[] rocketTextureData; // Load textures rocketTexture = Content.Load<Texture2D>(“Rocket"); personTexture = Content.Load<Texture2D>("Person"); // Extract collision data rocketTextureData = new Color[rocketTexture.Width * rocketTexture.Height]; rocketTexture.GetData(rocketTextureData); personTextureData = new Color[personTexture.Width * personTexture.Height]; personTexture.GetData(personTextureData); http://creators.xna.com/en-US/tutorial/collision2dperpixel

  8. Per-Pixel Collision (cont) static boolIntersectPixels(Rectangle rectangleA, Color[] dataA, Rectangle rectangleB, Color[] dataB) { // Find the bounds of the rectangle intersection int top = Math.Max(rectangleA.Top, rectangleB.Top); int bottom = Math.Min(rectangleA.Bottom, rectangleB.Bottom); int left = Math.Max(rectangleA.Left, rectangleB.Left); int right = Math.Min(rectangleA.Right, rectangleB.Right); // Check every point within the intersection bounds for (int y = top; y < bottom; y++) for (int x = left; x < right; x++) { // Get the color of both pixels at this point Color colorA = dataA[(x - rectangleA.Left) + (y - rectangleA.Top) * rectangleA.Width]; Color colorB = dataB[(x - rectangleB.Left) + (y - rectangleB.Top) * rectangleB.Width]; // If both pixels are not completely transparent, if (colorA.A != 0 && colorB.A != 0) // then an intersection has been found return true; } // No intersection found return false; }

  9. Bounding Volumes AABB OBB

  10. Terrain Collision • Heightmap information • Look up terrain height • 3 LERPs – Linear Interpretation between points • X • Z • Between x and z http://creators.xna.com/en-US/sample/collision3dheightmap

  11. Resolving Collision • Gross collision & subdivide if needed • Three phases • Prologue – ignore or trigger other events • Collision – point of impact, new velocities • Epilogue – destroy object, effects, damage

More Related