worldBounds work incorrectly

Software: Away3D 4.x

Avatar
Mu Duck, Newbie
Posted: 25 November 2013 04:03 PM   Total Posts: 20

Hello everyone.
I have a cube mesh, which is supposed to be a trigger for some actions, when a walking character overlaps it. Quite Simple. The trigger mesh has its x,y,z, rotation and scale changed somehow.

I tried to use something like this:

if(mesh.worldBounds.overlaps(char.worldBounds)){...

It works, but the bounds are placed incorrectly (I don’t understand how exactly, but not like the cube itself).

Then I tried a simpler method - to test if a single point is inside the bounds:

if(mesh.worldBounds.containsPoint(char.position){...}

But it seems to be working with the same incorrect bounding box.

Then I came up with something weird, which relies on bounds property, but first I need to translate char.position to bounds-space:

vec:Vector3D mesh.inverseSceneTransform.transformVector(char.position);
if(
mesh.bounds.containsPoint(vec)){...

To my surprise it worked correctly, however I wasn’t even sure, if I multiplied position by the correct matrix XD. But my problem now is that I still want to use overlaps() method and I don’t know how to translate char.bounds to mesh.bounds space for that. And I am still thinking, that I did something incorrect with worldBounds property.

Did anyone have a problem like this one? Is it a bug with worldBounds?
By the way I used mesh.showBounds = true; And in all cases it shows the correct bounds, as expected.

   

Avatar
Mu Duck, Newbie
Posted: 26 November 2013 06:27 PM   Total Posts: 20   [ # 1 ]

I studied it a bit more and now I can say, that worldBounds are set incorrectly only if rotation properties are applied to mesh. So this seems to be a bug really.

Here is the screenshot of my case: http://briztimqwo.com/sites/harmony/1.png
I rotate mesh (the bear) on Y-axis by 40 degrees.
blue wireframe box is worldBounds
white wireframe box is bounds
As you can see worldBounds are actually bounding usual bounds. If you translate mesh or scale it (on any axis) - they are set correctly.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X