Update object bounds with scene position/rotation..

Software: Away3D 4.x

Mr Margaret Scratcher, Sr. Member
Posted: 06 September 2012 02:27 PM   Total Posts: 344

Hi there, I’m going a bit of simple collision detection, and having difficulty when I rotate objects, namely that that the bounds stay in the same postition as if the object had not been rotated.

I know that this is due to the bounds’ location being local, as opposed to the global/scene position of the objects I’m testing for collision against - currently I have the bounds.min.x etc plus the parentOC3D.x which give me a real world position of the bound, it’s just the rotation which is puzzling me.

I tried rotating the mesh itself, rather than its parent OCD, but I get the same result…

Is there a way to ‘apply’ the rotation to the mesh, and thereby recalculate the bounding box?

Luckily, my objects are only going to be rotated by 90 degrees at a time, and around the y axis, so I could add in some of conditionals which swap the calculations around, I guess…

   

Mr Margaret Scratcher, Sr. Member
Posted: 06 September 2012 03:30 PM   Total Posts: 344   [ # 1 ]

Hmm…. I’ve just implemented a workaround based on the parent’s rotation, only to find that my button to rotate the opposite direction does seem to rotate the bounds too…

Looks like it could be a silly mistake somewhere on my part…

Not like me is it? smile

   

Mr Margaret Scratcher, Sr. Member
Posted: 06 September 2012 03:37 PM   Total Posts: 344   [ # 2 ]

Ah, it was because I was using this to swap the bounds:

//Compensate for rotation:
    
if (currentDragObject.rotationY == || currentDragMesh.rotationY == 180)
     
{
     
var meshMaxZ:Number currentDragMesh.bounds.max.z
     
var meshMinZ:Number currentDragMesh.bounds.min.z
     
var meshMaxX:Number currentDragMesh.bounds.max.x
     
var meshMinX:Number currentDragMesh.bounds.min.x
     }
     
    
if (currentDragObject.rotationY == 90 || currentDragMesh.rotationY == 270)
     
{
     
var meshMaxZ:Number currentDragMesh.bounds.max.x
     
var meshMinZ:Number currentDragMesh.bounds.min.x
     
var meshMaxX:Number currentDragMesh.bounds.max.z
     
var meshMinX:Number currentDragMesh.bounds.min.z
     } 

checking the ortation of the ObjectContainer3D, rather than the mesh.

So I do need to leave the above doe in to compensate for rotations, but obviously checking on the mesh rotation rather than that of the ObjectContainer3D.

Unless of course I revert back to rotating the OC3D…

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X