Presentation is loading. Please wait.

Presentation is loading. Please wait.

11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Managing large numbers of objects Colliding spheres with things (spheres being common.

Similar presentations


Presentation on theme: "11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Managing large numbers of objects Colliding spheres with things (spheres being common."— Presentation transcript:

1 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Managing large numbers of objects Colliding spheres with things (spheres being common proxies) Project Stage 4, Grading meetings this week

2 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Today Using separating planes/axes for collision testing Collision detection packages Time critical collision detection

3 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Triangle-Triangle Testing (Moller and Haines) Finding the intersection of two triangles is the base case for many general purpose collision packages Observations: What can you say about the intersection of two triangles in 2D or 3D? –Type of intersection? Points (how many), line, plane? –Relationship of intersection feature to original triangles? –Some simple conditions that must hold for triangles to intersect?

4 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin 2D Triangle Testing Overlap found by testing edges from one triangle against those of the other Overlap found by testing one vertex from each triangle for containment in the other

5 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Triangle-Triangle General Case (Moller and Haines) Option 1: –Find points where triangle A’s edges intersect the plane of triangle B (at most 2 points) – no collision if no such points –Join them with a segment –Test segment against triangle B – test must check for containment –Version in book uses slow segment-triangle test, and doesn’t test containment Option 2 (fastest, when implemented correctly): –Find the line of intersection of the two planes –Find the intervals for which the lines lie inside each triangle (parameters only) –Test if the intervals overlap Options 3 and 4: –Look for a separating plane, or use Voronoi regions

6 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Separating Planes Two convex objects do not intersect if and only if there exists a plane that separates them - a separating plane Can also use the separating axis - the normal of the separating plane –More convenient for testing The number of potential separating plane orientations is finite for finite-sided objects in 3D –How do you think you find them? Which planes are candidates? In 2D, separating lines –Which lines are candidates?

7 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Using Separating Axes Option 1: Use linear programming to find out if the point sets of the objects are linearly separable –Expensive, so not used Option 2: Use a projection and interval tests –For each potential separating axis, find the extents of the triangle along that axis In general case, same as projecting vertices onto a line and then taking max/min –Then look for overlap in the extents This test is slower than necessary for triangles, but it works great for boxes, as we will see later

8 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Separating Axes Example This one separatesThis one doesn’t

9 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin AABB-AABB (Recall: Axis Aligned Bounding Box) Two AABBs do not intersect if and only if Can be seen as a series of separating axes tests –Three potential separating axes are the x,y and z axes –Each row checks for separation along one of the axes There is also a positive version of the test, using “ands” –More like dimension reduction, which can be viewed as separating axis tests –Why use one over the other (in C++ at least)?

10 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin OBB-OBB (Oriented Bounding Box: Gottschalk, Lin, Manocha SIGGRAPH 96) The fast OBB-OBB test uses separating axes –There are 15 possible axes for two OBBs: 3 faces from each box, and 3x3 edge direction combinations The test projects the boxes onto each potential axis and looks for overlaps –Finding extents along the axis consists of some dot products and multiplications Many optimizations make the test possible in about 200 operations –Express one box’s axes in terms of the other’s –Re-use common sub-expressions –Shortcut degenerate cases

11 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin OBB Test OBB consists of three axes and three “radii” along those axes In all cases, assume that the separating axis in question has its origin at the center of one box For separating axes derived from faces, we also know that the axis is parallel to one of the box axes –Express the other box’s axes in terms of the first box (a rotation) –Terms disappear a1a1 a2a2 b1b1 b2b2 T D 2D test (3D has three axes per box):

12 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Algorithms for 3D Objects OBB-Tree –A hierarchy of OBBs –Reports all collisions between triangle soup Voronoi-Region Methods (Lin-Canny and V-Clip) –Only works for convex manifold objects, but extremely robust –Actually a closest features algorithm - gives closest features even if objects do not intersect –Closest features are useful for predicting future collisions GJK: Duality-based method heavily used for robotics –But not robust to special cases (esp. parallel faces) in my experience

13 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin OBB-Trees (Gottschalk, Lin, Manocha: SIGGRAPH 96) Represent an object (collection of triangles) with a hierarchy of OBBs –Leaves are triangles –Each box bounds its children Do collision testing between two objects by doing collision testing between two trees –Test two boxes, one from each tree. If they intersect, recursively test 4 combinations of child boxes (binary trees) –Start with root boxes, base case is triangle-triangle tests –Result is a list of triangle pairs that intersect Proof that a class project can go a long way

14 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Building the Trees Assume the objects are rigid, so the tree is built as a pre- processing step Tree is built top down: –Start with all the triangles, and put an OBB around them –Subdivide the box along the biggest dimension, classify triangles, and recurse on the two sets (just like building a BSP tree) –Child boxes don’t bear any specific relation to the parents – different orientations and sizes –Parents don’t even have to bound child boxes Basic operation is fitting an OBB to a collection of triangles…

15 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin OBB-Tree Construction

16 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Fitting OBBs The OBB fitting problem requires finding the orientation of the box that best fits the data Ideally, you want the minimum volume for the box, but that’s hard Instead, turn to an idea from statistics and AI (academic AI): principal components –Point sample the convex hull of the geometry to be bound –Find the mean and covariance matrix of the samples –The mean will be the center of the box –The eigenvectors of the covariance matrix are the principal directions – they are used for the axes of the box –The principle directions tend to align along the longest axis, then the next longest that is orthogonal, and then the other orthogonal axis

17 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Principle Components

18 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin OBB-Tree Evaluation OBB-Trees are the method of choice for unstructured geometry Important analysis: Cost of detection, for two phases, is N b C b +N n C n –Number of broad tests times cost of broad test + number of narrow tests times cost of each narrow test –C b and N n depend on broad phases scheme - –OBB-Tree is good at N n and not bad at C b, whereas AABB is good at C b but not so good at N n Biggest way to improve it would be to exploit coherence, but it is not clear how to do so Faster algorithms are restricted to more structured geometry … Available as RAPID (just OBB-Trees) and V-COLLIDE (OBB-Trees and dimension reduction broad phase)

19 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Closest Features Recall Voronoi regions and closest point problems –Find the closest point by finding out which Voronoi region the test point lies in Closest features algorithms find the shortest distance between two convex objects by first finding the closest features –The objects must be convex for the closest point to be uniquely defined –Convexity also makes greedy search sure to succeed –Closest features may be vertex-vertex, vertex-edge, vertex-face, edge-edge; other cases are degenerate (but must be handled) Key theorem: If f 1 is the closest feature on object 1, and f 2 is the closest feature on object 2, then f 1 lies in f 2 ’s Voronoi region and vice versa

20 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Lin-Canny Lin-Canny closest features uses the same walk through Voronoi regions that we saw for closest point computations Iterative procedure: –Start with previous closest features (exploit coherence) –Test each feature against other’s Voronoi region –If an error, walk to neighboring feature and repeat Only works for convex, polygonal, closed objects Voronoi regions are built as a pre-process, but not an expensive task, so could be done in real time Available as I-COLLIDE (along with a dimension reduction broad- phase and methods for managing hierarchies of convex objects)

21 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Lin-Canny Lin-Canny was originally proposed as an algorithm –The authors never implemented it!! It has problems with infinite looping under some cases, an inability to handle penetration, and general instability –The problem is in choosing which region to step to next –Historic note: Lin and Canny described the algorithm, but Mirtich was the first to implement it (Canny was the common thread)

22 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin V-Clip (Mirtich 98) V-Clip fixes the problems with Lin-Canny by rethinking the rules for transitioning from one region to the next –Uses derivative information to figure out which region to walk to next –Works in cases of penetration (detects it and returns negative distance) –In my experience, it has never crashed with valid input and always gives sensible output (every other closest point package has crashed for me) If you ever need it, I have an implementation that also does closest point –But it’s patented, so legally you cannot use it without a license from Mitsubishi Electric

23 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin V-Clip Analysis Very very fast if the conditions for using it can be met, particularly if coherence exists –Higher frame rates lead to greater coherence –Brief digression: the evil feedback loop for dynamics As frame time increases, the amount of work to compute each frame increases, increasing the frame time even more, … Can be very easily modified to handle affinely deforming objects It is really a primitive collision test - the primitives are convex rigid bodies –It can be used as the base case for algorithms like OBB-Trees –To my knowledge, no-one has tried using k-dop trees with V-Clip, or OBB- Trees with V-Clip as the primitive test

24 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Time-Critical Collision Detection Time-critical collision detection gives the best approximate answer it can in a fixed amount of time Sphere-Trees (Hubbard 96) use hierarchies of spheres to approximate objects –Lower levels of the hierarchy represent better and better approximations –Basically the volumetric equivalent of progressive LOD trees To do time-critical rendering, keep performing tests, working down the hierarchy, until you run out of time Report collisions if indicated by the most accurate tests performed In principle, could use any form of bounding volume hierarchy (OBBs in particular), but for some reason no-one has done it

25 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Final Project Stage Clean up your game and make it as good as you can You MUST have a functional game by the grading deadline –A game is not just an environment – it involves goals, success, enjoyment

26 11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Todo By Monday, Dec 1, Final goals By Wednesday, Dec 10, Final Demo Monday, Dec 15, Final Exam, 2:45 P.M


Download ppt "11/25/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Managing large numbers of objects Colliding spheres with things (spheres being common."

Similar presentations


Ads by Google