Animated texture

kingdranix

31-03-2009 01:20:25

Does QuickGUI support animated textures like gif or image strip for buttons and widgets?
If it does, how can it be done?

Cheers

kungfoomasta

31-03-2009 02:16:37

Whats an Image strip? I have not tried gif files, does Ogre support loading of gif files? I'm using the Ogre system for loading of textures, so QuickGUI will support anything Ogre supports.

kingdranix

31-03-2009 05:58:50

Whats an Image strip?
It is like a comic strip where the animated image are in a row on a single texture.
I manage to do this using a 2D Sprite Manager from the wiki using a png image strip
but not the animated gif image.
So I'm wondering if the buttons can have an animated texture despite using skins.

kungfoomasta

31-03-2009 08:19:01

So you have a lot of images, right? I could implement this, but it will require the Window's texture to be redrawn each frame, which will take up some additional resources. I'd probably add it to the SkinElement definition.

Currently:

SkinElement default
{
Border_Bottom 2
Border_Left 2
Border_Right 2
Border_Top 2
Texture qgui.button.png
TileBackground false
TileBorders true
}


Idea:

SkinElement default
{
Border_Bottom 2
Border_Left 2
Border_Right 2
Border_Top 2
NumberOfFrames 0
Texture qgui.button.png
TileBackground false
TileBorders true
}


I'd have to think about it some more. I doubt I could implement this anytime soon, tho.

kingdranix

31-03-2009 15:28:45

I've manage to create the effect using this codes. Not sure if this is a good way.

if(Ogre::Root::getSingletonPtr()->getTimer()->getMilliseconds() > prevTime + 500) {
QuickGUI::SkinElement *tempPtr = QuickGUI::SkinTypeManager::getSingletonPtr()->getSkinType("Button",
Start->getSkinTypeName())->getSkinElement("default");
tempPtr->setTextureName( Ogre::StringConverter::toString(test)+".png" );
if(++test > 2) test = 1;
tempPtr ->getTextureImage();
prevTime = Ogre::Root::getSingletonPtr()->getTimer()->getMilliseconds();
Start->redraw();
}


I wish ogre could display animated gif instead of just displaying the first frame of the gif.

kungfoomasta

31-03-2009 18:50:25

Ah, pretty cool! Great that you dug in and found a way to do it. :)

I was thinking more along a general solution, so that any Widget could contain an animated Skin (element). I have a QuickGUI::TimerManager and a QuickGUI::Timer class, which can be used to force Widgets to call the "redraw" method every X seconds, or every frame. (although its important to note that the Timer's are driven by rendering of frames, if no rendering is performed, the timer's won't accumulate elapsed time)

For 9.05 I will probably update the Skin structure, so that would be a good time for me to look into this. So sometime in April I'll probably take a stab at implementing it. Basically if you set "NumberOfFrames" to a number greater than 0, the Widget will notify the SkinElement to update its Texture, and use it for drawing:

NumberOfFrames 5
Texture qgui.button.png

will translate to the following textures:

qgui.button0.png
qgui.button1.png
qgui.button2.png
qgui.button3.png
qgui.button4.png