It seems when I use addAnimatedMeshSceneNode() to load multiple instances of the same model, the actual mesh buffers are shared. That's normally just swell, but when I apply vertex shading it applies it to all of them.
Is there a simple way to over-ride this behavior and specify that each should have it's own buffer?
Shared mesh buffers?
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
You can create q copy of the mesh and use that one for the next scene node. there is no automatic way for doing this.
Why do shaders create a problem here? The vertex buffers are uploaded for each mesh separately. This should create a new temporary copy each time. So I'm wondering what interferes here.
Why do shaders create a problem here? The vertex buffers are uploaded for each mesh separately. This should create a new temporary copy each time. So I'm wondering what interferes here.
The root of the problem is that the meshes are cached, and once they are loaded you get a pointer to the same mesh every time you ask for it. One way to get around this is to remove the mesh from the mesh cache after loading it. By removing it from the cache, you prevent the next scene node from trying to share the vertex data. Each scene node will have its own mesh data.
The big problem with this is that you are potentially duplicating lots of data. If it becomes a problem, you could use a shader or even a texture to modify the color of the nodes.
Travis
Code: Select all
scene::IAnimatedMesh* am1 = smgr->getMesh("../../media/dwarf.x");
scene::IAnimatedMeshSceneNode* amNode1 =
smgr->addAnimatedMeshSceneNode(am1);
smgr->getMeshCache()->removeMesh(am1);
// modify vertex colors of am1
scene::IAnimatedMesh* am2 = smgr->getMesh("../../media/dwarf.x");
scene::IAnimatedMeshSceneNode* amNode2 =
smgr->addAnimatedMeshSceneNode(am2);
smgr->getMeshCache()->removeMesh(am2);
// modify vertex colors of am2
Travis
AHHHHH!!!smgr->getMeshCache()->removeMesh(am1);
That's it, after reading your post vitek, I realized I've ran across this before on the forum, I was looking everywhere for some kind of flag. Many thanks and sorry to slow you down.
@hybrid
I was actually using m_pSm->getMeshManipulator()->setVertexColors(), I dropped the phrase vertex shading because I don't know what I'm talking about.