I have a 3d moving box an开发者_JS百科d a stationary box. I can detect collisions ok but now I would like to slide the moving box against the stationary box as a collision response. For this I need the normal of the face that collides with the moving box. Does anyone know how I figure this out? It doesn't seem like the collision test gives me this information. Any help is appreciated.
The normal of the face is equal to the cross product between the vectors of two of the connecting edges of all the edges which are adjacent to the face.
Let a,b and c be position vectors of 3 of the 4 points around the face:
//edge a<->b
Vector3f ab = b-a;
//edge b<->c
Vector3f bc = c-b;
//normal of the face
Vector3f normal = Vector3.cross_product(ab,bc);
If you don't know what the cross product between two three-dimensional vectors is, you can look here: http://en.wikipedia.org/wiki/Cross_product
精彩评论