Animation "Markers"?

Problems building or running the engine, queries about how to use features etc.
Post Reply
BTolputt
Greenskin
Posts: 121
Joined: Thu Feb 18, 2010 8:05 am
x 2

Animation "Markers"?

Post by BTolputt »

I've been looking at the Character Sample for hints/inspiration on how to control a character using OGRE. The first thing that struck me was the fact that there were hard-coded "markers" in the animation, namely the time at when the hands grabbed/released the swords. On seeing this, my first thought was "So how would you apply this to any other character/animation"... the answer, of course, being "You can't" or "Keep the same animation timing for all" - neither of which is the best situation.

While I know I can compile anything I want into my code, and will do so if necessary, I was wondering if there was some built-in OGRE functionality similar to the "animation markers" I am familiar with from the NIF format. That is, there were an array of strings/time pairs, or "animation markers" built into the animation file format. The purpose of these markers was to pass the game engine a string as the animation passed the marker. These could then be used in whatever way the game engine desired, from it being an indicator of grabbing/releasing a weapon or playing a sound effect.

I realise that OGRE is a "rendering engine", not a "game engine" - so this may be outside the desired scope of the library and/or have been dealt with in a different manner somehow more generic than the method I describe. Feel free to point me to a page in the Wiki/manual and tell me to "RTFM" if I missed something obvious; otherwise I'd appreciate hearing what the OGRE method of doing these things might be (should there actually be an OGRE method).

User avatar
MrD
Goblin
Posts: 292
Joined: Wed Oct 21, 2009 3:16 pm
Location: England
x 1

Re: Animation "Markers"?

Post by MrD »

There isn't at present, there is a thread about this somewhere. Adding an animation event system into OGRE so you could register callbacks on an animation frame for certain events (like a footfall) would certainly be a nice feature.
Last edited by MrD on Sun Feb 21, 2010 9:34 pm, edited 1 time in total.
Insimnax Framework - A game framework for OGRE

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Animation "Markers"?

Post by jacmoe »

You can do this easily:

Code: Select all

    if (!treeInsertItem(list, "Animations", depth, TREE_ITEM_TYPE_NONE, false))
    {
        ////////////// DEPTH
        depth ++;

        AnimationStateSet *mAnims = mEntity->getAllAnimationStates();
        if (mAnims)
        {
            AnimationStateIterator ite = mAnims->getAnimationStateIterator();

            if (ite.hasMoreElements())
            {
                treeInsertItem(list, "Default (no anim.)", depth, TREE_ITEM_TYPE_ANIMATION);

                while (ite.hasMoreElements())
                {
                    AnimationStateMap::mapped_type i = ite.getNext();
                    //AnimationStateMap::iterator i = ite.getNext();
                    treeInsertItem(list, i->getAnimationName(), depth, TREE_ITEM_TYPE_ANIMATION);

                }
            }
        }
        else
        {
            treeInsertItem(list, "No animations", depth); 
        }                   
The code is taken from MeshViewerMeshInfo.cpp in https://ogreaddons.svn.sourceforge.net/ ... meshviewer :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

User avatar
MrD
Goblin
Posts: 292
Joined: Wed Oct 21, 2009 3:16 pm
Location: England
x 1

Re: Animation "Markers"?

Post by MrD »

jacmoe wrote:You can do this easily:

Code: Select all

    if (!treeInsertItem(list, "Animations", depth, TREE_ITEM_TYPE_NONE, false))
    {
        ////////////// DEPTH
        depth ++;

        AnimationStateSet *mAnims = mEntity->getAllAnimationStates();
        if (mAnims)
        {
            AnimationStateIterator ite = mAnims->getAnimationStateIterator();

            if (ite.hasMoreElements())
            {
                treeInsertItem(list, "Default (no anim.)", depth, TREE_ITEM_TYPE_ANIMATION);

                while (ite.hasMoreElements())
                {
                    AnimationStateMap::mapped_type i = ite.getNext();
                    //AnimationStateMap::iterator i = ite.getNext();
                    treeInsertItem(list, i->getAnimationName(), depth, TREE_ITEM_TYPE_ANIMATION);

                }
            }
        }
        else
        {
            treeInsertItem(list, "No animations", depth); 
        }                   
The code is taken from MeshViewerMeshInfo.cpp in https://ogreaddons.svn.sourceforge.net/ ... meshviewer :)
Correct me if I'm wrong, but that is just listing the animations on a mesh? That's not what the OP was asking; the OP was asking if there is an easy way to tag frames of animation with information you can use at runtime to perform events without having to set it up yourself using in code using explicit timings.
Insimnax Framework - A game framework for OGRE

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Animation "Markers"?

Post by jacmoe »

Of course there is no way without setting anything up in code.
Of course, you can look into something already cooked for you:
http://www.ogre3d.org/forums/viewtopic.php?f=11&t=45260

If that doesn't fit the bill, use the code to make it fit. :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

User avatar
MrD
Goblin
Posts: 292
Joined: Wed Oct 21, 2009 3:16 pm
Location: England
x 1

Re: Animation "Markers"?

Post by MrD »

That's one of the threads I was looking for. Here is the other http://www.ogre3d.org/forums/viewtopic.php?f=3&t=24106

IMHO the things discussed in that thread would be a really nice feature in OGRE since we have a similar animation event system at work where you can tag frames with callbacks in the animation event editor and then when they are run in code they call the correct callback when the animation plays. Makes tagging animations for footfalls sound effects, or even hit checks on a fully extended arm in a punch animation, a piece of cake. The designers would kill us if we removed it; it got a little bit broke once and they almost skinned us.
Insimnax Framework - A game framework for OGRE

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Animation "Markers"?

Post by jacmoe »

Actually, the Ogre Team has talked about dropping even more animation functionality from the core..
As this is not strictly rendering related, and because it allows you to custom tailor an animation system to your specific needs.
So we should be happy that some functionality exist (still).. :wink:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

User avatar
MrD
Goblin
Posts: 292
Joined: Wed Oct 21, 2009 3:16 pm
Location: England
x 1

Re: Animation "Markers"?

Post by MrD »

Animation is not rendering related, news to me. Do you know what kind of features they are thinking of possibly dropping?

I think one of the problems I see when I see things like this is that I am primarily (when I was at work, and when I go back to work later this year) a tools programmer, so my job is focused on making complex programming things simple for designers and artists to use, while also giving enough power to programmers to do what they need to do. The animation event system is an example of that, a designer or artist does not want to have to mess around setting up manual timings for their animations just so they can make something happen, they just want to be able to say "on this frame, I want it to do this" and not care how that gets done. That's where tools programmers come in, to translate that designers requirement into something that eventually gets run in the engine in an efficient manner. By comparison engine programmers are more concerned with doing things as efficiently as possible, while giving the games programmers the most empowerment and flexibility they can; so in that regard I can understand why the OGRE team would want to drop their own animation stuff in favour of letting people implement their own. As a tools programmer it makes me cry since it means me having to put on my engine programmer hat and implement a low-level animation system, as a games programmer is makes me happy since I have the flexibility to do it exactly how I want.

I am actually doing my final year dissertation on visual scripting systems that let designers create in-game logic without needing to know much about programming, or how the system works internally. That however is another topic entirely ;)
Insimnax Framework - A game framework for OGRE

BTolputt
Greenskin
Posts: 121
Joined: Thu Feb 18, 2010 8:05 am
x 2

Re: Animation "Markers"?

Post by BTolputt »

Thanks for the links - I shall look at them tonight after dinner. I pretty much assumed there was no code that did this already built into OGRE, but didn't want to reinvent the wheel if it was something already there.

That said, removing animation from OGRE is not something I think terribly wise. Not simply because it is something I want (the existing code could always be ported over to the new OGRE if it was removed); but because animation is now tied up in the rendering abstraction - especially/particularly if one is using skeletal animation. Were animation a CPU-only event, I could understand it but OGRE abstracts the underlying rendering API (relatively well I might add) and should it not handle matrix skinning (and the like) transparently, developers would have to dig into the guts of OGRE to get decent frame rates out of it again.

Technically speaking, one might say that loading resources is not "rendering related" either and yet there has been significant amount of work putting together the threaded background loading. Narrowing the definition of "rendering" to remove animation would remove alot of other functionality as well.

User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Re: Animation "Markers"?

Post by xavier »

BTolputt wrote:but because animation is now tied up in the rendering abstraction - especially/particularly if one is using skeletal animation. Were animation a CPU-only event, I could understand it but OGRE abstracts the underlying rendering API (relatively well I might add) and should it not handle matrix skinning (and the like) transparently, developers would have to dig into the guts of OGRE to get decent frame rates out of it again.
It doesn't have to be. I use Havok for animation and do GPU skinning just fine (including shadows and self-shadowing). At the end of the day (or frame), all that a skeletal animation system needs to provide the renderer is the updated bone transforms -- just a list of matrices, in other words. That's all a matrix palette is, after all.

Animation could easily be removed from the Ogre rendering core, and left in the distribution as a component, or other form of adjunct library.
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.

BTolputt
Greenskin
Posts: 121
Joined: Thu Feb 18, 2010 8:05 am
x 2

Re: Animation "Markers"?

Post by BTolputt »

xavier wrote:It doesn't have to be.
I'm not debating that, but it seems a little odd to remove animation whilst working on the threading & background loading functionality (for example). To repeat myself: "Narrowing the definition of "rendering" to remove animation would remove alot of other functionality as well."

Perhaps to rephrase my issue: Why is animation considered "non-rendering related functionality" when there are features being added & improved even less related to "rendering functionality?

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Animation "Markers"?

Post by jacmoe »

What features? :)
If the animation was turned into a component/plugin, we could have our cake and eat it too.
Xavier could use Havok, you could use the Ogre animation component, allowing for total freedom.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

BTolputt
Greenskin
Posts: 121
Joined: Thu Feb 18, 2010 8:05 am
x 2

Re: Animation "Markers"?

Post by BTolputt »

jacmoe wrote:What features? :)
OK, I'm going to assume that you are not pulling my chain (cos picking on the forum "new guy" is not good manners ;) ) and repeat myself:
...yet there has been significant amount of work putting together the threaded background loading. and
...it seems a little odd to remove animation whilst working on the threading & background loading functionality (for example)...

We know that this is being / will be worked on by Steve/sinbad and yet it is further removed from rendering (especially given the generally serial GPU command queue) than animation is. My point is that this concept of "removing non-render related code" seems to be applied inconsistently. From an outside perspective (which is really all we have here on the forums ;) ), it seems that the argument given for animation removal is an excuse when it is ignored for other features in active development.
jacmoe wrote:If the animation was turned into a component/plugin, we could have our cake and eat it too.
Xavier could use Havok, you could use the Ogre animation component, allowing for total freedom.
My understanding of his post is that he already is successfully using Havok. Note, I don't have a particular argument for the animation not being a component/plugin (so long as the exporters and so on continue to work as expected). After all, I can see that Terrain is still actively maintained & improved on. The Sample_Terrain shows how to use it properly and I assume that if animation were to be split out - there would be a similar pattern applied to it's functionality. What I have a (minor) concern about is, simply, that the purity of OGRE's functionality is not the primary reason for the push to remove animation as a core feature.

Update:
To use the reasoning provided for removing animation, OGRE should also have the following removed:
  • Resource Loading: After all, loading a mesh is not actually related to rendering it and can be left to the end-user.
  • Threading & Work Queues: As we don't need threads to render graphics, only (really) to handle the interleaving of application tasks.
  • Particles, Billboards, & GUI code: After all, if "animation" is not classified as a pure enough "render related functionality" (requiring only some matrix parameters to the vertex shader, as I am told ;) ), the same argument follows for these application specific features.
It should be obvious that (in my opinion) there are some elements created for & kept in OGRE that are not solely for their "rendering related functionality", but to make the library easier to use. I believe animation is one of those features (it IS a significant section on the OGRE Features page).

User avatar
gmfreaky
Halfling
Posts: 56
Joined: Tue Feb 02, 2010 6:49 pm

Re: Animation "Markers"?

Post by gmfreaky »

Why would you want that to be removed :shock:

Post Reply