Collision Detection - Find which side of a cube is face up

Software: Away3D 4.x

madmicra, Newbie
Posted: 22 May 2015 02:22 PM   Total Posts: 1

Ok, so having scoured the web and here. I’ve not found much of use and don’t expect to get much in the way of response here, certainly of any use anyways, no offence.

So I’m using Away 3D 4.1.6 and Away Physics to create a dice roll off a back wall of a large box/basin shape. I’ve been able to create a lovely natural looking roll. What I’m struggling with is finding which face is face up after it has stopped rolling.

I’ve seen the jiglib tutorial here
which has a supposed solution in it’s comments but this is no help since jiglib has not been updated to work with Away 3D 4.1.6 only the original Away 3D 4 before the way the primitives creation was changed and I need it use the most recent version.

I’ve also seen this function below on many a page here but it’s not accurate as you can have more than one vector at above 0.5 at times, meaning it gives which ever one was called first and not necessarily the right one. I did try to modify it to make it more accurate but still ended up with something inaccurate.

if (Math.abs (diceRb.up.y) >0.5)
   
{
    
if (diceRb.up.0)
    
{
     rollResult 
1;
    
}
    
else
    
{
     rollResult 
6;
    
}
   }
   
if (Math.abs (diceRb.front.y) >0.5)
   
{
    
if (diceRb.front.0)
    
{
     rollResult 
3;
    
}
    
else
    
{
     rollResult 
4;
    
}
   }
   
if (Math.abs (diceRb.right.y) >0.5)
   
{
    
if (diceRb.right.0)
    
{
     rollResult 
5;
    
}
    
else
    
{
     rollResult 
2;
    
}
   } 

I’ve also tried to use rays on each side of my cube and try to detect whether they are intersecting with the floor object once it has stopped but I get the result that they all are so I must be doing something incorrectly when checking intersection.

Surely someone has figured this out? But it seems to be a common question and no obvious solution shown. Accuracy is of high importance here. Does anyone have any ideas about this in the current version of Away 3D and Away Physics. Anything I have found has related to older versions. Also given that there is no documentation for the physics part this is getting kinda difficult.

I feel there should be a simple enough solution and I should be able to use the up/right/front vector to get the correct face but I’ve found no method that is 100% accurate. If anyone can point me in a better direction please say. I’ve studied the tutorials but none have them really have enough information in them that match what I wish to do.

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X