Date post: | 13-Dec-2015 |
Category: |
Documents |
Upload: | alvin-mccoy |
View: | 232 times |
Download: | 1 times |
Collision Detection and Collision Detection and ResponseResponse
MotivationMotivation
OpenGL is a rendering systemOpenGL is a rendering system OpenGL has no underlying knowledge of OpenGL has no underlying knowledge of
the objects it drawsthe objects it draws Collision Detection == Intersection Collision Detection == Intersection
DetectionDetection
MotivationMotivation
Collision DetectionCollision Detection Identifying the intersection of 3D modelsIdentifying the intersection of 3D models
Collision ResponseCollision Response Calculating the appropriate post collision Calculating the appropriate post collision
response of the 3D modelsresponse of the 3D models AssumptionsAssumptions
Closed 3D polygonal objectsClosed 3D polygonal objects
Overall ApproachOverall Approach
Where is collision detection and Where is collision detection and response in code?response in code?
In animation functionIn animation functionUsually in Idle or DisplayUsually in Idle or DisplayUpdate object positionsUpdate object positionsIf (CollisionDetection())If (CollisionDetection())
Collision Response()Collision Response()Draw ObjectsDraw Objects
Collision DetectionCollision Detection
Basic Collision Detection functionBasic 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;
Collision Detection PackagesCollision Detection Packages
SWIFT++SWIFT++http://www.cs.unc.edu/~geom/SWIFT++http://www.cs.unc.edu/~geom/SWIFT++
//Works on ‘polygon soup’Works on ‘polygon soup’
Why is collision detection Why is collision detection difficult?difficult?
Too many calculationsToo many calculationsReduce # of calculationsReduce # of calculations
AccuracyAccuracyAccept approximationsAccept approximations
Lots of poor casesLots of poor casesGuarantee detection?Guarantee detection?Accuracy requirements?Accuracy requirements?
http://www.cs.unc.edu/~geom/http://www.cs.unc.edu/~geom/collide/index.shtmlcollide/index.shtml
Reduce CalculationsReduce Calculations
Reduce object Reduce object complexitycomplexity
Test with only Test with only other objects other objects that might be that might be within collision within collision spacesspacesSpatial divisionsSpatial divisions
Pre-process vs. Pre-process vs. runtimeruntime
Approximate Object ShapeApproximate Object Shape
For many For many applications, it is not applications, it is not necessary to get necessary to get absolute collision absolute collision detection accuracydetection accuracy
How can we How can we approximate the approximate the shape?shape?
Bounding BoxesBounding Boxes
Calculate a 3D box that Calculate a 3D box that bounds the objectbounds the object
In the collision detection In the collision detection test, use the 3D box to test, use the 3D box to test for collision in place test for collision in place of the full modelof the full model
Two typesTwo types Axis AlignedAxis Aligned
Bounding boxes are aligned Bounding boxes are aligned w/ the world coordinate w/ the world coordinate axesaxes
Object AlignedObject Aligned Bounding boxes are aligned Bounding boxes are aligned
w/ the object coordinate w/ the object coordinate axesaxes
Axis Aligned Bounding BoxesAxis Aligned Bounding Boxes
How do we calculate a How do we calculate a AABB?AABB? Take max and min for each Take max and min for each
dimensiondimension ProsPros
Very fastVery fast Works for many situationsWorks for many situations
ConsCons Collision detection accuracy Collision detection accuracy
reduced for many casesreduced for many cases
Axis Aligned Bounding BoxesAxis Aligned Bounding Boxes
How do we calculate How do we calculate intersections?intersections? Calculate overlap for the min-Calculate overlap for the min-
max range for each dimensionmax range for each dimension ProsPros
Very fastVery fast Works for many situationsWorks for many situations
ConsCons Collision detection accuracy Collision detection accuracy
reduced for many casesreduced for many cases
Object-Aligned Bounding Object-Aligned Bounding BoxesBoxes
Calculate BB based on object’s primary dimensionsCalculate BB based on object’s primary dimensions Object’s dimensions could be encoded in model or Object’s dimensions could be encoded in model or
calculated real-timecalculated real-time Apply M matrix to bounding box coordinatesApply M matrix to bounding box coordinates
Other bounding shapesOther bounding shapes
BoxesBoxesCubesCubesCylindersCylindersPolygonsPolygonsUser-defined User-defined
shapesshapesShould be easy to Should be easy to
calculate and testcalculate and test
Bounding Box ApproachBounding Box Approach
Test collisions Test collisions with BBwith BB
Can either report Can either report collisioncollision
Or then calculate Or then calculate more accurate more accurate collisioncollision Benefits of this Benefits of this
include more include more accurate responseaccurate response
Poor casesPoor cases
Thin objectsThin objects
Poor casesPoor cases
Numerical PrecisionNumerical Precision
Collision ResponseCollision Response
Assuming rigid bodiesAssuming rigid bodies Idea is to “rewind time” and to point Idea is to “rewind time” and to point
of collision and calculate resulting of collision and calculate resulting locationlocation
Why is collision response Why is collision response difficult?difficult?
Resolving interpenetration is difficultResolving interpenetration is difficultMultiple objectsMultiple objects
http://www.peroxide.dk/download/tutorials/tut10/pics/pic04.jpg
Numerical ImprecisionNumerical Imprecision
VibrationsVibrationsSolutions? Minimum deltaSolutions? Minimum delta