Page 1 of 1

IAnimatedMesh : is it possible to update a bounding box ?

Posted: Sat May 10, 2008 7:23 pm
by Oddmonger
Hello.

As a little drawing say more than lot of words, let's look at this:

Image

How ugly.

It would be nice if IAnimatedMesh could update the bounding box while the animation is running.

Is it possible ? Or may i have to do it myself ?

Posted: Sat May 10, 2008 9:32 pm
by hybrid
Some animated mesh do that, e.g. md2. So I don't understand why yours doesn't :?

Posted: Sat May 10, 2008 10:25 pm
by Oddmonger
hybrid wrote:Some animated mesh do that, e.g. md2. So I don't understand why yours doesn't :?
Hmm well, i don't understand either

The nice running woman on the screenshot is "sydney.md2" and comes from the "media" directory of Irrlicht.

So the bounding box should grow when Sydney is running, should'nt it?

I'll give a closer look tomorrow. On the samples, not on Sydney :wink:

bounding box aren't updated in md2 animation cycle

Posted: Sun May 11, 2008 9:57 am
by Oddmonger
Ok, i've modified a bit the first sample of Irrlicht sample dir.
I've added bounding box visibility.
You can see that the bounding box doesn't change while Sydney is running.

Here is the complete code for testing:

Code: Select all

/* based on irrlicht sample: 01.HelloWorld 
   i've stripped all i could, to only keep the bare minimum for running.
   i've added the bounding box visibility.
*/

#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;

int main()
{
  IrrlichtDevice *device =
     createDevice( video::EDT_OPENGL, dimension2d<s32>(640, 480), 16, false, false, false, 0);

  device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");

  IVideoDriver* driver = device->getVideoDriver();
  ISceneManager* smgr = device->getSceneManager();

  IAnimatedMesh* mesh = smgr->getMesh("sydney.md2");
  IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );

  //show me the bounding box, Lebowski!
  node->setDebugDataVisible(EDS_BBOX);

  if (node)
  {
    node->setMaterialFlag(EMF_LIGHTING, false);
    node->setMD2Animation ( scene::EMAT_RUN );
  }

  smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));

  while(device->run())
  {
    driver->beginScene(true, true, SColor(255,100,101,140));
    smgr->drawAll();
    driver->endScene();
  }

  device->drop();
  return 0;
}