1 / 159

Detekcija trkov

Detekcija trkov. Pomen detekcije trkov. Especially important in Interactive Virtual Environments . No matter how good the VE look, the poor realism resulting from a lack of collision detection. However, there may be hundreds, even thousands of objects in the virtual world.

cole
Télécharger la présentation

Detekcija trkov

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. Detekcija trkov

  2. Pomen detekcije trkov • Especially important in Interactive Virtual Environments. • No matter how good the VE look, the poor realism resulting from a lack of collision detection. • However, there may be hundreds, even thousands of objects in the virtual world.

  3. Pomen detekcije trkov

  4. Uvod

  5. Kaj je odkrivanje trkov? • Entities occupy, partially or fully, the same location at the same time. • We term the above scenario a collision. • Collision leads to event(s) in most cases – • Bullet hitting a box of grenades causing the event of explosion and possibly other events (e.g., reduction of life force for players stood near the grenades at time of explosion). • However, this is not the full story – • Ideally we should foresee collision as immanent and time our event to occur at a deterministic point in time (true collision). • Q: How is this achieved while still maintaining performance? • A: With great difficulty when performance permits.

  6. Trki

  7. Odkrivanje trkov • Essential for many games • Shooting • Kicking, punching, beating, whacking, smashing, hitting, chopping, dicing, slicing, julienne fries… • Car crashes • Expensive • tests!! Demo

  8. Problem N teles

  9. Različne vrste teles, ki trkajo

  10. Uporaba odkrivanja trkov • Determining if the player or character has a hit a wall or obstacle • To stop them walking through it • Determining if a projectile (missile) has hit a target • Detecting points at which behavior should change • A car in the air returning to the ground • Cleaning up animation • Making sure a character’s feet do not pass through the floor • Simulating motion of some form • E.g. cloth, or something else

  11. Odkrivanje trkov • Collision detection, as used in the games community, usually means intersection detection of any form • Intersection detection is the general problem: find out if two geometric entities intersect – typically a static problem • Interference detection is the term used in the solid modeling literature – typically a static problem • Collision detection in the research literature generally refers to a dynamic problem – find out if and when moving objects collide • Subtle point: Collision detection is about the algorithms for finding collisions in time as much as space

  12. Terminologija Convex Concave Non-Manifold Manifold An object is convex if for every pair of points inside the object, the line joining them is also inside the object An surface is manifold if every point on it is homeomorphic to a disk. Roughly, every edge has two faces joining it

  13. Izbira algoritma • The geometry of the colliding objects is the primary factor in choosing a collision detection algorithm • “Object” could be a point, or line segment • Object could be specific shape: a sphere, a triangle, a cube, … • Objects can be concave/convex, solid/hollow, deformable/rigid • The way in which objects move is a second factor • Different algorithms for fast or slow moving objects • Different algorithms depending on how frequently the object must be updated • Of course, speed, simplicity, robustness are all other factors

  14. Strategije odkrivanja trkov • There are several principles that should be considered when designing a collision detection strategy • What might they be? • Say you have more than one test available, with different costs. How do you combine them? • How do you avoid unnecessary tests? • How do you make tests cheaper?

  15. Strategije odkrivanja trkov • There are several principles that should be considered when designing a collision detection strategy • Fast simple tests first to eliminate many potential collisions • e.g.: Test bounding volumes before testing individual triangles • Exploit locality to eliminate many potential collisions • e.g.: Use cell structures to avoid considering distant objects • Use as much information as possible about the geometry • e.g.: Spheres have special properties that speed collision testing • Exploit coherence between successive tests • Things don’t typically change much between two frames

  16. Robustnost • For our purposes, collision detection code is robust if it: • Doesn’t crash or infinite loop on any case that might occur • Better if it doesn’t crash on any case at all, even if the case is supposed to be “impossible” • Always gives some answer that is meaningful, or explicitly reports that it cannot give an answer • Can handle many forms of geometry • Can detect problems with the input geometry, particularly if that geometry is supposed to meet some conditions (such as convexity) • Robustness is remarkably hard to obtain

  17. Odkrivanje trkov • Efficiency hacks/cheats • Fewer tests: Exploit spatial coherence • Use bounding boxes/spheres • Hierarchies of bounding boxes/spheres

  18. Tipi geometrije • Points • Lines, Rays and Line Segments • Spheres, Cylinders and Cones • Cubes, rectilinear boxes - Axis aligned or arbitrarily aligned • AABB: Axis aligned bounding box • OBB: Oriented bounding box • k-dops – shapes bounded by planes at fixed orientations • Convex, manifold meshes – any mesh can be triangulated • Concave meshes can be broken into convex chunks, by hand • Triangle soup • More general curved surfaces, but not used (often) in games AABB OBB 8-dop

  19. Collision Detection using Bounding Spheres (Boxes) • If the bounding spheres (boxes) of two objects don’t intersect, there is no collision between the two object. • How to determine the intersection between spheres / boxes? • If the bounding volumes intersect, there may be collision between the objects. • However, there may still be no collision. • Tight bounds performs better. We may treat two objects collided if the bounds are tight and intersect. • Not every object has a good bounding sphere (box), e.g. planes.

  20. Primeri obsegajočih volumnov

  21. Primeri obsegajočih volumnov

  22. Obsegajoča krogla in kvader • Bounding sphere: the minimum sphere enclosing the object. • You may need to find the center of the object and the radius of the sphere. (can be done in the modeling phase) • Not accurate in may cases. But can be used as initial test before applying more complicated algorithms. • Not a good fit for narrow or long objects • Bounding box (axis-aligned): the minimum and maximum coordinates of the object in x, y, z directions • Not transform-invariant. Need to be recomputed after a transformation, e.g. rotation. • Can fit odd shaped objects better

  23. Obsegajoči kvader (bounding box) • Place a box around an object • Box should completely enclose the object and be of minimal volume • Fairly simple to construct • Test intersections between the boxes to find intersections • Each box has 6 faces (planes) in 3D • Simple algebra to test for intersections between planes • If one of the planes intersects another, the objects are said to collide

  24. Obsegajoči kvader • Space complexity • Each object must store 8 points representing the bounding box • Therefore, space is O(8) and Ω(8) • Time complexity • Each face of each object must be tested against each face of each other object • Therefore, O((6n)2) = O(n2) • n is the number of objects

  25. Obsegajoči kvader • Pro • Very easy to implement • Very little extra space needed • Con • Very coarse detection • Very slow with many objects in the scene

  26. Obsegajoče krogle (Bounding Spheres) • Similar to bounding boxes, but instead we use spheres • Must decide on a “center” point for the object that minimizes the radius • Can be tough to find such a sphere that minimizes in all directions • Spheres could leave a lot of extra space around the object!

  27. Obsegajoče krogle • Each sphere has a center point and a radius • Can build an equation for the circle • Simple algebra to test for intersection between the two circles

  28. Obsegajoče krogle • Space complexity • Each object must store 2 values - center and radius - to represent the sphere • Therefore, space is O(2) and Ω(2) • Space is slightly less than bounding boxes • Time complexity • Each object must test it’s bounding sphere for intersection with each other bounding sphere in the scene • Therefore, O(n2) • n is the number of objects • Significantly fewer calculations than bounding boxes!

  29. Obsegajoče krogle • Pro • Even easier to implement (than bounding boxes) • Even less space needed (than bounding boxes) • Con • Still fairly coarse detection • Still fairly slow with many objects

  30. Poravnani obsegajoči kvadri (Aligned Bounding Boxes) • Axis-aligned vs. Object-aligned • Axis-aligned BBox change as object moves • Approximate by rotating BBox Swept volume

  31. Oriented Bounding Boxes (OBBs) • These are more difficult to implement and result in greater effort to achieve collision detection. However, the collision detection is more accurate than AABBs. • Furthermore, because the OBBs are expected to “fit” more tightly around an entity the tree structure is expected to be much reduced over that of AABBs. • Checking for OBBs that are collided means ensuring that no separating axis exist (same as AABBs). However, in 3D there are 15 potential axes. Furthermore, the axes do not lie trivially on regular planes (X, Y, Z) but must be deduced from the orientation of the OBBs involved. • Handling OBBs in three dimensions are beyond the scope of this course. • AABBs are adequate for our purposes.

  32. Hierarhije obsegajočih volumnov

  33. Izgradnja hierarhije

  34. Hierarhije za trdna telesa

  35. Optimization Structures • BV, BVH (bounding volume hierarchies) • Octree • KD tree • BSP (binary separating planes) • OBB tree (oriented bounding boxes- a popular form of BVH) • K-dop • Uniform grid

  36. Testing BVH’s TestBVH(A,B) { if(not overlap(ABV, BBV) return FALSE; else if(isLeaf(A)) { if(isLeaf(B)) { for each triangle pair (Ta,Tb) if(overlap(Ta,Tb)) AddIntersectionToList(); } else { for each child Cb of B TestBVH(A,Cb); } } else { for each child Ca of A TestBVH(Ca,B) } }

  37. Bounding Volume Hierarchies

  38. Octrees

  39. KD Trees

  40. BSP Trees

  41. OBB Trees

More Related