Combining skeletal and vertex animation

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
cc9cii
Halfling
Posts: 99
Joined: Tue Sep 18, 2018 4:53 am
x 20

Combining skeletal and vertex animation

Post by cc9cii »

Ogre Version: 1.10.11
Operating System: Windows 10
Render System: D3D9

I'm trying to add a set of facial poses to a character. The animations and poses are defined in the head Mesh and the Entity is subsequently created. I can see all of these in the debugger, and they look ok as far as I can tell.

However, once I call shareSkeletonInstanceWith() all the AnimationStates in the Entity are deleted. I'm not sure why, but it must be done for some reason (once the sharing is stopped they are re-created from the Mesh).

So, how am I meant to implement *both* vertex and skeletal animations?
User avatar
sercero
Bronze Sponsor
Bronze Sponsor
Posts: 450
Joined: Sun Jan 18, 2015 4:20 pm
Location: Buenos Aires, Argentina
x 156

Re: Combining skeletal and vertex animation

Post by sercero »

Hello,

I have never used that feature, but according to the manual it should work:
https://www.ogre3d.org/docs/manual18/manual_81.html

However it seems that both animations have to be on the same mesh if I understood this thread correctly:
viewtopic.php?t=22040

(It has to be done by the exporter, supposedly)

You should search for the subject matter in the forum, there are many threads about this.

Best regards,
Guillermo
User avatar
cc9cii
Halfling
Posts: 99
Joined: Tue Sep 18, 2018 4:53 am
x 20

Re: Combining skeletal and vertex animation

Post by cc9cii »

Thanks for your response. I must admit that while I did use google I didn't use the forum's search function.

I will now search for those threads for more info.

About my head mesh - these are from Oblivion NIF files - a character is made from several of these and the skeleton is separate from the skinned meshes. I might be in trouble if mixing pose animation requires the mesh to be the same as the skeleton.
User avatar
sercero
Bronze Sponsor
Bronze Sponsor
Posts: 450
Joined: Sun Jan 18, 2015 4:20 pm
Location: Buenos Aires, Argentina
x 156

Re: Combining skeletal and vertex animation

Post by sercero »

Sorry for stating the obvious, but did you try to addTime() to both meshes or animation states separately?

Why are you trying to share the skeleton instance?

I am using that feature to have clothes animated at the same time as the model but everything is skeletal animation.

One thing that you might be doing wrong is the order of shareSkeletonInstanceWith(), I remember having that bit me in the ass at some point.
User avatar
cc9cii
Halfling
Posts: 99
Joined: Tue Sep 18, 2018 4:53 am
x 20

Re: Combining skeletal and vertex animation

Post by cc9cii »

> Sorry for stating the obvious, but did you try to addTime() to both meshes or animation states separately?

Well, there is no point in addTime() since all the animation states are deleted by Ogre::Entity:

Code: Select all

void Entity::shareSkeletonInstanceWith(Entity* entity)
{
    ...

    //check if we already share our skeletoninstance, we don't want to delete it if so
    if (mSharedSkeletonEntities != NULL)
    {
        entity->shareSkeletonInstanceWith(this);
    }
    else
    {
        OGRE_DELETE mSkeletonInstance;
        OGRE_FREE_SIMD(mBoneMatrices, MEMCATEGORY_ANIMATION);
        OGRE_DELETE mAnimationState;
        ...
> Why are you trying to share the skeleton instance?

Since I'm working with Oblivion assets I am not at liberty to change the original designer's choices :-(
I can guess why they might have gone this way, however:
  • All the skeletal animations are applied to one skeleton that is used by almost all the NPC's. (actually there is another skeleton for Khajiit and Argonian, but still, only a few) This allows the same animation to be re-used for everyone, e.g. idle, walk, attack, run, etc. So in the game when you see a bunch of NPC's you actually have the same skeleton doing different stuff (same skeleton but different skeleton instances). Then the game tries to make you think they are different by putting on different skins.
  • The game allows the skeleton to be switched to another mid-game when turning into a werewolf. Many of the skins remain while some are not allowed for werewolves. If the skeleton was not separate from the skins then there would be far too many permutations of skeleton/skin combo.
Now it could very well be that I'm not using Ogre properly - which is why I asked the question here in the forum. There are a few ways I can try:
  • Graft the head mesh to the skeleton - this will go against the idea of keeping a separate skeleton and I may have to "teach" all NPCs how to walk, run, etc, separately instead of doing once for the skeleton.
  • Give the head mesh its own skeleton and during animation copy the bone movements. The head mesh only uses 5 bones for influencing so the overhead might be acceptable. (until there is a crowd of NPCs I guess)
  • Learn how to use Ogre properly. I will investigate if I it is possible to call shareSkeletonInstanceWith() at a different point, but I thought one had to do it when the entity (for the head mesh) was being created?
Again, thanks for taking an interest.
User avatar
cc9cii
Halfling
Posts: 99
Joined: Tue Sep 18, 2018 4:53 am
x 20

Re: Combining skeletal and vertex animation

Post by cc9cii »

A quick update - more testing is needed, but I think I can just re-create the animations manually:

Code: Select all

entity->getMesh()->_initAnimationState(animStateSet);
User avatar
sercero
Bronze Sponsor
Bronze Sponsor
Posts: 450
Joined: Sun Jan 18, 2015 4:20 pm
Location: Buenos Aires, Argentina
x 156

Re: Combining skeletal and vertex animation

Post by sercero »

I think that you should try doing this in phases.

First have a single entity animated only with a skeleton, then have the same entity being animated with only vertex animation.

Then see if you can apply both at the same time using the same method (addTime()? I don't know how it is with vertex animation...)

Then you can go into the trouble of dealing with the shareSkeletonInstanceWith() function and having NPC sharing the same skeleton.

So go from the simple case to the complex one step by step.

I might sound patronizing but sometimes stating the "obvious" can trigger an idea.

Most of the troubles I had with the engine were solved searching in the forums.

Good luck.
User avatar
cc9cii
Halfling
Posts: 99
Joined: Tue Sep 18, 2018 4:53 am
x 20

Re: Combining skeletal and vertex animation

Post by cc9cii »

Good advice, taking small steps is always a good idea. Anyhow, it is working now - here is a short demo

Post Reply