Page 1 of 1

animate 2d image?

Posted: Thu Oct 04, 2007 10:19 am
by Virion
how to animate 2d image in irrlicht? i doesn't mean an already animated gif image, but something like this:



after clipped each part of the image (let's say 4 parts), how to animate them?

Posted: Thu Oct 04, 2007 11:53 am
by belfegor
Look in IrrSpintz source.

Posted: Thu Oct 04, 2007 1:11 pm
by odenter
Look at that 2D sample. There you can see how to animate pictures.
In simple, you have to change the image which has to be drawn.

1. picture 1
2. 0.5 seconds later picture 2
3. 0.5 seconds later picture 3
4. 0.5 seconds later picture 4
1. picture 1
2. 0.5 seconds later picture 2
3. 0.5 seconds later picture 3
4. 0.5 seconds later picture 4
and so on.

Posted: Fri Oct 05, 2007 2:17 am
by Virion

Code: Select all

ITexture* spriteImage = driver->getTexture("test.bmp");
		driver->makeColorKeyTexture(spriteImage,SColor(0,255,0,255));
		IBillboardSceneNode* spriteObject = smgr->addBillboardSceneNode(NULL,dimension2d<float>(50,50),
			vector3df(0,0,0));
		spriteObject->setMaterialTexture(0,spriteImage);
		spriteObject->setMaterialFlag(EMF_LIGHTING,false);
I got problem with this. The billboard appeared but it didn't have any texture on it! The whole thing white in colour.

Posted: Fri Oct 05, 2007 2:28 am
by Virion
I've tried the animator class found in this forum as well. but what I got was a flickering white rectangle.

Posted: Fri Oct 05, 2007 3:47 am
by Virion
OPENGL BUG!! ARGH! I changed to EDT_SOFTWARE and everything work fine o_O !!!

Posted: Fri Oct 05, 2007 9:20 am
by pippy
A better way would be to resize your image. Crop it to be a multiple of 2^X. It will then display correctly in Dx8, openGL etc.

multiples of 2^X are sizes like:
16
32
64
128
512
1024
2048


and so on. You can mix them to, like 64x512. I changed my game to use these sizes and it ran perfectly on all drivers

Posted: Fri Oct 05, 2007 11:41 am
by Virion
the image is already 128x128 because I am already clear about this 2^n thingy. The pic didn't show at all!

Posted: Fri Oct 05, 2007 12:19 pm
by hybrid
I guess it doesn't find your KeyColor. Try to use the positional version and use (0,0), otherwise use the correct alpha value (presumably 255).
Next thing, you will probably want to use an alpha channel transparency with your modified texture, so set the proper material value.
And finally, calling makeColorKeyTexture requires a mipmap regeneration of the texture, so call that one before drawing the texture.

Posted: Fri Oct 05, 2007 1:09 pm
by Virion
but even i didn't call makeColourKey it showed white as well...

Posted: Fri Oct 05, 2007 1:40 pm
by MasterGod
Check this, it might help.

Posted: Fri Oct 05, 2007 1:55 pm
by hybrid
Maybe it did not load the texture at all?

Posted: Fri Oct 05, 2007 1:57 pm
by TheGameMaker
I wrote an animated sprite2D class... (its kind of handy.. I can upload it, if your still interested..)