Original Post
Hi.
Im currently writing an FPS. I allready have a working level and collisions between the player and the floor/walls work fine. I Test the players collision box with the floors/walls collision boxes using this simple logic.
But that obviously doesnt work if i need to test the players collision box against a rotated collision box like for example a ramp.
I can calculate the coordinates of the 8 corners of the rotated colision box in world space but how would i determine if it intersects with the players colision box. Its a givin that the players collision box will never be rotated for incase that helps.
Any help appreciated. Thnx in Advance!
Im currently writing an FPS. I allready have a working level and collisions between the player and the floor/walls work fine. I Test the players collision box with the floors/walls collision boxes using this simple logic.
boolean valueInRange(float value, float min, float max)
{ return (value >= min) && (value <= max); }
boolean rectOverlap(Rect A, Rect B)
{
boolean xOverlap = valueInRange(A.x, B.x, B.x + B.width) ||
valueInRange(B.x, A.x, A.x + A.width);
boolean yOverlap = valueInRange(A.y, B.y, B.y + B.height) ||
valueInRange(B.y, A.y, A.y + A.height);
boolean zOverlap = valueInRange(A.z, B.z, B.z + B.depth) ||
valueInRange(B.z, A.z, A.z + A.depth);
return xOverlap && yOverlap && zOverlap;
}
But that obviously doesnt work if i need to test the players collision box against a rotated collision box like for example a ramp.
I can calculate the coordinates of the 8 corners of the rotated colision box in world space but how would i determine if it intersects with the players colision box. Its a givin that the players collision box will never be rotated for incase that helps.
Any help appreciated. Thnx in Advance!