Seperate MeshBuffers for Animated Mesh

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
the burning realm
Posts: 5
Joined: Sun Jun 15, 2014 9:07 pm

Seperate MeshBuffers for Animated Mesh

Post by the burning realm »

Hi all,

I am attempting to create instances of an AnimatedMesh and then recolor the vertices within the mesh. My problem is that these animatedMeshes use the same meshbuffers, so re-coloring one mesh will change any other instances.

Here is my code for loading the mesh

Code: Select all

 
for (int i = 0; i < PlayerParts::COUNT; i++) {
        mesh = (ISkinnedMesh*)c->assetManager->getMesh(appearance.modelId[i]);
        bodyNodes[i] = c->sceneManager->addAnimatedMeshSceneNode(mesh);
        bodyNodes[i]->setJointMode(EJUOR_CONTROL);
        bodyNodes[i]->setMaterialFlag(EMF_LIGHTING, false);
    }
 
recoloring legs, this is called with two different colors for each instance

Code: Select all

 
for (int i = 0; i < bodyNodes[LEGS]->getMesh()->getMeshBufferCount(); i++) {
        c->sceneManager->getMeshManipulator()->setVertexColors(bodyNodes[LEGS]->getMesh()->getMeshBuffer(i), legsColor);
    }
 
Even though one of the legs is set to red, and one is set to green they both show as green:
[img]
https://ibb.co/dcDHHc
[/img]

My question is how can I copy a meshbuffer so it is seperate from the original and then apply it to an IAnimatedMeshSceneNode?
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Seperate MeshBuffers for Animated Mesh

Post by CuteAlien »

I remember LunaRebirth had the same question last year: http://irrlicht.sourceforge.net/forum/v ... =1&t=51928
The best solution for this is probably to use a shader for the coloring instead of changing the mesh.

Another workaround is to rename the mesh in the mesh-cache, then you can load it again and each node using another copy that way (so you load it once per node... which makes for really bad loading times).

Copying animated meshes is unfortunatly not supported.
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
Post Reply