I'm attempting to add extra vertices to a skeletal animated in mesh, in real time. (Think of, an animal growing extra body parts, sprouting wings or a tail).
However I'm having a problem with getting the vertices 'over' to the skeletal animation vertex data. I believe I've added the vertices correctly, constructed new buffers as necessary and bound them all (I have a good understanding of how OpenGL works on the inside).
Here's what I have so far:
Code: Select all
cout << mEntity->getMesh->sharedVertexData->vertexCount << endl; // prints 3339
// the following creates new vertex buffers with vertexCount+15 vertices,
// clones the existing 3339 vertices into the new buffer,
// then adds position, texcoord, bone weighting etc information for 15 new
// vertices at the end.
// after adding the new vertices it binds them like this:
// vData = mEntity->getMesh->sharedVertexData;
// ...
// vData->vertexCount = newVertexCount;
// for ( unsigned int i=0; i<newBuffers.size();i ++ ) {
// // Bind new buffer
// vData->vertexBufferBinding->setBinding(i,newBuffers[i]);
// }
testEditMesh();
cout << mEntity->getMesh->sharedVertexData->vertexCount << endl;
// ^^ prints 3354, that's what I expect
cout << mEntity->_getSkelAnimVertexData()->vertexCount << endl;
// ^^ prints 3339. huh? that's not right.
// what if I update?
// ok, so update the animation, to see if that propagates the new vertex count
string animName = mEntity->getSkeleton()->getAnimation(0)->getName();
mEntity->getAnimationState(animName)->setEnabled(true); // don't know if this is necessary
mEntity->addSoftwareAnimationRequest(true);
mEntity->_updateAnimation();
mEntity->getAnimationState(animName)->setEnabled(false);
cout << mEntity->_getSkelAnimVertexData()->vertexCount << endl;
// ^^ *still* prints 3339. Hrrrrm.
Can anyone give me a hint of what I might be doing wrong? I based my code on the on the Dynamic Growing Buffers and Dynamic Line Drawing examples from the wiki (http://www.ogre3d.org/tikiwiki/tiki-ind ... ingBuffers and http://www.ogre3d.org/tikiwiki/tiki-ind ... ineDrawing), but they don't deal with skeletal animation and they only have one buffer bound to handle all the vertex data, so my case is more complicated.
Is there something else I need to do to tell Ogre that I've added extra vertices? It doesn't feel like enough to only change the vertexCount variable on the VertexData class, but this is what the examples do...
Any help appreciated.