Skined mesh - Removing mesh buffers

Post your questions, suggestions and experiences regarding to Image manipulation, 3d modeling and level editing for the Irrlicht engine here.
vasekkraka
Posts: 11
Joined: Mon Jan 11, 2016 7:17 am

Skined mesh - Removing mesh buffers

Post by vasekkraka »

Hello everybody,

I have one special question. In my App I load animated mesh model from X file. For example load dwarf.x from Irrlicht media directory.
I get IAnimatedMesh with 2 meshbuffers. When I convert IAnimatedMesh pointer to ISkinnedMesh pointer I can get information about count of joints for example and thats works fine.

But my problem is clonning mesh and deleting some buffers, becouse my loaded model is complexly and contain many parts and I need render only some part in one time.

Exactly:

1) load animated mesh from X file like dwarf.x
2) need duplicate this mesh dynamicaly (not load from file again) and this mesh soud be separate copy in memory without sharing from original model
3) finaly... need remove some meshbuffer Weapon mesh for example when i need render only animated dwarf...

I dont know how do this correctly.

Many sorry for my english :-) and many thanks for reply
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Skined mesh - Removing mesh buffers

Post by CuteAlien »

Not so trivial.

First check IMeshManipulator, if you are lucky it might have functions to clone the mesh.

But in some cases your only choice is testing (or knowing) what kind of mesh/meshbuffer is really used (for example SMesh and SMeshBuffer or SSkinMeshBuffer) and cast to that mesh/meshbuffer and modify the structures directly.
Unfortunately there is no getType() yet for those kind of classes, so basically you have to go over the corresponding loader code or use a debugger to figure out which type is really used (sorry).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
vasekkraka
Posts: 11
Joined: Mon Jan 11, 2016 7:17 am

Re: Skined mesh - Removing mesh buffers

Post by vasekkraka »

I try convert ImeshBuffer to correct type and deleeting some buffer with erase/clear method...

If I Attached this eddited mesh to IMeshSceneNode it works ok, but IAnimatedMeshSceneNode crashes program on smgr->DrawAll();

some idea?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Skined mesh - Removing mesh buffers

Post by CuteAlien »

Not immediately. If you have some example where I can reproduce it I can give it a shot in the debugger later on.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
vasekkraka
Posts: 11
Joined: Mon Jan 11, 2016 7:17 am

Re: Skined mesh - Removing mesh buffers

Post by vasekkraka »

Hi,

Code: Select all

 
IAnimatedMesh * dwarf_mesh = smgr->getMesh("..\\..\\..\\Data\\test_scene\\dwarf.x");
ISkinnedMesh * skinned = (ISkinnedMesh *)dwarf_mesh;
 
for (int i = 0; i < skinned->getJointCount(); i++)
{
      printf("Joint %i name: %s\n", i, skinned->getAllJoints()[i]->Name);
}
 
skinned->getAllJoints().clear(); // remove all joints - its not important when i comment this line no changes for crashing
 
printf("\tbuffer count: %i", skinned->getMeshBufferCount());
skinned->getMeshBuffers().erase(0);
printf("\tbuffer count: %i", skinned->getMeshBufferCount());
 
IMeshSceneNode * dwarf_node = smgr->addMeshSceneNode(dwarf_mesh, 0, 0, vector3df(30, 30, 0)); // works fine 
 
IAnimatedMeshSceneNode * anim_node = smgr->addAnimatedMeshSceneNode(dwarf_mesh, 0, 0, vector3df(60, 30, 0)); // crashes
 
other part of my code is like examples... WASD controled camera and loop for rendering
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Skined mesh - Removing mesh buffers

Post by CuteAlien »

Seems there is no way to reset RootJoints. finalize() (which should be called after changes) refused to re-calculate them. Maybe some kind of optimization... but unfortunately I'm not so familiar with the code to really know what this is about :-(

I suspect CSkinnedMesh::finalize() should clear RootJoints always (as that is the only place they are created).
But have to experiment some more (run into another crash while testing that... but I think that one is unrelated).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Skined mesh - Removing mesh buffers

Post by CuteAlien »

Sorry, turns out it's nothing I can fix quickly. I'm pretty certain CSkinnedMesh::finalize() should be changed. But it's not documented why it's written like it is and figuring that out will take longer. I suspect it might be because of the ogre-mesh loader which is the only one which could call finalize several times. But couldn't test because ogre-mesh loader is not up-to-date and does not support modern ogre files anymore. And I don't have old ogre meshes as examples to test. So ... have run into a dead end for now. I wrote none of the involved code so it's pretty hard for me to figure out what was the reasoning behind any of it *sigh*
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
vasekkraka
Posts: 11
Joined: Mon Jan 11, 2016 7:17 am

Re: Skined mesh - Removing mesh buffers

Post by vasekkraka »

Maybe some another question... Is possible make new instance CSkinedMesh or another animated mesh from loaded model?

Make new instance and with loops clone only needed mesh buffers and asign them to new model... ?
I know Joint contain weight array with id of meshbuffer fro skinning so for first try without joints but assigned to AnimatedNode?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Skined mesh - Removing mesh buffers

Post by CuteAlien »

Sorry, I'm not exactly sure what you try to do. It doesn't seem to be possible to clone CSkinnedMesh as far as I see if that is what you mean. You can split the mesh and the animations with ISkinnedMesh::useAnimationFrom if that's what you are trying to do.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
vasekkraka
Posts: 11
Joined: Mon Jan 11, 2016 7:17 am

Re: Skined mesh - Removing mesh buffers

Post by vasekkraka »

I only need remove some buffers or set it to invisible when renedring...

As you maybe know m2 files from WoW contain basic model and some rendundant submeshes... for example 6x hands 12x hair and so on...

And in one time is only one hair and one hands are rendered.... I'd like do same with X mesh files...
And becouse in one model is stored all submeshes when I load them into irrlicht is rendered all submeshes and its not look good...
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Skined mesh - Removing mesh buffers

Post by CuteAlien »

Hm, disabling meshbuffers in rendering - that feature would make a lot of sense. We should have a material flag to enable/disable materials (and thereby meshbuffers) completely. You can kinda work around it for now maybe by setting BackfaceCulling and FrontfaceCulling both to true. Thought it would still animate those meshbuffers and also send them to the graphiccard - they only wouldn't be rendered then.

I think adding a flag to disabling rendering wouldn't be too hard (basically meshscenenodes would have to check for that in OnRegister), but not sure if it would be as easy for the animation system. Maybe that would need other settings (unfortunately I'm only rudimentary familiar with the animation system).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
vasekkraka
Posts: 11
Joined: Mon Jan 11, 2016 7:17 am

Re: Skined mesh - Removing mesh buffers

Post by vasekkraka »

Many thanks for your replies I will make some tests and tell result :)
vasekkraka
Posts: 11
Joined: Mon Jan 11, 2016 7:17 am

Re: Skined mesh - Removing mesh buffers

Post by vasekkraka »

Again, one question... is possible dynamic make new CskinnedMesh?

When i try this i get compiling error

Code: Select all

ISkinnedMesh * n = new CSkinnedMesh();
and this looks like working but...

Code: Select all

IAnimatedMesh * clone = new SAnimatedMesh(NULL, E_ANIMATED_MESH_TYPE::EAMT_SKINNED);
 
        ISkinnedMesh * skin_clone = (ISkinnedMesh*)clone;
 
        skin_clone->getMeshType();
 
        skin_clone->getMeshBufferCount();
        
this line crashes app

Code: Select all

SSkinMeshBuffer * buf = skin_clone->addMeshBuffer();

some idea?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Skined mesh - Removing mesh buffers

Post by CuteAlien »

No you can't create a CSkinnedMesh as it's not in the public headers. The only way you can do something like that would be copying the corresponding files (CSkinnedMesh.cpp/.h) from Irrlicht into your project. Thought when you do that it's probably a good idea then to rename the files/classes as it can get confusing otherwise. But has the advantage that you can then modify them any way you like.

The "(ISkinnedMesh*)clone" cast can't work. You haven't created a struct/class derived from ISkinnedMesh* so casting it you just tell the compiler to access the memory at that address like a ISkinnedMesh despite the fact that the memory contains something completely different. That's like putting a "milk" sticker on nitroglycerin and expecting you can drink it now :-)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Skined mesh - Removing mesh buffers

Post by mongoose7 »

You *can* create skinned meshes, there is a special call, something like 'createSkinnedMesh' in the scene manager or elsewhere. Anyway, it can be done and was expected to be able to be done.
Post Reply