Allow manually setting vertex animation type

Minor issues with the Ogre API that can be trivial to fix
Post Reply
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 214

Allow manually setting vertex animation type

Post by scrawl »

In my project, I have vertex animations that I need to apply manually. I am not using Ogre's morph animation system because it's simply not compatible.
The problem is that Ogre only creates the SubEntity's software vertex animation buffer that I need IF a vertex animation track is used in the mesh.
As a workaround, I had to create a dummy animation track:

Code: Select all

    if (srcVerts.size() && geomMorpherController)
        mesh->createAnimation("dummy", 0)->createVertexTrack(1, subMesh->vertexData, Ogre::VAT_MORPH);
This is not very nice; it would be better if there was an API to manually override the vertex animation type.

For reference, here is how I'm applying the animation, which works great.

Code: Select all

            Ogre::VertexData* data = mSubEntity->_getSoftwareVertexAnimVertexData();

            const Ogre::VertexElement* posElem =

            Ogre::HardwareVertexBufferSharedPtr vbuf =

            // The first morph key always contains the original positions
            mNewVertices = mMorphs[0].mVertices;

            for (std::vector<Nif::NiMorphData::MorphData>::iterator it = mMorphs.begin()+1; it != mMorphs.end(); ++it)
                float val = 0;
                if (!it->mData.mKeys.empty())
                    val = interpKey(it->mData.mKeys, time);

                val = std::max(0.f, std::min(1.f, val));

                if (it->mVertices.size() != mMorphs[0].mVertices.size())

                if (val != 0)
                    for (unsigned int v=0; v<mNewVertices.size(); ++v)
                        mNewVertices[v] += it->mVertices[v] * val;

            vbuf->writeData(0, vbuf->getSizeInBytes(), &mNewVertices[0]);


Post Reply