Generic animation support for CEGUI::Window

Discussion regarding the development of CEGUI itself - as opposed to questions about CEGUI usage that should be in the help forums.

Moderators: CEGUI MVP, CEGUI Team

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: Generic animation support for CEGUI::Window

Postby Kulik » Wed Aug 11, 2010 21:00

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

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Generic animation support for CEGUI::Window

Postby CrazyEddie » Thu Aug 12, 2010 12:18

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.

User avatar
emarcotte
Quite a regular
Quite a regular
Posts: 55
Joined: Fri Dec 26, 2008 14:30
Contact:

Re: Generic animation support for CEGUI::Window

Postby emarcotte » Thu Aug 12, 2010 12:42

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:

User avatar
Jabberwocky
Quite a regular
Quite a regular
Posts: 86
Joined: Wed Oct 31, 2007 18:16
Location: Canada
Contact:

Re: Generic animation support for CEGUI::Window

Postby Jabberwocky » Fri Aug 13, 2010 00:06

Agreed - cool addition. Nice to see CE getting a little help on CEGUI core too.
The Salvation Prophecy
Space Combat. Planet Exploration. Strategic Domination.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: Generic animation support for CEGUI::Window

Postby Kulik » Fri Aug 13, 2010 07:28

I am really glad you like it, I had some fun implementing this :-)

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).

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Generic animation support for CEGUI::Window

Postby CrazyEddie » Fri Aug 13, 2010 12:01

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 :D

CE.

r0br0y
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Thu Apr 08, 2010 09:36

Re: Generic animation support for CEGUI::Window

Postby r0br0y » Thu Aug 26, 2010 07:33

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

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: Generic animation support for CEGUI::Window

Postby Kulik » Thu Aug 26, 2010 09:11

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

r0br0y
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Thu Apr 08, 2010 09:36

Re: Generic animation support for CEGUI::Window

Postby r0br0y » Thu Aug 26, 2010 12:54

Ah I see - got it:

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

r0br0y
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Thu Apr 08, 2010 09:36

Re: Generic animation support for CEGUI::Window

Postby r0br0y » Mon Aug 30, 2010 10:05

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

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: Generic animation support for CEGUI::Window

Postby Kulik » Mon Aug 30, 2010 10:36

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 :-)

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...

r0br0y
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Thu Apr 08, 2010 09:36

Re: Generic animation support for CEGUI::Window

Postby r0br0y » Mon Aug 30, 2010 12:06

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...

r0br0y
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Thu Apr 08, 2010 09:36

Re: Generic animation support for CEGUI::Window

Postby r0br0y » Wed Sep 15, 2010 07:52

Hi,

are there any news on fixing the first-animation-frame-lag?

thanks
rob

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: Generic animation support for CEGUI::Window

Postby Kulik » Wed Sep 15, 2010 11:21

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

r0br0y
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Thu Apr 08, 2010 09:36

Re: Generic animation support for CEGUI::Window

Postby r0br0y » Wed Sep 15, 2010 14:48

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...
    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