• Advertisement
Sign in to follow this  

AABB-AABB collision normal ( SOLVED )

This topic is 1963 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, i don't think i will ever invent that so i better ask before spending another days looking for something related to the problem...
SOLUTION FOUND HERE: http://www.gamedev.net/topic/567310-platform-game-collision-detection/


My game uses AABB's for collision detection, and i check objects for collision with:

[source lang="cpp"]
int CBoundingBox::classify(const CBoundingBox& rOther)
{
if( rOther.min.x >= min.x && rOther.max.x <= max.x &&
rOther.min.y >= min.y && rOther.max.y <= max.y &&
rOther.min.z >= min.z && rOther.max.z <= max.z )
{
return INSIDE;
}

if( max.x < rOther.min.x || min.x > rOther.max.x )
return OUTSIDE;
if( max.y < rOther.min.y || min.y > rOther.max.y )
return OUTSIDE;
if( max.z < rOther.min.z || min.z > rOther.max.z )
return OUTSIDE;

return INTERSECTS;

}
CVector3 CBoundingBox::closestPointOn(const CVector3& vPoint)
{
CVector3 xClosestPoint;
xClosestPoint.x = (vPoint.x < min.x)? min.x : (vPoint.x > max.x)? max.x : vPoint.x;
xClosestPoint.y = (vPoint.y < min.y)? min.y : (vPoint.y > max.y)? max.y : vPoint.y;
xClosestPoint.z = (vPoint.z < min.z)? min.z : (vPoint.z > max.z)? max.z : vPoint.z;
return xClosestPoint;
}



bool CBoundingBox::hasCollided(const CBoundingBox& rOther) const
{
if( min.x > rOther.max.x ) return false;
if( max.x < rOther.min.x ) return false;
if( min.y > rOther.max.y ) return false;
if( max.y < rOther.min.y ) return false;
if( min.z > rOther.max.z ) return false;
if( max.z < rOther.min.z ) return false;

return true;
}[/source]

That works perfectly fine but i need to implement sliding with AABB's so i will need to find out collision normal between AABB1 colliding with AABB2.


Can somebody *please* help me out with this and show me how do i calculate a collision normal between two AABBs ( the normal of the face of the AABB that the player is colliding with ) / find colliding AABB faces ? Edited by xynapse

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement