Hello, I was trying to follow the sample "ImportAnimationsShareSkeletonInstance", and tried to discard all the parts meshes and replace "char_mining.skeleton" with "char_reference.skeleton". I was doing this to see how to import animation from a .skeleton file with the same name as the mesh, since I tried doing that with a custom V2 "Cube.mesh" and "Cube.skeleton" file exported from blender but it failed.
Here's the code of the GameState.cpp file:
Code: Select all
namespace Demo
{
ImportAnimationsShareSkeletonInstanceGameState::ImportAnimationsShareSkeletonInstanceGameState(
const Ogre::String& helpDescription) :
TutorialGameState(helpDescription),
mAnyAnimation(0)
{
}
//-----------------------------------------------------------------------------------
void ImportAnimationsShareSkeletonInstanceGameState::createScene01()
{
Ogre::SceneManager* sceneManager = mGraphicsSystem->getSceneManager();
Ogre::v1::MeshPtr v1Mesh;
Ogre::MeshPtr v2Mesh;
bool halfPosition = true;
bool halfUVs = true;
bool useQtangents = false;
{ // Prepare char_reference mesh
v1Mesh = Ogre::v1::MeshManager::getSingleton().load(
"char_reference.mesh", Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME,
Ogre::v1::HardwareBuffer::HBU_STATIC, Ogre::v1::HardwareBuffer::HBU_STATIC);
v2Mesh = Ogre::MeshManager::getSingleton().createByImportingV1(
"char_reference.mesh", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
v1Mesh.get(), halfPosition, halfUVs, useQtangents);
v1Mesh->unload();
}
Ogre::SceneNode* sceneNode = sceneManager->getRootSceneNode(Ogre::SCENE_DYNAMIC)
->createChildSceneNode(Ogre::SCENE_DYNAMIC);
// Create the master.
Ogre::Item* charItem = sceneManager->createItem(
"char_reference.mesh", Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME,
Ogre::SCENE_DYNAMIC);
sceneNode->attachObject(charItem);
{
// Import animation from char_mining.skeleton
Ogre::SkeletonInstance* skeletonInstance = charItem->getSkeletonInstance();
skeletonInstance->addAnimationsFromSkeleton(
"char_reference.skeleton", Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
mAnyAnimation = skeletonInstance->getAnimation("char_reference");
mAnyAnimation->setEnabled(true);
}
//---------------------------------------------------------------------------------------------------
Ogre::Light* light = sceneManager->createLight();
Ogre::SceneNode* lightNode = sceneManager->getRootSceneNode()->createChildSceneNode();
lightNode->attachObject(light);
light->setPowerScale(Ogre::Math::PI); // Since we don't do HDR, counter the PBS' division by
// PI
light->setType(Ogre::Light::LT_DIRECTIONAL);
light->setDirection(Ogre::Vector3(-1, -1, -1).normalisedCopy());
mCameraController = new CameraController(mGraphicsSystem, false);
Ogre::Camera* camera = mGraphicsSystem->getCamera();
camera->setPosition(Ogre::Vector3(0, 2.5, 4));
TutorialGameState::createScene01();
}
//-----------------------------------------------------------------------------------
void ImportAnimationsShareSkeletonInstanceGameState::update(float timeSinceLast)
{
mAnyAnimation->addTime(timeSinceLast);
TutorialGameState::update(timeSinceLast);
}
} // namespace Demo
But this shows the same error as the V2 "Cube.mesh" and "Cube.skeleton" situation, which is:
"Can't find animation '[Hash...]' in SkeletonInstance::getAnimation at ..."
Is this because the .skeleton file in both situations doesn't have animations, only the base skeleton?