Page 1 of 1

Seperate MeshBuffers for Animated Mesh

Posted: Tue Feb 27, 2018 2:00 pm
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?

Re: Seperate MeshBuffers for Animated Mesh

Posted: Wed Feb 28, 2018 11:01 am
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.