[solved] How to Animate gifs

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
spracle
Not too shy to talk
Not too shy to talk
Posts: 34
Joined: Tue Aug 24, 2010 07:29

[solved] How to Animate gifs

Postby spracle » Thu Sep 02, 2010 06:45

hi~I know 0.7.2 added animation system, but I'm still confused about how to animate gifs in cegui?

Anyone could help me,here?
Last edited by spracle on Mon Nov 01, 2010 12:33, edited 1 time in total.

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

Re: How to Animate gifs

Postby CrazyEddie » Thu Sep 02, 2010 09:06

You can not directly use animated 'gif' files, this will probably never change; CEGUI does not work like that.

To do image flipping animation, you need to load the images to be used as Images defined on an Imageset (it could be possible to have your own code that would return an appropriate Imageset given a .gif file, but this is not provided within CEGUI). You can then use those Image names within the animation system to flip to the new image at an appropriate time. I can't give a concrete example at the moment, but play around with it, and if you can't figure it out, post what you have and someone will point you in the right direction.

CE.

User avatar
spracle
Not too shy to talk
Not too shy to talk
Posts: 34
Joined: Tue Aug 24, 2010 07:29

Re: How to Animate gifs

Postby spracle » Fri Sep 03, 2010 03:03

Seem that I kind of understand how Animation System works,and i tested it in the ceguiSamples

Changed code of "Sample_FirstWindow.cpp" in Sample_firstWindow is following:

Code: Select all

#include "Sample_FirstWindow.h"
#include "CEGUI.h"

int main(int /*argc*/, char* /*argv*/[])
{

   FirstWindowSample app;
   return app.run();
}

bool FirstWindowSample::initialiseSample()
{
   using namespace CEGUI;

   CEGUI::Animation* anim = CEGUI::AnimationManager::getSingleton().createAnimation("Testing");
   anim->setDuration(0.3f); // duration in seconds
   anim->setReplayMode(CEGUI::Animation::RM_Once); // when this animation is started, only play it once, then stop

   CEGUI::Affector* affector1 = anim->createAffector("YRotation", "float");
   affector1->createKeyFrame(0.0f, "0.0");
   affector1->createKeyFrame(0.3f, "10.0", CEGUI::KeyFrame::P_QuadraticAccelerating);


   CEGUI::Affector* affector2 = anim->createAffector("Alpha", "float");
   affector2->createKeyFrame(0.0f, "1.0"); // at 0.0 seconds, set alpha to 0.5
   affector2->createKeyFrame(0.3f, "0.5", CEGUI::KeyFrame::P_QuadraticDecelerating); // at 1.0 seconds, set alpha to 1.0, now decelerating!

   CEGUI::Affector* affector3 = anim->createAffector("Text", "float");
   affector3->createKeyFrame(0.0f, "AAAA"); // at 0.0 seconds, set alpha to 0.5
   affector3->createKeyFrame(0.3f, "BBBB", CEGUI::KeyFrame::P_QuadraticDecelerating);

   CEGUI::Affector* affector4 = anim->createAffector("Visible", "bool");
   affector4->createKeyFrame(0.0f, "true"); // at 0.0 seconds, set alpha to 0.5
   affector4->createKeyFrame(0.3f, "false", CEGUI::KeyFrame::P_QuadraticDecelerating);

   SchemeManager::getSingleton().create("TaharezLook.scheme");

   System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");

   WindowManager& winMgr = WindowManager::getSingleton();
   DefaultWindow* root = (DefaultWindow*)winMgr.createWindow("DefaultWindow", "Root");
   CEGUI::Font& font = FontManager::getSingleton().createFreeTypeFont("DefaultFont", 10/*pt*/, true, "simhei.ttf");
   System::getSingleton().setDefaultFont("DefaultFont");

   System::getSingleton().setGUISheet(root);

   FrameWindow* wnd = (FrameWindow*)winMgr.createWindow("TaharezLook/FrameWindow", "Demo Window");

   root->addChildWindow(wnd);

   CEGUI::AnimationInstance* instance = CEGUI::AnimationManager::getSingleton().instantiateAnimation(anim);

   instance->setTargetWindow(wnd);

   instance->start();

   wnd->setPosition(UVector2(cegui_reldim(0.25f), cegui_reldim( 0.25f)));
   wnd->setSize(UVector2(cegui_reldim(0.5f), cegui_reldim( 0.5f)));

   wnd->setMaxSize(UVector2(cegui_reldim(1.0f), cegui_reldim( 1.0f)));
   wnd->setMinSize(UVector2(cegui_reldim(0.1f), cegui_reldim( 0.1f)));


   wnd->subscribeEvent(CEGUI::Window::EventMouseEntersArea, CEGUI::Event::Subscriber(&CEGUI::AnimationInstance::handleStart, instance));

   return true;
}
void FirstWindowSample::cleanupSample()
{
   // nothing to do here!
}



But it couldn't work .Did I miss something?

User avatar
spracle
Not too shy to talk
Not too shy to talk
Posts: 34
Joined: Tue Aug 24, 2010 07:29

Re: How to Animate gifs

Postby spracle » Fri Sep 03, 2010 09:05

hoho~ Problems solved :D
It's about "injectTimepulse()" function, and it's my problem~

ogre2012
Not too shy to talk
Not too shy to talk
Posts: 21
Joined: Wed Mar 23, 2011 07:55

Re: [solved] How to Animate gifs

Postby ogre2012 » Wed Mar 23, 2011 09:04

1.first ,you must read this article
http://www.cegui.org.uk/wiki/index.php/Animation_System
you can find the resource in this web
http://u.115.com/file/f9f717c629
the layout's name is Format.layout.

2.you can add the following in the VanillaSkin.scheme file( "the Vanilla/StaticImage")

Code: Select all

<Animations>
         <AnimationDefinition name="Testing" duration="0.3" replayMode="once">
              <Affector property="Image" interpolator="String">
                   <KeyFrame position="0.1" value="set:guangbiao image:NewImage1" />
                   <KeyFrame position="0.2" progression="discrete" value="set:guangbiao image:NewImage2" />
                   <KeyFrame position="0.3" progression="discrete" value="set:guangbiao image:NewImage3" />
                </Affector>
            <Affector property="Alpha" interpolator="float">
               <KeyFrame position="0.0" value="1.0" />
               <KeyFrame position="0.3" value="0.5" />
            </Affector>
            <Affector property="XRotation" interpolator="float">
               <KeyFrame position="0.0" value="0" />
               <KeyFrame position="0.3" value="10" />
            </Affector>
            <Affector property="Text" interpolator="String">
               <KeyFrame position="0.0" value="AAAA" />
               <KeyFrame position="0.3" value="BBBB" />
            </Affector>
         </AnimationDefinition>
      </Animations>

3. in the Sample_FalagardDemo1.cpp file

CEGUI::Window* imageComponent;

Code: Select all

{
      // this affector will again use String to change the Image
      CEGUI::Affector* affector = anim->createAffector("Image", "String");

      affector->createKeyFrame(0.1f, "set:guangbiao image:NewImage1"); // at 0.1 seconds
      affector->createKeyFrame(0.2f, "set:guangbiao image:NewImage2", CEGUI::KeyFrame::P_Linear); // at 0.2 seconds
       affector->createKeyFrame(0.3f, "set:guangbiao image:NewImage3", CEGUI::KeyFrame::P_Linear);
   }

   //CEGUI::MouseCursor

   instance = CEGUI::AnimationManager::getSingleton().instantiateAnimation(anim);
   // after we instantiate the animation, we have to set its target window
   instance->setTargetWindow(imageComponent);  //textComponent  imageComponent

4. you can used the file in my resource.rar.

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

Re: [solved] How to Animate gifs

Postby Kulik » Thu Mar 24, 2011 16:48

Just for the record, you have to define the animation once, via C++ code (or python/lua) OR via XML (looknfeel, animations.xml). You can do it twice but it's kind of wasteful. I also can't figure out how you start the animation. You have to either instance->start() or subscribe the "Start" action to some Event.

jack1104
Just popping in
Just popping in
Posts: 11
Joined: Fri Nov 04, 2011 13:24

Re: [solved] How to Animate gifs

Postby jack1104 » Thu Nov 17, 2011 08:06

Hello,

I'm trying make an icon with changing image, I reference the code by ogre2012 in my WidgetLook:

Code: Select all

<WidgetLook name="game1/Button">
...
<AnimationDefinition name="Testing" duration="0.3" replayMode="once">
              <Affector property="Image" interpolator="String">
                   <KeyFrame position="0.1" value="set:game1 image:myImage1" />
                   <KeyFrame position="0.2" progression="discrete" value="set:game1 image:myImage2" />
                   <KeyFrame position="0.3" progression="discrete" value="set:game1 image:myImage3" />
              </Affector>
...
<Subscription event="MouseEntersArea" action="Start" />
...
</WidgetLook>


But I get an error at CEGUIPropertySet.cpp line 124:

Code: Select all

CEGUI_THROW(UnknownObjectException("There is no Property named '" + name + "' available in the set."));

name = "image" occur an error here.
But I try the name(<Affector property>) = "float", "UnifiedHeight"...etc, is working no problem.

I have no idea how "There is no Property named '" + name + "' available in the set." happened.
I'm new with CEGUI and my english is poor, forgive me :oops:

Can anyone help me?

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

Re: [solved] How to Animate gifs

Postby CrazyEddie » Thu Nov 17, 2011 09:17

Don't double-post (especially not into other peoples topics). One and only warning ;)

Thanks

CE.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 4 guests