Animation frame callbacks

What it says on the tin: a place to discuss proposed new features.
User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
Posts: 2087
Joined: Thu Mar 03, 2005 7:11 am
Location: WA, USA
Contact:

Post by KungFooMasta » Tue Sep 19, 2006 12:14 am

Thanks for pointing that out, I feel dumb now :shock:

I guess a simple wrapper with a list is the best solution... at least until I can investigate further.

KungFooMasta
0 x

User avatar
Bren
Goblin
Posts: 215
Joined: Tue Jul 08, 2003 4:41 pm
Location: 0,0,0
Contact:

Post by Bren » Thu Nov 16, 2006 1:27 am

Did anybody get anywhere with this? I've been thinking about event tagging in animations recently...
0 x

User avatar
RedEyeCoder
Gnome
Posts: 344
Joined: Sat Jun 16, 2007 7:29 am
Location: Brisbane, Australia

Re: Animation frame callbacks

Post by RedEyeCoder » Tue Jul 14, 2009 6:36 am

This thread is really old however I am looking at the same problem myself. Is anyone aware if any work ever went into this? I have browsed through the source and searched the forums but there is no evidence that this is yet supported. I tend to still agree with what Sinbad and others said about creating a wrapper object around AnimationState which stores a list of time/events.
0 x

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19261
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
Contact:

Re: Animation frame callbacks

Post by sinbad » Wed Jul 15, 2009 6:10 pm

It comes up now and again, almost made it into a GSoC project this year, but really on its own is not big enough. It probably isn't a huge amount of work, it just needs someone with an itch to scratch to put it to bed ;)
0 x

User avatar
evilshadow
Kobold
Posts: 26
Joined: Sat Dec 20, 2008 4:29 pm
Location: Asia

Re: Animation frame callbacks

Post by evilshadow » Wed Dec 16, 2009 7:11 am

Are there any progressing about this topic yet ? :)
0 x
The dark side of the moon...

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

Re: Animation frame callbacks

Post by BTolputt » Mon Feb 22, 2010 7:24 am

I get the impression from another thread that the addition is not actually desired in OGRE by the core dev(s). Which conflicts a little with what Sinbad said near the beginning of the thread... but that was some years ago now :P

If a clear set of requirements were written up (i.e. a common base from which we can all work from, not a wish-list from specific projects); I'd be interested in contributing something. As mentioned above, it probably won't make it into OGRE in & of itself; but I need it for my project(s) and so it will be at least up to date on the OGRE wiki if desired.
0 x

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19261
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
Contact:

Re: Animation frame callbacks

Post by sinbad » Tue Feb 23, 2010 12:52 pm

No, I can see a use for it certainly. Mostly it's about time & other priorities; as an open source project the things that get done in volunteer time are necessarily the things that developers either need themselves, or are curious about. The easiest way to get a new feature done is to submit a patch, or convince a developer that it's more exciting than the 500 other things they have in their head right now. Or pay them of course ;)
0 x

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

Re: Animation frame callbacks

Post by dark_sylinc » Thu Mar 04, 2010 4:47 am

I'm passing by over this forum and couldn't help notice this thread.

Is this that a big deal???
I mean, I've got this problem too, but since animation in Ogre is already handled manually (call animationState->addTimePos( time ) ) I just keep an external counter and handle this myself. I've tackled this in two projects already.

Building a very flexible animation system over OGRE's to handle sound & particle FXs can be very easy.

A basic version of the code looks like this, I just wrote it for the purpose of this forum but you'll get the idea:

Code: Select all

struct AnimationContainer
{
    float fTime; //Time where this container is triggered
    CallBackClass *callback;
};

std::vector<AnimationContainer> m_container; //Contains multiple animations & fx
std::vector<AnimationState> animationsToPlay;

//In update...
for( int i=0; i<m_container.size(); i++ )
{
    if( timePos > m_container[i].fTime )
       break;
     if( m_container[i].animationName != "" )
     {
          entity->getAnimationState( m_container[i].animationName )->setEnabled( true );
          animationsToPlay.push_back( entity->getAnimationState( m_container[i].animationName ) );
     }

     if( !m_container[i].callback )
            m_container[i].callback->call( timePos )
}

for( int i=0; i<animationsToPlay.size(); i++ )
      animationsToPlay[i]->setTimePos( timePos );
When you want one animation and multiple callbacks, just leave blank ("") the text fields for the variables you don't use.
You can extend the idea and use other stuff (i.e. use a common base class with Derived classes to handle animations, pfxs, and sounds separately, without wasting memory space for unused variables in a unified struct like I'm doing)

Bottom line, this is one of the areas where OGRE leaves you complete low level control of what you can do, while yet still being easy to work with (low level usually means messy code, but this time it doesn't). So I don't see the point of implementing animation frame callbacks in a generic way.
Animation is a complex problem which can't be solved generically. I admit though, for the rushed developer a simple system could get the job done, but not for any serious or advanced animation development.

Cheers
Dark Sylinc
0 x

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

Re: Animation frame callbacks

Post by BTolputt » Thu Mar 04, 2010 7:26 am

The (admittedly minor) issue with us all doing it ourselves is that we would all write our own exporters for this information. I know the code is trivial, I've already written something similar, but it would be nice to export this information from the content creation program of our choice (Blender, MAX, Maya, etc) along with the mesh, skeleton, and other animation data.

The reason I can see this being common amongst all applications is that all the sounds, physics, game code etc can easily be retrieved from a basic string associated with a given time offset into the animation. Want to play a sound on the footfall section of the animation, attach a string to time X with data "playSound:footfall.wav". Want the frame where the gun starts to recoil to be when the game fires the bullet, attach a string to time Y with data "game:gunFire". Want to play the gunshot noise at the same time, add in the "playSound" tag after a carriage return.

Sure, the tags will be game specific but we've already established this was going to be the case. However, I am pretty sure that the convenience of having the artists tag frames/times in the content creation would be much more intuitive than having to edit an external text file and/or use a tool solely for this purpose. I'm considering the savings across multiple art pipelines rather than the technical difficulty of each developer writing their own runtime loader/handler for it.
0 x

User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
Contact:

Re: Animation frame callbacks

Post by Klaim » Thu Mar 04, 2010 9:55 am

dark_sylinc> You should provide a patch then. As Sinbad said, there are other priorities and providing a patch woudld be helpful.
0 x

Post Reply