View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# AABB-AABB collision normal ( SOLVED )

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

No replies to this topic

### #1xynapse  Members

Posted 08 September 2012 - 02:36 PM

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, 08 September 2012 - 03:43 PM.

perfection.is.the.key

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.