BoudingBox and TransformedBoundingBox situation !

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
PsYkO57
Posts: 7
Joined: Wed Jun 24, 2009 12:28 pm

BoudingBox and TransformedBoundingBox situation !

Post by PsYkO57 »

Hello,

I'm using Irrlicht for a professionnal project, and so far, it worked nicely. But then I implemented something that highlight the selected scene node by drawing a bounding box around it. The "selected" object is the object that the camera is looking at.

My big problem is that :

If I look the object with my camera on the left part of the object, I got this :

Image

And if I look with my camera on the right of the object, I have this :

Image

Obviously, you see that there is a problem with the green and the red bouding box, they are not at the same position :
* The green bouding box is the object's TransformedBoundingBox
* The red bouding bx is the object's BoudingBox

In the first case, the green bouding box is always connected to the object on an edge, and the red bouding box is the inital position of the box.

In the second case, the red bounding box is always on the object, and the green bouding box seems to be at 2*coords, wheree coords are the coordinates I've put the object.

I say "inital position of the box" because I've done a node->setPosition(...) to move it and see what the bounding box are. And yes, I've done a node->updateAbsolutePosition().

The code that shows the bounding boxes is :

Code: Select all

driver->draw3DBox(scene3D->getCurTargetedNode()->getTransformedBoundingBox(), SColor(255,0,255,0));
driver->draw3DBox(scene3D->getCurShowedVarsNode()->getBoundingBox(), SColor(255,255,0,0));
So I looked and looked and looked at the problem, but I can't figure out why when I move the camera (or just the camera lookat), the object's bouding box are changing.

BTW, I'm using the FPS native camera.

I can't give you the entire code because it's fully linked with another software (as I said, I'm working on a professionnal project) and it can't run on its own.
I hope I've been clear enought, and you'll be able to help me,
Don't hesitate to ask for further details,
Thanks
Eigen
Competition winner
Posts: 375
Joined: Fri Jan 27, 2006 2:01 pm
Location: Estonia
Contact:

Post by Eigen »

Put

Code: Select all

driver->setTransform(video::ETS_WORLD, core::matrix4());
in front of the drawing functions if you haven't already.
PsYkO57
Posts: 7
Joined: Wed Jun 24, 2009 12:28 pm

Post by PsYkO57 »

Oh, it really works!

Can you tell me why should I do that, and what does it do?

Thanks, really :)
Eigen
Competition winner
Posts: 375
Joined: Fri Jan 27, 2006 2:01 pm
Location: Estonia
Contact:

Post by Eigen »

It sets the world transformation (position and rotation values are set to 0). Otherwise it would use the last rendered scene node or camera (I'm not sure which) transformation instead. It means it draws everything relative to the transformation (position, rotation etc). At least this is how I understand it.
Post Reply