algorithm to detect cube intersection

Software: Away3D 3.x

mole, Newbie
Posted: 04 October 2011 12:40 PM   Total Posts: 29

I need to be able to detect the intersection of 2 Away 3D cubes.
I tried to do this using jigLib, I don’t need physics and the way jigLib works doesn’t help me any further.
I have 2 cubes, they are rotated, and their pivot point is moved. I need a way to quickly detect if these cubes intersect.
Can anyone point me in the correct direction? Is there an easy way to do this?

   

Stephen Hopkins, Sr. Member
Posted: 09 October 2011 01:39 AM   Total Posts: 110   [ # 1 ]

What you are looking for is called OBB-OBB intersection. You may be able to find some code here http://www.realtimerendering.com/intersections.html

or just google oriented bounding box intersection for the general algorithm. If their pivot point is moved, you are gonna have to transform your cubes vertices to get them in the same coordinate space.

 Signature 

http://www-scf.usc.edu/~shopkins

   

Avatar
Alejandro Santander, Administrator
Posted: 09 October 2011 06:34 AM   Total Posts: 414   [ # 2 ]

That’s right. To detect oriented bounding box intersections you can use the method of the separating axis. Compare vertices of cube A onto face normals of cube B by finding the projection of “aVertexOfFaceBToAVertexOfCubeA” onto “theNormalOfFaceB”. If you find any of such projections to be positive (i.e. aVertexOfCubeA being in front of B’s face under analysis), you’ve found a separating axis on both cubes and hence a collision cannot occur. If you test all posibilities and do not find a separating axis, you’ve detected a collision.

It is all clearly explained in David Eberly’s paper “Intersection of Convex Objects: The Method of Separating Axes” which I’m sure you’ll be able to find in the internet. It even explains how to resolve such collisions.

Otherwise, I am certain you can use AwayPhysics for detection by creating 2 rigid bodies and setting their flags to not resolve collisions and be notified when the event occurs.

hth

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X