1 / 21

CS361

Week 13 - Friday. CS361. Last time. What did we talk about last time? Ray/sphere intersection Ray/box intersection Slabs method Line segment/box overlap test Ray/triangle intersection Ray/polygon intersection. Questions?. Assignment 5. Project 4. Plane/box intersection.

svein
Télécharger la présentation

CS361

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. Week 13 - Friday CS361

  2. Last time • What did we talk about last time? • Ray/sphere intersection • Ray/box intersection • Slabs method • Line segment/box overlap test • Ray/triangle intersection • Ray/polygon intersection

  3. Questions?

  4. Assignment 5

  5. Project 4

  6. Plane/box intersection • Simplest idea: Plug all the vertices of the box into the plane equation n • x + d = 0 • If you get positive and negative values, then the box is above and below the plane, intersection! • There are more efficient ways that can be done by projecting the box onto the plane

  7. BV/BV intersection • Seeing if bounding volumes collide is a fundamental part of most collision detection algorithms • Does this ship hit that asteroid? • Bounding volumes are often arranged in hierarchies of bounding volumes • Bounding volumes allow for easy reject cases

  8. Sphere/sphere intersection • Sphere/sphere is the easiest • Is the distance between their centers bigger than the sum of their radii? • If yes, they are disjoint • If no, they overlap r2 r1 c2 c1

  9. Sphere/box intersection • Remember that an AABB is defined by two points, amin and amax • We go through each axis (x, y, and z) and first check to see if we can reject based on distance on that axis being too large • If not, we add the squared axis's distance to the total • If you want to do a sphere/OBB intersection, transform the sphere's center into the axes of the OBB and then the OBB will be an AABB

  10. Sphere/box pseudocode intersect( c, r, A ) { d = 0 for i in x,y,z if( (e = ci – aimin) < 0 ) if( e < -r ) return DISJOINT d = d + e2 else if ( (e = ci – aimax) > 0 ) if( e > r ) return DISJOINT d = d + e2 if ( d > r2 ) return DISJOINT return OVERLAP }

  11. AABB/AABB intersection • We test each dimension to see if the min of one box is greater than the max of the other or vice versa • If that's ever true, they're disjoint • If it's never true, they overlap intersect(A, B ) { for i in x,y,z • if(aimin > bimax or bimin > aimax ) return DISJOINT return OVERLAP }

  12. k-DOP/k-DOP intersection • Note that an AABB is a special case of a 6-DOP • We can apply the same test as for an AABB, looking at the mins and maxes of each slab • Because the axes of a k-DOP are not necessarily orthogonal, this test is inexact (unlike for the AABB) • It is conservative: Some disjoint k-DOPs will report that they overlap, but overlapping k-DOPs will never report disjoint intersect(A, B ) { for i in 1 … k/2 • if(diA,min > diB,max or diB,min > diA,max ) return DISJOINT return OVERLAP }

  13. OBB/OBB intersection • Again, an OBB is surprisingly complex • The fastest way found involves the separating axis test • There are 15 different axes you've got to test for overlap before you can be sure that the boxes overlap • When all the math is worked out, the test is quite fast

  14. View frustum intersection • Because anything visible on the screen will be in the view frustum, we can save time by ignoring objects that are not • Remember that the frustum is defined by 6 planes: near, far, left, right, top and bottom • When test the frustum against bounding volumes, we will want three answers: outside, inside, and intersect

  15. Frustum planes • To test frustum intersection, it is necessary to know the plane equations for each of the six frustum planes • If the view matrix is V and the projection matrix is P, the final transform is M = PV • If mi means the ith row of M, the equations for each plane are as follows: • -(m3 + m0) • (x, y, z, 1) = 0 (left) • -(m3 – m0) • (x, y, z, 1) = 0 (right) • -(m3 + m1) • (x, y, z, 1) = 0 (bottom) • -(m3 – m1) • (x, y, z, 1) = 0 (top) • -(m3 + m2) • (x, y, z, 1) = 0 (near) • -(m3 – m2) • (x, y, z, 1) = 0 (far)

  16. Frustum/sphere intersection • We take the center of the sphere p and plug it into each of the plane equations, getting signed distance values • Note that the normals of the planes point outwards • If the distance to any given plane is greater than radius r, the sphere is outside the frustum • If the distances to all six planes are less than –r, the sphere is inside • Otherwise, the sphere intersects • This test is conservative: Reports some outside spheres as intersections

  17. Frustum/box intersection • We skipped over the section that says how to test a plane for intersection with a box, but it's a simple calculation • To do frustum/AABB intersection, we test the AABB against every plane of the frustum • If the box is outside any plane, we return outside • If the box is not outside any plane but intersects some plane, we return intersects • Otherwise, we return inside

  18. Line/line intersection • We will only look at the 2D problem, but the book has discussion of 3D lines as well • For a 2D vector (x, y), we define its perp dot product (x, y) = (-y, x) • Thus, we can work through the equations of a line (only the path to the value of s is shown) • r1(s) = r2(t) • o1 + sd1 = o2 + td2 • sd1 • d2 = (o2 – o1) • d2 • s = ((o2 – o1) • d2) / d1 • d2

  19. Upcoming

  20. Next time… • Collision detection

  21. Reminders • Keep working on Project 4 • Start Assignment 5 • Read Chapter 17

More Related