Download presentation
Presentation is loading. Please wait.
Published byAlvin McCoy Modified over 9 years ago
1
Collision Detection and Response
2
Motivation OpenGL is a rendering system OpenGL is a rendering system OpenGL has no underlying knowledge of the objects it draws OpenGL has no underlying knowledge of the objects it draws Collision Detection == Intersection Detection Collision Detection == Intersection Detection
3
Motivation Collision Detection Collision Detection Identifying the intersection of 3D models Identifying the intersection of 3D models Collision Response Collision Response Calculating the appropriate post collision response of the 3D models Calculating the appropriate post collision response of the 3D models Assumptions Assumptions Closed 3D polygonal objects Closed 3D polygonal objects
4
Overall Approach Where is collision detection and response in code? Where is collision detection and response in code? In animation function In animation function Usually in Idle or Display Usually in Idle or Display Update object positions Update object positions If (CollisionDetection()) If (CollisionDetection()) Collision Response() Collision Response() Draw Objects Draw Objects
5
Collision Detection Basic Collision Detection function Basic Collision Detection function for (i=0;i<num_of_objects-1;i++) for (i=0;i<num_of_objects-1;i++) for (j=i+1;j<num_of_objects;j++) for (j=i+1;j<num_of_objects;j++) X=TestIntersection(Object I, Object j) X=TestIntersection(Object I, Object j) If (x==1) return 1; If (x==1) return 1;
6
Collision Detection Packages SWIFT++ SWIFT++ http://www.cs.unc.edu/~geom/SWIFT++/ http://www.cs.unc.edu/~geom/SWIFT++/ http://www.cs.unc.edu/~geom/SWIFT++/ Works on ‘polygon soup’ Works on ‘polygon soup’
7
Why is collision detection difficult? Too many calculations Too many calculations Reduce # of calculations Reduce # of calculations Accuracy Accuracy Accept approximations Accept approximations Lots of poor cases Lots of poor cases Guarantee detection? Guarantee detection? Accuracy requirements? Accuracy requirements? http://www.cs.unc.edu/~geom/collide/ind ex.shtml http://www.cs.unc.edu/~geom/collide/ind ex.shtml
8
Reduce Calculations Reduce object complexity Reduce object complexity Test with only other objects that might be within collision spaces Test with only other objects that might be within collision spaces Spatial divisions Spatial divisions Pre-process vs. runtime Pre-process vs. runtime
9
Approximate Object Shape For many applications, it is not necessary to get absolute collision detection accuracy For many applications, it is not necessary to get absolute collision detection accuracy How can we approximate the shape? How can we approximate the shape?
10
Bounding Boxes Calculate a 3D box that bounds the object Calculate a 3D box that bounds the object In the collision detection test, use the 3D box to test for collision in place of the full model In the collision detection test, use the 3D box to test for collision in place of the full model Two types Two types Axis Aligned Axis Aligned Bounding boxes are aligned w/ the world coordinate axes Bounding boxes are aligned w/ the world coordinate axes Object Aligned Object Aligned Bounding boxes are aligned w/ the object coordinate axes Bounding boxes are aligned w/ the object coordinate axes
11
Axis Aligned Bounding Boxes How do we calculate a AABB? How do we calculate a AABB? Take max and min for each dimension Take max and min for each dimension Pros Pros Very fast Very fast Works for many situations Works for many situations Cons Cons Collision detection accuracy reduced for many cases Collision detection accuracy reduced for many cases
12
Axis Aligned Bounding Boxes How do we calculate intersections? How do we calculate intersections? Calculate overlap for the min-max range for each dimension Calculate overlap for the min-max range for each dimension Pros Pros Very fast Very fast Works for many situations Works for many situations Cons Cons Collision detection accuracy reduced for many cases Collision detection accuracy reduced for many cases
13
Object-Aligned Bounding Boxes Calculate BB based on object’s primary dimensions Calculate BB based on object’s primary dimensions Object’s dimensions could be encoded in model or calculated real-time Object’s dimensions could be encoded in model or calculated real-time Apply M matrix to bounding box coordinates Apply M matrix to bounding box coordinates
14
Other bounding shapes Boxes Boxes Cubes Cubes Cylinders Cylinders Polygons Polygons User-defined shapes User-defined shapes Should be easy to calculate and test Should be easy to calculate and test
15
Bounding Box Approach Test collisions with BB Test collisions with BB Can either report collision Can either report collision Or then calculate more accurate collision Or then calculate more accurate collision Benefits of this include more accurate response Benefits of this include more accurate response
16
Poor cases Thin objects Thin objects
17
Poor cases Numerical Precision Numerical Precision
18
Collision Response Assuming rigid bodies Assuming rigid bodies Idea is to “rewind time” and to point of collision and calculate resulting location Idea is to “rewind time” and to point of collision and calculate resulting location
19
Why is collision response difficult? Resolving interpenetration is difficult Resolving interpenetration is difficult Multiple objects Multiple objects http://www.peroxide.dk/download/tutorials/tut10/pics/pic04.jpg
20
Numerical Imprecision Vibrations Vibrations Solutions? Minimum delta Solutions? Minimum delta
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.