getBoundingBox() --doubt

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
hkolli
Posts: 42
Joined: Thu Jul 13, 2006 8:29 pm

getBoundingBox() --doubt

Post by hkolli »

hi all ,

when we use getBoundingBox() function we get the values regarding it's x,y,z planes .... how do i access them .

thanks
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The bounding box just knows the min and max of the bounding area. It knows nothing about orientation. Well, it is always oriented with the coordinate system axes, so the orientation of the box is always the identity matrix.

In model space the planes are just this...

Code: Select all

core::plane3df xy(0, 0, 0, 0, 0, 1);
core::plane3df xz(0, 0, 0, 0, 1, 0);
core::plane3df yz(0, 0, 0, 1, 0, 0);
If you want that information in some other coordinate system, you need to apply the appropriate matrix transform to the plane.

Code: Select all

// this would transform the above planes into world space
node->getAbsoluteTransformation().transformPlane(xy);
node->getAbsoluteTransformation().transformPlane(xz);
node->getAbsoluteTransformation().transformPlane(yz);
It sounds like you may want the planes of the axis aligned box. If you want this, then you need to do no rotation, you just need to offset the plane position by half of the box extents.
hkolli
Posts: 42
Joined: Thu Jul 13, 2006 8:29 pm

Post by hkolli »

hi

is the following code not valid


// D3DRMBOX box;
core::aabbox3d<f32> Box;

//meshBuilder -> GetBox( &box );
Box=anode->getBoundingBox();
s32 sizex = Box.T maxx - Box.T minx;
s32 sizey = Box.T maxy - Box.T miny;
s32 sizez = Box.T maxz - Box.T minz;
// Find the average of the flyer's three dimensions.
size = ( sizex + sizey + sizez ) / 3.0;

thanks
hkolli
hkolli
Posts: 42
Joined: Thu Jul 13, 2006 8:29 pm

Post by hkolli »

hi ,


is this correct


Box=anode->getBoundingBox();
s32 sizex = Box.T maxx - Box.T minx;
s32 sizey = Box.T maxy - Box.T miny;
s32 sizez = Box.T maxz - Box.T minz;

thanks
hkolli
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Well, it would be simpler to say...

Code: Select all

core::vector3df size = node->getBoundingBox().getExtent();
// size.x, y and z are the dimensions of the box

core::vector3df center = node->getBoundingBox().getCenter();
// center.x, y and z mark the center of the bounding box
hkolli
Posts: 42
Joined: Thu Jul 13, 2006 8:29 pm

Post by hkolli »

thanks

vitek
Post Reply