Page 1 of 1

Issues with Mesh Loader in a game

Posted: Sun May 15, 2011 4:36 pm
by L o
Hey,

I tried to put my own level loader (it is named "ODFL loader") into one of a game a friend of mine wrote. Usually, ODFL loader loads the level with simple irrlicht test programs I wrote. However, with this game, it failed with a memory bug:

Code: Select all

==16830==    by 0x430A980: irr::scene::CAnimatedMeshSceneNode::setJointMode(irr::scene::E_JOINT_UPDATE_ON_RENDER) (CAnimatedMeshSceneNode.cpp:892)
The reason is pretty clear: it fails in this line:

Code: Select all

scene::IAnimatedMesh *level = smgr->getMesh("testlevel.odfl");
nodeList.push_back(smgr->addAnimatedMeshSceneNode(level)); // <- HERE 
My friend was adding an animated mesh, I never did that when I used ODFL loader. I loaded it like this, instead:

Code: Select all

scene::IAnimatedMesh* level = smgr->getMesh("testlevel.odfl");
odflnode = smgr->addOctTreeSceneNode(level->getMesh(0));
"Google"ing tells me that I'll need to provide "joints" for irrlicht. Is this the reason for that segfault? What can I do to fix it?

Thank you a lot for any help!
- Johannes

Posted: Sun May 15, 2011 8:02 pm
by hybrid
It seems to be more of a badly programmed loader. I guess that it does not use a skinned mesh internally, but sets the mesh type wrongly. This would cause an illegal access somewhere in the render methods. I fear you have to fix the loader to make this more fail safe.

Posted: Mon May 16, 2011 5:59 am
by L o
Hey,

to be honest, it was me who wrote the loader. :lol:

I remember trying to use the loader in that game my friend wrote. But loading failed with an assertion saying that the mesh needed to have a type of EAMT_SKINNED. So I replaced (in the loader)

Code: Select all

animatedmesh = new SAnimatedMesh();
with

Code: Select all

animatedmesh = new irr::scene::CSkinnedMesh();
This passed the assertion then, but caused the segfault :( Is there a possibility to help the loader get working in that game?

Greetings,
Johannes

Posted: Mon May 16, 2011 7:41 am
by hybrid
Since your format does not seem to have a skeleton animation, you're not supposed to use EAMT_SKINNED_MESH or CSkinnedMesh. You should create an SMesh, fill the structures as intended, put that one mesh into a newly created SAnimatedMesh and return that one in turn. Just set the type no EAMT_UNKNOWN or EAMT_3DS (or some other non-animated format). Check the other static mesh loaders how the final few code lines should look like.