wierd problem with drawing 3d box around terrain

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
MM2_23
Posts: 12
Joined: Sun Jan 07, 2007 3:24 am

wierd problem with drawing 3d box around terrain

Post by MM2_23 »

Hey,

I have this 3rd person camera system kind of like WoW and just recently I drew a 3dbox around the terrain (to debug) and sometimes on startup the character is at the edge of the box even though his position is closer to the middle of the terrain.

Then at certain angles (when I rotate my camera) the bounding box jumps back to the right place, but then it jumps back to the wrong place if I keep rotating. What's going on?

I think irrlicht might be thinking my characters position is the origin at certain angles but I'm not sure why. Also, on some start ups the camera system and the bounding box work perfectly fine at all angles. Kind of weird. Any suggestions?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

You are probably not setting the world transform before you render the bounding box. If you don't explicitly set the transform, the transform from the last rendered object will be used and that isn't going to be what you want most of the time. You should also be setting a material.

Code: Select all

// code assumes you have a scene node named 'terrain' and that
// i remember the names of all of the appropriate functions...
driver->setMaterial(video::SMaterial());
driver->setTransform(video::ETS_WORLD, terrain->getAbsoluteTransformation());
driver->draw3DBox(terrain->getBoundingBox(), video::SColor(255, 255, 0, 0));
MM2_23
Posts: 12
Joined: Sun Jan 07, 2007 3:24 am

Post by MM2_23 »

perfect, that did the trick. I'm not sure what the material is for (probably not the same as the materials in Newton right? What's the difference?). I've tried to use the same implementation to draw a box around my animatedX mesh but I just can't seem to get it to appear around the node the mesh is attached to. ridiculous. Thanks for your help vitek
Post Reply