1 / 32

3 . 4. Contact Generation

3 . 4. Contact Generation. Generating contacts between rigid bodies. Contact Generation. Generating contacts between rigid bodies. Introduction to contact generation .

rich
Download Presentation

3 . 4. Contact Generation

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. 3.4.Contact Generation Generating contacts between rigid bodies

  2. Contact Generation Generating contacts between rigid bodies

  3. Introduction to contact generation A collision detection system may simply return the single point of maximum interpenetration if two objects are found to be in contact. Unfortunately, this does not provide adequate information to implement a realistic physics simulation, i.e. a collision between two objects may involve multiple points of contact (e.g. a car object resting on a surface). As such, the process of contact generation should produce a set of points of contact for each interpenetrating object pairing.

  4. Introduction to contact generation One box resting on top of another box will have a region (or patch) in direct contact. The contact patch can be of any shape (depending on the geometry of the touching objects). In order to simplify the process, a contact patch is typically simplified to a representative contact point or set of contact points. As such, a means of modelling a contact patch using a set of contact points is needed. The next slide shows one means of accomplishing this mapping (producing reasonable physical behaviour in most situations). Contact pair Single contact ● ● ● Collision detection Contact generation

  5. Common types of contact Edge-edge contact Point-face contact In most cases, the following collision detection algorithms will try to model a contact using either point-face or edge-edge contacts (primitives with curved surfaces will use some of the other cases). ● ● Face-face contacts Face-face collisions are needed when one or both contact faces are curved, otherwise, flat face-face contacts can be modelling using edge–edge and edge–face contacts. ●

  6. Common types of contact Point-edge contact Edge-face contact ● Point–point contacts and point–edge contacts can be effectively ignored as they are unlikely to occur and can be handled as a point-face contact. Point-point contact Edge–face contacts can often be replaced by a pair of edge–point contacts (except when the face is curved). ●

  7. Contact data Assuming the types of contact identified above, the following properties can be defined permitting the contact to be described: Colllision point – the representative point of contact (given interpenetrate any number of points might be selected – some arbitrary means of selecting a point is adopted, e.g. mid penetration point) Collision normal - direction in which an impact impulse will be applied between the two objects. By convention, the contact normal points from the first object involved toward the second. Penetration depth - amount that the two objects are interpenetrating measured along the direction of the collision normal passing through the collision point Contact normal Penetration depth ● Contact point

  8. Contact data: Point-Face Contacts Point–face contacts are the most common and important type of contact. The contact normal is given by the normal of the surface at the point of contact. The contact point is given as the point involved in the contact (if interpenetrating, the midway point between the object’s point and projected face point could be used) The penetration depth is calculated as the distance between the object point and the projected point. Contact normal Penetration depth ● Contact point

  9. Contact data: Edge-Edge Contacts Edge–edge contacts are the second most important type of contact and are used to model resting contacts between objects with flat or concave sides The contact normal is at right angles to the tangents of both edges (built using a cross product) The contact point is typically the closest point on one edge to the other (a point midway between both edges could also be used) The penetration depth is the distance between the two edges. Contact normal ● Contact point Penetration depth

  10. Contact data: Edge-Face Contacts Edge–face contacts are only used with curved surfaces (although the contact data is generated in a very similar way to point–face contacts) The contact normal is given by the normal of the face (the edge direction is ignored) The contact point is calculated as the point of deepest penetration geometrically. The penetration depth is the distance between the edge and the face along the direction of the normal passing through the contact point. Contact normal Penetration depth ● Contact point

  11. Contact data: Face-Face Contacts The contact normal is given by the normal of the first face. The contact point is calculated as the point of deepest penetration geometrically. If a point of deepest penetration cannot be readily obtained (e.g. two interpenetrating flat surfaces), an arbitrary point is selected. The penetration depth is the maximum distance between the two faces involved within the contact. Face–face contacts occur when a curved surface comes in contact with another face (either curved or flat). In this case, the contact data is more arbitrarily selected. Penetration depth Contact normal Contact point ●

  12. Coherence and Contact Generation The most efficient algorithms for calculating collision information between a pair of convex objects will typically terminate whenever the point of deepest interpenetration is found, i.e. a single contact is provided. Generating a complete set of contacts is considerably more difficult as a contact can be interpreted in different ways (e.g. a point-face contact could be interpreted as another point–face contact for a different face, with a different penetration depth). To generate a complete set of contacts, a means of interpretating and integrating points of contact is needed.

  13. Coherence and Contact Generation The problem of contact set generation can be (somewhat) avoided by introducing a degree of frame coherence and then simply generating a single contact (of maximum penetration), e.g.: consider two stacked boxes Frame 1: A single contact is generated and resolved in the normal manner. Frame 2: As only one point of contact was resolved, the boxes will likely re-interpenetrate but probably in a different way. This is detected as a new contact, providing two contacts which are resolved. Frame 3: A third point of contact is generated. We have three contacts which is sufficient to keep the boxes stacked in a stable manner. ● ● ● Frame 1: First contact Frame 2: Second contact

  14. Coherence and Contact Generation To take advantage of the coherence, we store the type of contact (e.g. point–edge or edge–edge) and which feature was involved for each object. If in the next frame, the same type of contact is generated (but with updated contact properties) that the stored contact can be updated. If a new type of contact has been detected, then it is added to the set of cached contacts. Contacts are removed from the set of cached contacts if the interpenetration depth is less than some fixed value (i.e. the contact has moved sufficient apart). • Aside: Typically a small negative value is used for the interpenetration distance, i.e. contacts that have only just separated are still maintained in the cache).

  15. Primitive Contact Generation Algorithms Generating contacts between rigid bodies

  16. Primitive Contact Generation Algorithms A contact generation algorithm generates contact information between pairs of potentially colliding primitives, returning zero, one or more contacts. Iterated over a set primitive pairings (e.g. as returned from some form of collision broad pass algorithm) a pool of contacts will be generated which can then be passed to the physics engine to be resolved. See the recommended course text book for details of contact generation given sphere-sphere, and sphere-plane primitives.

  17. Box-Plane Contact Generation This algorithm can return more than one contact. Only point-face contacts will be returned, i.e. rather than return a face-face contact, up to four point-face contacts will be returned (one for each corner point in contact with the plane/half-space). Likewise, an edge-face contact will be returned using two point-face contacts. ● ● ● ● ● ●

  18. Box-Plane Contact Generation Contacts are generated by checking for interpenetration of each box vertex against the plane, i.e. the vertex is in contact if (where p is the vertex location, n the plane normal and d the plane distance) foreach( Point p : box.Vertices ) { float d = dot( p, plane.n ); if( d < plane.d + ε ) { contact.Point = p + plane.n * (d - plane.d); contact.Normal = plane.n; contact.Penetration = plane.d – d; } } Determine the vertex-plane distance An epsilon value might be introduced to cover resting contacts Generate contact information, assuming the contact point is midway between the vertex and plane.

  19. Sphere-Box Contact Generation A sphere-box collision will result in a single contact, although the contact type can differ (face-face, edge-face, or point-face). All three types of contact can be tested/constructed using the same approach (assuming that the collision normal is from the perspective of the sphere), as follows: Find the closest point on the box (OBB) to the centre of the sphere (as outlined within an earlier lecture). The closest point may be in a box corner, edge or face. If the closest box point to sphere centre distance is less than the sphere radius then generate contact information. ● ● ●

  20. Box-Box Contact Generation Generating box-to-box contacts is notably more complex than the previous generation algorithms; however, the technique employed behind box-to-box contact generation is similar to that for any pair of concave shapes.

  21. Type of Box-Box Contacts Point-edge contact There are six possible types of contact between two boxes Edge-face contact Point-face contact ● Edge-edge contact Point-point contact ● ● Face-face contact ●

  22. Type of Box-Box Contacts: Simplification Face-face and edge-face contacts can be represented using a number of point-face or edge-edge contacts. The point–point and point–edge contacts do not have any obvious means of determining a contact normal, additionally these forms of contact are very unlikely to occur. As such, they can be safely ignored (and will result in a point-face or edge-face contact). Face-face contact ● ● ● ● Edge-face contact • Aside: Modelling a face-face (or edge-face) contact using a single contact (assuming the definition above) will likely not be stable. Multiple contacts, whilst increasing computation, also increase stability. ● ●

  23. Box-Box Contact Generation In order to generate contacts between two boxes the following steps are used: Use a separating axis test along each possible separating axis as a means of providing an early out for non-collision or to determine the axis of greatest interpenetration. Generate a contact for the point of greatest interpenetration. Use the notion of contact coherence, to combine the contact with previously detected contacts to update/extend the set of box-box contacts.

  24. Box-Box Contacts: Separating axes The separating axis test can be performed for two boxes by projecting the half-size of the box onto the separating axis, i.e.: boolFindPenetrationOnAxis ( Box one, Box two, Vector3 axis ) { float oneProj = TransformToAxis(one, axis); float twoProj = TransformToAxis(two, axis); Vector3 centre = two.Centre - one.Centre; float distance = Math.Abs( Dot( center, axis) ); return (distance < oneProj + twoProj); } Project the half-size of each box onto the axis Determine the midpoint between the boxes and project this onto the axis Return true if the projected half-widths overlap ● ● Return the accumulated projection of each box axis onto the separating axis ● float TransformToAxis(Box box, Vector3 axis) { return box.HalfSizeX * Math.Abs( Dot( axis, box.AxisX ) ) + box.HalfSizeY * Math.Abs( Dot( axis, box.AxisY ) ) + box.HalfSizeZ * Math.Abs( Dot( axis, box.AxisZ ) ); }

  25. Box-Box Contacts: Separating axes test A total of 15 different axes must be tested (to confirm interpenetration), these include: The three principal axes of each box The nine axes which are perpendicular to each pair of principal axes from each box Aside: The nine perpendicular axis are formed by taking the cross product of each pairing of principle axes

  26. Box-Box Contacts: Building a contact Once the point of deepest interpenetration has been found it is necessary to interpret this point in terms of a particular type of contact. This is a complex problem to solve for general polyhedral. A workable approach for box-to-box contacts is to simply (and exhaustively) check for each possible type of point-face and edge-edge contact. If the point of deepest interpenetration is: Along one of the principles axis of a box, then it is a point-face contact, Along a perpendicular axis, then it is an edge-edge contact As only a single contact is returned, if more than one contact is found within the search, then the contact that has the greatest interpenetration is returned. Aside: A range of more efficient and more complex algorithms exist for general polyhedral (such as GJK or V-Clip) – see directed reading.

  27. Box-Box Contacts: Point-Face A point-face contact uses the same approach as for a sphere-box collision (but assuming a zero-radius sphere). Each vertex from one box is projected onto the principal axes of the other. If the vertex is inside the box, then a point–face collision is required. If the vertex is inside the box on more than one axis, then the axis with the shallowest penetration is used.

  28. Box-Box Contacts: Point-Face Vector3 relPoint = box.TransformToLocal(point); Vector3 normal; float minDepth = box.HalfSizeX – Math.Abs(relPoint.X); if (min_depth < 0) return; normal = box.AxisX * ((relPoint.x < 0)?-1:1); float depth = box.HalfSizeY – Math.Abs(relPoint.Y); if (depth < 0) return; else if (depth < min_depth) { min_depth = depth; normal = box.AxisY * ((relPoint.Y < 0)?-1:1); } depth = box.HalfSizeZ – Math.Abs(relPoint.Z); if (depth < 0) return 0; else if (depth < min_depth) { min_depth = depth; normal = box. AxisZ * ((relPoint.Z < 0)?-1:1); } Ensure the point is expressed in the box’s local space Determine the axis of least (positive) penetration The collision normal will be constructed to be stored within the contact Build the contact using the determined point, normal and interpenetration depth

  29. Box-Box Contacts: Edge-Edge Each edge from one object is checked against the edges of the other object. This is accomplished by: Consider each edge of object A. Work out its interpenetration with each edge of object B. The shallowest interpenetration of an edge from A is the interpenetration of the edge. The edge from object A with the deepest interpenetration is retained.

  30. Directed reading Directed Reading Directed physics reading

  31. Directed reading Read Chapter 13 of Game Physics Engine Development (pp263-297) on rotations. Read Chapter 9 of Real Time Collision Detection (pp383-412) on convexity based methods of intersection. Directed reading

  32. Summary Today we explored: • How to model different forms of contact • Means of generating contacts between rigid body primitives To do: • Read the directed reading. • Consider if you might wish to develop your own physics engine as your project.

More Related