Animation frame callbacks
- KungFooMasta
- OGRE Contributor
- Posts: 2087
- Joined: Thu Mar 03, 2005 7:11 am
- Location: WA, USA
- x 16
- Contact:
- Bren
- Goblin
- Posts: 215
- Joined: Tue Jul 08, 2003 4:41 pm
- Location: 0,0,0
- Contact:
- RedEyeCoder
- Gnome
- Posts: 344
- Joined: Sat Jun 16, 2007 7:29 am
- Location: Brisbane, Australia
Re: Animation frame callbacks
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.
- sinbad
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
- Contact:
Re: Animation frame callbacks
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
- evilshadow
- Kobold
- Posts: 26
- Joined: Sat Dec 20, 2008 4:29 pm
- Location: Asia
Re: Animation frame callbacks
Are there any progressing about this topic yet ?
The dark side of the moon...
-
- Greenskin
- Posts: 121
- Joined: Thu Feb 18, 2010 8:05 am
- x 2
Re: Animation frame callbacks
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
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.
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.
- sinbad
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
- Contact:
Re: Animation frame callbacks
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
- dark_sylinc
- OGRE Team Member
- Posts: 5299
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1279
- Contact:
Re: Animation frame callbacks
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:
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
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 );
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
-
- Greenskin
- Posts: 121
- Joined: Thu Feb 18, 2010 8:05 am
- x 2
Re: Animation frame callbacks
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.
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.
- Klaim
- Old One
- Posts: 2565
- Joined: Sun Sep 11, 2005 1:04 am
- Location: Paris, France
- x 56
- Contact:
Re: Animation frame callbacks
dark_sylinc> You should provide a patch then. As Sinbad said, there are other priorities and providing a patch woudld be helpful.