Show BoundingBox

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
riddler2006
Posts: 10
Joined: Thu May 24, 2007 3:42 pm

Show BoundingBox

Post by riddler2006 »

Hi,

I know that this problem has been discussed several times since this forum exists but the most soultions don't work in my case. I want to show the boundingbox around my object but unfortunately when i set showDebugData to true the calculation power my computer needs rises from 10 to 50 percent. So I search for another way to show the bounding box and tried following code...

IAnimatedMeshSceneNode node;

Box3D box = node.TransformedBoundingBox;
device.Video.drawBox3D(box, new Color(200,255,255,255));

unfortunately this box will be never drawn.. what do I wrong?
I use Irrlicht.NET

thanks for your hrlp
trivtn
Posts: 132
Joined: Tue Jan 17, 2006 12:30 pm
Location: Viet Nam
Contact:

Post by trivtn »

I think if you uses Irrlicth 1.3 you could use setDebugDataVisible(irr::scene::EDS_BBOX). another way use drawBox3D but use must use it in the loop ( while device->run()... end).
There's something is fantastic, there's nothing is absolute.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

after smgr->drawAll()

SMaterial m;
m.Lighting = false;
driver->setTransform(node->getAbsoluteTransformation());
driver->setMaterial(m);

then draw it
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Just FYI, I don't believe that all scene nodes implement debug rendering as of 1.3, so you might still want to render the box yourself. Just to expand on what bitplane just said...

Code: Select all

// after driver->beginScene(...)

video::SMaterial m; 
m.Lighting = false; 
driver->setMaterial(m);

// this is an object aligned bounding box. it should be a pretty tight fit.
core::aabbox3df box(node->getBoundingBox());

// to draw a box that is in object coordinates...
driver->setTransform(video::ETS_WORLD, node->getAbsoluteTransformation());
driver->draw3DBox(box, video::SColor(255, 0, 255, 0));

// this is a world aligned bounding box. it may be bigger than the
// object space bounding box, but the edges of the box will be aligned
// with the world coordinate system.
node->getAbsouteTransformation().transformBoxEx(box);

// to draw a box that is in world coordinates...
driver->setTransform(video::ETS_WORLD, core::matrix4());
driver->draw3DBox(box, video::SColor(255, 0, 0, 255));

// before driver->endScene(...)
riddler2006
Posts: 10
Joined: Thu May 24, 2007 3:42 pm

Post by riddler2006 »

Thanks a lot.. it works
:-)
Post Reply