Question about .skeleton file

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
knn217
Halfling
Posts: 70
Joined: Wed Jan 25, 2023 9:04 am
x 5

Question about .skeleton file

Post by knn217 »

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?

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Question about .skeleton file

Post by dark_sylinc »

Hi!

knn217 wrote: Wed Feb 01, 2023 10:17 am

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 ..."

First, test in Debug build. If you see "[Hash...]" it's because you're in Release build. Debug builds have a lot of checks to aid in discovering incorrect setup.

knn217 wrote: Wed Feb 01, 2023 10:17 am

Is this because the .skeleton file in both situations doesn't have animations, only the base skeleton?

You're trying to load char_reference.skeleton (which is valid) but then try to grab an animation called char_reference but char_reference.skeleton simply has no such animation.

In fact char_reference.skeleton has no animations at all.

In the original sample, we load char\_mining.skeleton and load the char\_mining animation. Because char_mining.skeleton does have an animation with such name, it succeeds.

knn217
Halfling
Posts: 70
Joined: Wed Jan 25, 2023 9:04 am
x 5

Re: Question about .skeleton file

Post by knn217 »

dark_sylinc wrote: Wed Feb 01, 2023 11:38 pm

First, test in Debug build. If you see "[Hash...]" it's because you're in Release build. Debug builds have a lot of checks to aid in discovering incorrect setup.

Here's the output and Ogre.log from "char_reference":
Output:

Code: Select all

Ogre: Parsing script Tutorial_Terrain.compositor
Ogre: Parsing script UvBaking.compositor
Ogre: Finished parsing scripts for resource group Popular
Ogre: Creating resources for group Popular
Ogre: All done
Ogre: Mesh: Loading char_reference.mesh.
Ogre: Skeleton: Loading char_reference.skeleton
Ogre: Corrupted chunk detected! Stream name: 'char_reference.mesh' Chunk id: 36864
Ogre: WARNING: char_reference.mesh is an older format ([MeshSerializer_v1.100]); you should upgrade it as soon as possible using the OgreMeshTool tool.
Ogre: Mesh: Loading char_reference.mesh.
Ogre: Corrupted chunk detected! Stream name: 'char_reference.mesh' Chunk id: 36864
Ogre: WARNING: char_reference.mesh is an older format ([MeshSerializer_v1.100]); you should upgrade it as soon as possible using the OgreMeshTool tool.
Ogre: Can't assign material deferred_default_mat because this Material does not exist. Have you forgotten to define it in a .material script?
Exception thrown at 0x00007FF908B306BC in ImportAnimationsShareSkeletonInstance.exe: Microsoft C++ exception: Ogre::ItemIdentityException at memory location 0x000000F20B5EE2F0.
Ogre: WARNING: GraphicsSystem::deinitialize() not called!!!
Exception thrown at 0x00007FF908B306BC in ImportAnimationsShareSkeletonInstance.exe: Microsoft C++ exception: Ogre::Exception at memory location 0x000000F20B5EF520.
The thread 0x7034 has exited with code 4294967295 (0xffffffff).
The thread 0x3480 has exited with code 4294967295 (0xffffffff).
The thread 0x32fc has exited with code 4294967295 (0xffffffff).
The thread 0x651c has exited with code 4294967295 (0xffffffff).

Ogre.log:

Code: Select all

07:26:09: Creating resources for group Popular
07:26:09: All done
07:26:09: Mesh: Loading char_reference.mesh.
07:26:09: Skeleton: Loading char_reference.skeleton
07:26:09: Corrupted chunk detected! Stream name: 'char_reference.mesh' Chunk id: 36864
07:26:09: WARNING: char_reference.mesh is an older format ([MeshSerializer_v1.100]); you should upgrade it as soon as possible using the OgreMeshTool tool.
07:26:09: Mesh: Loading char_reference.mesh.
07:26:09: Corrupted chunk detected! Stream name: 'char_reference.mesh' Chunk id: 36864
07:26:09: WARNING: char_reference.mesh is an older format ([MeshSerializer_v1.100]); you should upgrade it as soon as possible using the OgreMeshTool tool.
07:26:09: Can't assign material deferred_default_mat because this Material does not exist. Have you forgotten to define it in a .material script?
07:26:09: OGRE EXCEPTION(5:ItemIdentityException): Can't find animation 'char_reference' in SkeletonInstance::getAnimation at D:\OGRE_NEXT\ogre-next\OgreMain\src\Animation\OgreSkeletonInstance.cpp (line 412)
07:26:09: WARNING: GraphicsSystem::deinitialize() not called!!!

And here's the output and Ogre.log from my custom .skeleton file:
Output:

Code: Select all

Ogre: Parsing script Tutorial_Terrain.compositor
Ogre: Parsing script UvBaking.compositor
Ogre: Finished parsing scripts for resource group Popular
Ogre: Creating resources for group Popular
Ogre: All done
Ogre: Mesh: Loading Cube.003.mesh.
Ogre: Skeleton: Loading Cube.003.skeleton
Exception thrown at 0x00007FF908B306BC in ImportAnimationsShareSkeletonInstance.exe: Microsoft C++ exception: Ogre::RenderingAPIException at memory location 0x0000002E708FD500.
Ogre: OGRE EXCEPTION(3:RenderingAPIException): Fixed Function pipeline is no longer allowed nor supported. The material Material must use shaders in HlmsLowLevel::calculateHashFor at D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreHlmsLowLevel.cpp (line 159)
Ogre: Couldn't apply datablock '[Value 0x00000024]' to this renderable. Using default one. Check previous log messages to see if there's more information.
Exception thrown at 0x00007FF908B306BC in ImportAnimationsShareSkeletonInstance.exe: Microsoft C++ exception: Ogre::ItemIdentityException at memory location 0x0000002E708FE490.
Ogre: WARNING: GraphicsSystem::deinitialize() not called!!!
Exception thrown at 0x00007FF908B306BC in ImportAnimationsShareSkeletonInstance.exe: Microsoft C++ exception: Ogre::Exception at memory location 0x0000002E708FF570.
The thread 0x10b4 has exited with code 4294967295 (0xffffffff).
The thread 0x25a4 has exited with code 4294967295 (0xffffffff).
The thread 0x3008 has exited with code 4294967295 (0xffffffff).

Ogre.log:

Code: Select all

07:16:32: Creating resources for group Popular
07:16:32: All done
07:16:32: Mesh: Loading Cube.003.mesh.
07:16:32: Skeleton: Loading Cube.003.skeleton
07:16:32: OGRE EXCEPTION(3:RenderingAPIException): Fixed Function pipeline is no longer allowed nor supported. The material Material must use shaders in HlmsLowLevel::calculateHashFor at D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreHlmsLowLevel.cpp (line 159)
07:16:32: OGRE EXCEPTION(3:RenderingAPIException): Fixed Function pipeline is no longer allowed nor supported. The material Material must use shaders in HlmsLowLevel::calculateHashFor at D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreHlmsLowLevel.cpp (line 159)
07:16:32: Couldn't apply datablock '[Value 0x00000024]' to this renderable. Using default one. Check previous log messages to see if there's more information.
07:16:32: OGRE EXCEPTION(5:ItemIdentityException): Can't find animation 'Cube.003' in SkeletonInstance::getAnimation at D:\OGRE_NEXT\ogre-next\OgreMain\src\Animation\OgreSkeletonInstance.cpp (line 412)
07:16:32: WARNING: GraphicsSystem::deinitialize() not called!!!
dark_sylinc wrote: Wed Feb 01, 2023 11:38 pm

You're trying to load char_reference.skeleton (which is valid) but then try to grab an animation called char_reference but char_reference.skeleton simply has no such animation.

This seems to be the problem, Is there a way to check my .skeleton files's animation names? Or do I do that from blender?

knn217
Halfling
Posts: 70
Joined: Wed Jan 25, 2023 9:04 am
x 5

Re: Question about .skeleton file

Post by knn217 »

My bad, found the solution, should've checked "Skeletal Animations README" at the bottom of blender2ogre's github page

Post Reply