Generic animation support for CEGUI::Window
Moderators: CEGUI MVP, CEGUI Team
Re: Generic animation support for CEGUI::Window
http://harcov.czenet.com/kulik/CEGUI/anims3.patch - latests and greatest, doesn't include xml. Eddie added xml support today, it will most likely be commited tomorrow. HTH
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Generic animation support for CEGUI::Window
The initial implementation of the animation support has been committed to branches/v0-7 @ r2590. This includes everything needed to animate from code and xml. There's still a few other bits to be added, like XML format documentation, adding this support to the lua binding and other such things which will get done over the coming days or so.
CE.
CE.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: Generic animation support for CEGUI::Window
I just wanted to say that this API is really nicely presented from the little sample you gave on IRC. I slapped it onto one of the CEGUI demos and it definitely makes things feel much more "shiney" with very little effort.
Awesome work to all involved.![Hammer :hammer:](./images/smilies/hammer.gif)
Awesome work to all involved.
![Hammer :hammer:](./images/smilies/hammer.gif)
- Jabberwocky
- Quite a regular
- Posts: 86
- Joined: Wed Oct 31, 2007 18:16
- Location: Canada
- Contact:
Re: Generic animation support for CEGUI::Window
Agreed - cool addition. Nice to see CE getting a little help on CEGUI core too.
The Salvation Prophecy
Space Combat. Planet Exploration. Strategic Domination.
Space Combat. Planet Exploration. Strategic Domination.
Re: Generic animation support for CEGUI::Window
I am really glad you like it, I had some fun implementing this ![Smile :-)](./images/smilies/icon_smile.gif)
Please give it a proper testing, there are likely to be bugs and I would like to have as many fixed as possible before this gets released.
Plus I am announcing the "Animation contest". Who does the coolest looking but not overly disturbing usable animation, wins the special and unique opportunity to have his animation in the animation demo - you can't pass on that (hope CE is ok with that).
Future ideas:
KeyFrames should be able to symlink to properties. This allows some dynamic animations where you can set the property to target value and then just run the animation. Should keep the neccessary animation count down. ("Alpha" is 1.0, set "NewAlpha" to 0.5 and just run the "Fade" animation)
Event system could be adapted to support event chaining/linking. For example: "TabControl". You have a selected tab. You click a different tab and now the old tab fades out and the new fades in. This is not currently possible because the tab is selected immediately by CEGUI. So the only option is to fade in the new tab.
Still not sure about this - Affectors should be able to affect properties of child windows of the target window. This can already be done by doing 2 animations and starting them at once (subscribing them to the same events or starting manually).
![Smile :-)](./images/smilies/icon_smile.gif)
Please give it a proper testing, there are likely to be bugs and I would like to have as many fixed as possible before this gets released.
Plus I am announcing the "Animation contest". Who does the coolest looking but not overly disturbing usable animation, wins the special and unique opportunity to have his animation in the animation demo - you can't pass on that (hope CE is ok with that).
Future ideas:
KeyFrames should be able to symlink to properties. This allows some dynamic animations where you can set the property to target value and then just run the animation. Should keep the neccessary animation count down. ("Alpha" is 1.0, set "NewAlpha" to 0.5 and just run the "Fade" animation)
Event system could be adapted to support event chaining/linking. For example: "TabControl". You have a selected tab. You click a different tab and now the old tab fades out and the new fades in. This is not currently possible because the tab is selected immediately by CEGUI. So the only option is to fade in the new tab.
Still not sure about this - Affectors should be able to affect properties of child windows of the target window. This can already be done by doing 2 animations and starting them at once (subscribing them to the same events or starting manually).
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Generic animation support for CEGUI::Window
Kulik wrote:Plus I am announcing the "Animation contest". Who does the coolest looking but not overly disturbing usable animation, wins the special and unique opportunity to have his animation in the animation demo - you can't pass on that (hope CE is ok with that).
This gets the official CE seal of approval
![Very Happy :D](./images/smilies/icon_biggrin.gif)
CE.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: Generic animation support for CEGUI::Window
Just some feedback:
The animation-stuff works really good for me - thanks much for sharing!
But I've noticed that the boolinterpolator checks if the absolute keyframe position is greater than 0.5 to go from true to false (or vice versa). So all bool values are toggled always after 0.5sec...
Maybe it would be better to have the transition after half of the animation-duration? Or maybe I missed sth?
thanks
rob
The animation-stuff works really good for me - thanks much for sharing!
But I've noticed that the boolinterpolator checks if the absolute keyframe position is greater than 0.5 to go from true to false (or vice versa). So all bool values are toggled always after 0.5sec...
Maybe it would be better to have the transition after half of the animation-duration? Or maybe I missed sth?
thanks
rob
Re: Generic animation support for CEGUI::Window
r0br0y:
Thanks for the feedback!
The position between 2 keyframes is always scaled down to <0.0, 1.0> to make things easier for the interpolators. If you want bool value to change after it has reached the keyframe, try discrete progression.
I also started some crude documentation on wiki http://www.cegui.org.uk/wiki/index.php/Animation_System
Thanks for the feedback!
The position between 2 keyframes is always scaled down to <0.0, 1.0> to make things easier for the interpolators. If you want bool value to change after it has reached the keyframe, try discrete progression.
I also started some crude documentation on wiki http://www.cegui.org.uk/wiki/index.php/Animation_System
Re: Generic animation support for CEGUI::Window
Ah I see - got it:
Works like a charme!
Thanks again
Code: Select all
<Affector property="Visible" interpolator="bool">
<KeyFrame position="0" value="true" />
<KeyFrame position="0.5" value="false" progression="discrete" />
</Affector>
Works like a charme!
Thanks again
Re: Generic animation support for CEGUI::Window
Hi Kulik,
I use the animations to fade-in windows that I generate just before the animation start (=same frame) . So if the generation-process is more complex the current frame lasts longer and with that the time-delta that is injected into the animationmanager is higher.
Sometimes this results in visually shifted or even skipped animations (if duration is short and time-delta high).
Maybe it's possible to skip the first frame when an animations starts or add the first time-delta to the duration?
thanks
rob
I use the animations to fade-in windows that I generate just before the animation start (=same frame) . So if the generation-process is more complex the current frame lasts longer and with that the time-delta that is injected into the animationmanager is higher.
Sometimes this results in visually shifted or even skipped animations (if duration is short and time-delta high).
Maybe it's possible to skip the first frame when an animations starts or add the first time-delta to the duration?
thanks
rob
Re: Generic animation support for CEGUI::Window
r0br0y: Subscribe the animations to "Shown" event, this way the animation is started when the window is ready and shown, just make sure the window is invisible and you set it to visible when everything is ready. I do it all the time and it works for me ![Smile :-)](./images/smilies/icon_smile.gif)
EDIT: I've given it some thought and I may have misunderstood your problem. This indeed happens currently. I think the solution would be to include some option to skip the first stepping of animation instance after start. This is a hack though, I have to think of something more clean and powerful...
![Smile :-)](./images/smilies/icon_smile.gif)
EDIT: I've given it some thought and I may have misunderstood your problem. This indeed happens currently. I think the solution would be to include some option to skip the first stepping of animation instance after start. This is a hack though, I have to think of something more clean and powerful...
Re: Generic animation support for CEGUI::Window
Kulik wrote:EDIT: I've given it some thought and I may have misunderstood your problem. This indeed happens currently. I think the solution would be to include some option to skip the first stepping of animation instance after start. This is a hack though, I have to think of something more clean and powerful...
Yes, that's what I ment.
Maybe the first time-delta should be ignored (or set to 0). This would allow the animatin to start at position 0 (what make sense to me) and solves my problem at the same time...
Re: Generic animation support for CEGUI::Window
Hi,
are there any news on fixing the first-animation-frame-lag?
thanks
rob
are there any news on fixing the first-animation-frame-lag?
thanks
rob
Re: Generic animation support for CEGUI::Window
I have zero free time right now but I somehow assembled a patch that *should* fix this. It received very very little testing, please report if this works for you. If this works, I think it can be commited, it doesn't break anything.
http://harcov.czenet.com/kulik/CEGUI/skip_first_step.patch
http://harcov.czenet.com/kulik/CEGUI/skip_first_step.patch
Re: Generic animation support for CEGUI::Window
Hi Kulik,
thanks for the support and the patch!
Unfortuantely it doesn't fix my problem as framerate-drops more than one frame and by skipping the first frame position never becomes 0 (that should be the supported imo).
So I made some changes that...
Diff on trunk:
regards
rob
thanks for the support and the patch!
Unfortuantely it doesn't fix my problem as framerate-drops more than one frame and by skipping the first frame position never becomes 0 (that should be the supported imo).
So I made some changes that...
- 1. ...set the time-delta to 0 on first frame instead of skipping the whole step
- 2. ...do an aditional check if the time-delta is bigger than the duration and skips the whole step if so. That works great for me and I have nice animations even after complex loadings in debug!
Well of course I'm aware that this additional check could result in a never starting/advancing/ending animation if duration is very very short and framerate always low.
Although I can't think of any case this could ever happen, I'm not 100% happy about it... would do you think?
Diff on trunk:
Code: Select all
Index: cegui/include/CEGUIAnimationInstance.h
===================================================================
--- cegui/include/CEGUIAnimationInstance.h (revision 2619)
+++ cegui/include/CEGUIAnimationInstance.h (working copy)
@@ -183,10 +183,13 @@
\brief
Starts this animation instance - sets position to 0.0 and unpauses
+ \param
+ enableFirstStep if true the first step/frame is shown
+
\par
This also causes base values to be purged!
*/
- void start();
+ void start(bool enableFirstStep = true);
/*!
\brief
@@ -203,14 +206,21 @@
/*!
\brief
Unpauses this animation instance - allows it to step forward again
+
+ \param
+ enableFirstStep if true the first step/frame is shown
*/
- void unpause();
+ void unpause(bool enableFirstStep = true);
/*!
\brief
Pauses the animation if it's running and unpauses it if it isn't
+
+ \param
+ enableFirstStep if true the first step/frame is shown
+ (only applies when unpausing!)
*/
- void togglePause();
+ void togglePause(bool enableFirstStep = true);
/*!
\brief
@@ -330,6 +340,8 @@
bool d_bounceBackwards;
//! true if this animation is unpaused
bool d_running;
+ //! skip next update (true if the next update should be skipped entirely)
+ bool d_firstStep;
typedef std::map<String, String> PropertyValueMap;
/** cached saved values, used for relative application method
Index: cegui/src/CEGUIAnimationInstance.cpp
===================================================================
--- cegui/src/CEGUIAnimationInstance.cpp (revision 2619)
+++ cegui/src/CEGUIAnimationInstance.cpp (working copy)
@@ -58,7 +58,8 @@
d_position(0.0),
d_speed(1.0),
d_bounceBackwards(false),
- d_running(false)
+ d_running(false),
+ d_firstStep(false)
{}
//----------------------------------------------------------------------------//
@@ -185,10 +186,11 @@
}
//----------------------------------------------------------------------------//
-void AnimationInstance::start()
+void AnimationInstance::start(bool skipNextStep)
{
setPosition(0.0);
d_running = true;
+ d_firstStep = skipNextStep;
onAnimationStarted();
}
@@ -208,14 +210,15 @@
}
//----------------------------------------------------------------------------//
-void AnimationInstance::unpause()
+void AnimationInstance::unpause(bool enableFirstStep)
{
d_running = true;
+ d_firstStep = enableFirstStep;
onAnimationUnpaused();
}
//----------------------------------------------------------------------------//
-void AnimationInstance::togglePause()
+void AnimationInstance::togglePause(bool enableFirstStep)
{
if (isRunning())
{
@@ -223,7 +226,7 @@
}
else
{
- unpause();
+ unpause(enableFirstStep);
}
}
@@ -242,6 +245,22 @@
return;
}
+ const float duration = d_definition->getDuration();
+
+ // If time-delta is bigger than the duration this step is skipped.
+ // This gets rid of annoying animation skips when FPS gets too low e.g. after complex layout loading, etc...
+ if (delta > duration)
+ {
+ return;
+ }
+
+ // If firstStep is enabled the time-delta is set to 0 to allow starting at position=0
+ if (d_firstStep)
+ {
+ d_firstStep = false;
+ delta = 0;
+ }
+
if (delta < 0.0f)
{
CEGUI_THROW(InvalidRequestException(
@@ -250,8 +269,6 @@
"trying!"));
}
- const float duration = d_definition->getDuration();
-
// we modifty the delta according to playback speed
delta *= d_speed;
regards
rob
Return to “CEGUI Library Development Discussion”
Who is online
Users browsing this forum: No registered users and 3 guests