minardogl 122 Report post Posted November 9, 2006 I´m computing the collision between a moving sphere and a mesh. I´m using OpCode, so I use a capsule (LSS) to represent the sphere movement. Opcode returns me the list of triangles collisioning with the capsule. But beside the triangles, I also need the collision point where the capsule collides so I be able move the sphere to that point. Opcode, just give me the triangle indices. I can extract the vertices of that triangle. Computing the collision normal is fairly simple, But how could I compute the collision point between the capsule (LSS) and the triangle? 0 Share this post Link to post Share on other sites
Dim_Yimma_H 557 Report post Posted November 10, 2006 Getting the exact collision point/time of collision can be fairly complicated if using collision detection algorithms that only tests for overlapping geometry.One way to get a good enough time of collision for arbitrary moving geometries is by using a binary search between the time before collision t_{1}, and the time after collision t_{2}. If a collision is detected during this time the time of movement t_{m} is subdivided, for example t_{m} = (t_{2} - t_{1}) / 2.The simulation is then re-run from t_{1} to t_{1} + t_{m}. If collision is not detected then t_{1} + t_{m} is the "closest" time before collision. If collision is detected then t_{1} + t_{m} is the "closest" time after collision. This is repeated until t_{m} is small enough. The point before collision is then approximated using velocity and t_{m}.Here's a link to a document that explains this: http://www.cescg.org/CESCG-2003/LKavan/index.html, see "Time of Contact".There are other more specialized ways though. It's a good idea to use a capsule for sphere-mesh collision query, that tells that there is a collision. Since the sphere center is always offset from a triangle by its radius at the exact time of collision, the exact time is possible to find for a sphere. Offset the triangle by the sphere radius along the triangle normal, then perform a ray-triangle intersection test. That intersection is the center of the sphere at the time of collision.I don't know if OPCODE can find the intersection point though, maybe you'll have to code the ray-triangle test yourself. Here's a reference for that: http://softsurfer.com/Archive/algorithm_0105/algorithm_0105.htm, see "Ray/Segment-Triangle Intersection". If several triangles are overlapped by the capsule, remember to find the closest intersection point. 0 Share this post Link to post Share on other sites