I'm trying to create a procedural skeletal mesh with a procedural skeleton and manual animation. I think I've successfully created the mesh and skeleton but I'm unable to translate/rotate individual bones.
This is how I created the skeletal mesh (only difference from regular mesh is shown)
Code: Select all
...
auto weightsElemType = Ogre::v1::VertexElement::multiplyTypeCount(Ogre::VET_FLOAT1, num_joints_per_vertex);
vertexElements.push_back(Ogre::VertexElement2(Ogre::VET_UBYTE4, Ogre::VES_BLEND_INDICES));
vertexElements.push_back(Ogre::VertexElement2(weightsElemType, Ogre::VES_BLEND_WEIGHTS));
...
Ogre::uint8* dstData = reinterpret_cast<Ogre::uint8*>(vcursor);
for (int i = 0; i < 4; i++) {
Ogre::uint8 idx = 0;
if (i < data.joint_indices.size()) idx = data.joint_indices[i];
*dstData++ = idx;
}
vcursor = reinterpret_cast<Ogre::Real*>(dstData);
for (int i = 0; i < data.joint_weights.size(); i++) {
*vcursor++ = data.joint_weights[i];
}
Code: Select all
auto skeleton = Ogre::v1::OldSkeletonManager::getSingleton().create(skeleton_name,Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);
auto root_bone = skeleton->createBone("bone0", 0);
auto bone1 = skeleton->createBone("bone1", 1);
auto bone2 = skeleton->createBone("bone2", 2);
root_bone->addChild(bone1);
root_bone->addChild(bone2);
skeleton->setBindingPose();
Code: Select all
auto ski = ent->getSkeletonInstance();
if (ski) {
int bone_count = ski->getNumBones(); // returns 3, as intended
auto bone0 = ski->getBone(0);
auto bone1 = ski->getBone(1);
auto bone2 = ski->getBone(2);
bone1->setOrientation(...);
}
PS: I'm not going to use Ogre's built-in animation classes (won't import from file and won't create them procedurally). I just want to change bones' position/translation/scale each frame manually.