DanEE 122 Report post Posted May 24, 2007 Hello all! For a game I'm programming I would need the collison normal of a bounding-sphere with an Axis-aligned Bounding Box. The collision normal should be a simple vector (Up, Down, Left, etc...) in the case of a collision of the sphere with a face of the AABB or a more exact normal if the sphere collides with an edge or even a simple point. Now I can't find any resources in the net for this particular problem. I don't even know how I could check if the sphere collides only with an edge or a point. Could you guide me to the right direction? 0 Share this post Link to post Share on other sites
gammaGT 122 Report post Posted May 24, 2007 What Intersection algorithm do you use? In case you perform a triangle intersection check, you're likely to receive the barycentric coordinates of the point on the triangle. Use them to compute the point of intersection and getyour collision normal with "collisionNormal = Sphere.Center - PointOfIntersection"... You might want to normalize it though.That's all I can say with what you've posted so far.Good luck!Martin<edit> Do you want to take movement into account?</edit> 0 Share this post Link to post Share on other sites
johnb 351 Report post Posted May 24, 2007 The collision normal of a sphere with anything is always along a line from the centre of the sphere to the contact point - along a radius.As for whether it collides with a corner, edge or face this is determined by the location of the sphere's centre. One way of looking at it is as follows:Suppose the box is defined by x1 < x < x2y1 < y < y2z1 < z < z2and the sphere is at (X, Y, Z)Simply count how many of the following are truex1 < X < x2y1 < Y < y2z1 < Z < z2If none are true the sphere hits a corner. If one is true the sphere hits an edge. If two are true the sphere hits a face (if three are true the sphere is inside the box, which is case you probably want to exclude).More formally the planes x = x1, x = x2 etc. divide the space into Voronoi regions, of which this is an application. You can work them out for other polygonal bodies, though the maths quickly gets a lot more complicated. 0 Share this post Link to post Share on other sites