bounding Box on cubes

Software: Away3D 3.x

Tempy111, Sr. Member
Posted: 23 November 2015 01:59 PM   Total Posts: 133

Hi, I’m a Little confused about Bounding boxes on cube shapes..

while I’ve kinda found away around it which isn’t greatly useful, I’ve created a basic cube like this:

floor=new Cube({material:Checkboard,width:1000,height:10,depth:1000,y:-200,x:0,z:0}); 

that’s fine. It loads, it displays, but when I do a AABB test using that cube, it reports that the minY is -907.1244586351119 and maxY is 507.12445863511186.. Or more, that’s the parent.. if I do it on the object itself, it seams to get it kinda right but without taking into account the real location. (it comes back as -5,5, which doesn’t take into account that fact it was set as y = -200).

Going through the Cookbook as a reference book on the subject, seams to say this should work (it’s where I got the code for this version of a AABB test) but it doesn’t..

my quick and dirty fix is just checking with the Y’s of the objects for height checking. though as I’m not quite sure, right now, on how to align models inside a box, I have a 3Ds model which I need to take away half the high to get it’s bottom.

   

Tempy111, Sr. Member
Posted: 25 November 2015 05:05 PM   Total Posts: 133   [ # 1 ]

still can’t figure it out.. tried debugbb = true to show the box, but doesn’t show so i’m not sure what I did wrong there.. I place another cube, which has a height of 100 onto the stage, 100 pixels higher and I noticed, it’s not touching the bottom one. as if it made the bounding box twice the size it should be and then centred the cube in it.. interesting

   

Tempy111, Sr. Member
Posted: 27 November 2015 04:25 PM   Total Posts: 133   [ # 2 ]

did the long way.. took the X,Y and Z and used the Width/Height/Depth to work out the bounding box. still confused why the build in stuff didn’t do it..

   

superCube, Newbie
Posted: 30 November 2015 11:47 AM   Total Posts: 6   [ # 3 ]

//Bounds are often used to show where mouse clicks are detected so try enabling the mouse

Something like this should work

var cube:Mesh = new Mesh(new CubeGeometry());

cube.mouseEnabled = true;
cube.showBounds = true;

   

Tempy111, Sr. Member
Posted: 01 December 2015 10:55 AM   Total Posts: 133   [ # 4 ]

create the cube as a mesh instead of a cube? show showBounds comes back as an error (1056 cannot create property) on a cube object.

Doesn’t seam to want to work as a Mesh either but I might need to completely redo how cube creation is done.. oh well.

thanks anyway ^_^

   

superCube, Newbie
Posted: 02 December 2015 02:52 PM   Total Posts: 6   [ # 5 ]

Yes renderable geometry needs to exist as a property of a mesh.

So you call the mesh constructor and then pass in the required geom

Then set showBounds to true on the mesh instance

var plane:Mesh = new Mesh(new Plane Geom…, your material)

plane.showBounds = true;

   

Tempy111, Sr. Member
Posted: 02 December 2015 03:16 PM   Total Posts: 133   [ # 6 ]

hang on.. cubeGeometry… isn’t that 4.0? not 3.6? which might be why it doesn’t seam to work for me and showBounds is different from debugBB which I have been told… mm

   

Tempy111, Sr. Member
Posted: 07 December 2015 02:06 PM   Total Posts: 133   [ # 7 ]

Back to this..

It seams the Bounding box for the cubes is 100% fine. but the mesh is another matter.. maybe..

well.. I load the md2, when loaded it’s put into a mesh object. that’s all perfect and fine I think..

anyway.. I tell the mesh (RabbitMesh in this case) to have debugbb = true;
RabbitMesh.debugbb = true; that should be fine. but at the moment, it replies that value is not a function.

So I won’t display the Bounding box as a wireframe so I can see if it is hitting when it shouldn’t be..

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X