animate 2d image?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

animate 2d image?

Post 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?
Last edited by Virion on Fri Oct 05, 2007 11:41 am, edited 1 time in total.
belfegor
Posts: 383
Joined: Mon Sep 18, 2006 7:22 pm
Location: Serbia

Post by belfegor »

Look in IrrSpintz source.
Small FPS demo made using Irrlicht&NewtonDEMO
InfoHERE
Its at very early stage but i think im crazy enough to finish it all alone.
odenter
Posts: 48
Joined: Thu Oct 21, 2004 10:35 am
Location: Bremen (Germany)

Post 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.
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post 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.
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

I've tried the animator class found in this forum as well. but what I got was a flickering white rectangle.
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

OPENGL BUG!! ARGH! I changed to EDT_SOFTWARE and everything work fine o_O !!!
pippy
Posts: 49
Joined: Sun Jul 08, 2007 11:31 pm

Post 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
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

the image is already 128x128 because I am already clear about this 2^n thingy. The pic didn't show at all!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

but even i didn't call makeColourKey it showed white as well...
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

Check this, it might help.
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Maybe it did not load the texture at all?
TheGameMaker
Posts: 275
Joined: Fri May 12, 2006 6:37 pm
Location: Germany

Post by TheGameMaker »

I wrote an animated sprite2D class... (its kind of handy.. I can upload it, if your still interested..)
Post Reply