Simple AABB colision through items in array…

Software: Away3D 4.x

Mr Margaret Scratcher, Sr. Member
Posted: 13 September 2012 11:44 AM   Total Posts: 344

Getting a bit stuck with this.. Basically, I have a a project which allows me to add a number of items to a scene and drag them to re-arrange.

I have a

if (itemDragging)
   
{
    _drag3D
.updateDrag();
    
checkCollision();
    
currentDragObject.position previousDragPos;
    
   

and then

private function checkCollision():void 
  {
   
var testCount:uint  = new uint;
   
testCount 1;
   for (var 
i:uint =0currentItemArray.lengthi++)
   
{
    
      
var testItem currentItemArray[i].virtualItem.extra.collisionCube;
      
//var testItem = cube;
     
     //Dragmesh detects collisions
     
if  (AABBTest(testItemcurrentDragMesh))
     
{
     
//trace ("object collides with object at ["+i+"]");
     
trace ("testCounts is " testCount);
     
     
}
      
else {
       trace 
("No collision: AABB test = " AABBTest(testItemcurrentDragMesh)); 
       
       
testCount += 1;
       
trace ("testCounts is " testCount);
       
       
}
    
       
if (testCount == currentItemArray.length)
       
{
        previousDragPos 
currentDragObject.position;
       
}
   }
  } 

But strangely it only seems to detec collision on certain sides..

Is there a more elegant way of cycling through items on screen and checking to see if they intersect?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X