Adding vertices to a skeletal-animated mesh

Problems building or running the engine, queries about how to use features etc.
Post Reply
michlbeck
Gnoblar
Posts: 5
Joined: Thu Aug 29, 2013 7:25 pm

Adding vertices to a skeletal-animated mesh

Post by michlbeck »

Hej,

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.
As you can see at the end, the new vertex count isn't getting propagated on to the result of _getSkelAnimVertexData(). I'm on OSX and haven't been able to build a debug build of the Ogre lib myself to see what's going on inside.

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.
michlbeck
Gnoblar
Posts: 5
Joined: Thu Aug 29, 2013 7:25 pm

Re: Adding vertices to a skeletal-animated mesh

Post by michlbeck »

I was able to finally build a release-with-debug-info version of the Ogre framework, now I'm able to step through and see what he is doing...

Code: Select all

bool animationDirty =
            (mFrameAnimationLastUpdated != mAnimationState->getDirtyFrameNumber()) ||
            (hasSkeleton() && getSkeleton()->getManualBonesDirty());
I am thinking that this is the magic lines of code, from inside Ogre::Entity::updateAnimation(). I need to make the animationDirty flag become true. The easiest way to do this seems to be to call mEntity->getSkeleton()->_notifyManualBonesDirty(). This feels like a hack but it seems to be working.
michlbeck
Gnoblar
Posts: 5
Joined: Thu Aug 29, 2013 7:25 pm

Re: Adding vertices to a skeletal-animated mesh

Post by michlbeck »

... I do not know why i was thinking that that worked. It doesn't.

I think I need to manually make the Ogre::Entity::prepareTempBlendBuffers() method public and rebuild the SDK again. :(
Post Reply