Help with explosion

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
reetu.raj
Posts: 17
Joined: Wed Aug 27, 2008 5:11 pm
Location: Orlando
Contact:

Help with explosion

Post by reetu.raj »

Hello,

I am using irrlicht texture animator to animate my explosion,

I am facing a problem, as you can see in the explosion frame below, that I have used background color as pink, because explosion flame has lots of black pixel so I can not choose to make black pixel transparent.
So I was wondering that how to make that pink color transparent.

I tried using this line below in my code explosion1()

Code: Select all

driver->makeColorKeyTexture(t, core::position2d<s32>(5,5));
But it doesnt help. Please help how should I solve it.


here is the code

Code: Select all

void explosion_1()
{
	ISceneNodeAnimator* anim = 0;
	array<video::ITexture*> textures;
	for (s32 g=1; g<17; ++g)
	{
			for(s32 g1=1; g1<4; ++g1)
			{
				char tmp[64];
				snprintf(tmp, 64, "media/explosion2/Explode-04-june_%d.jpg", g);
				ITexture* t = driver->getTexture(tmp);
				driver->makeColorKeyTexture(t, core::position2d<s32>(5,5));
				textures.push_back(t);
			}
	}

	anim = smgr->createTextureAnimator(textures, 100);


	vector3df waypoint;
	waypoint.X=50;
	waypoint.Y=5;
	waypoint.Z=50;

	IBillboardSceneNode* bill = 0;

	for (int r=0; r<2; ++r)
	{
		bill = smgr->addBillboardSceneNode(0, core::dimension2d<f32>(100,100),waypoint);
		bill->setMaterialFlag(video::EMF_LIGHTING, false);
		bill->setMaterialTexture(0, driver->getTexture("media/explosion1/Explode-04-june_1.jpg"));
		bill->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA);
		bill->addAnimator(anim);
	}

	anim->drop();

	return;		
	
}


Image
reetu.raj
Posts: 17
Joined: Wed Aug 27, 2008 5:11 pm
Location: Orlando
Contact:

here is the image of explosion frame

Post by reetu.raj »

Image
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

Uh, if you're planning on using transparency, don't use jpegs. The compression messes with the colors which is most likely why it isn't working. Just look at the area around the fire, the purple there is different from the purple at (5,5). Try saving it as a png instead.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

If you use keycolor alpha it maps into the alpha channel, hence TRANSPARENT_VERTEX_ALPHA won't help, but TRANSPARENT_ALPHA_CHANNEL :!:
reetu.raj
Posts: 17
Joined: Wed Aug 27, 2008 5:11 pm
Location: Orlando
Contact:

Post by reetu.raj »

Yes, Now I am using png24bit images, but still I am unable to make the pink color transparent :(
reetu.raj
Posts: 17
Joined: Wed Aug 27, 2008 5:11 pm
Location: Orlando
Contact:

Post by reetu.raj »

thank you hybrid !! it worked !!yeyi
Post Reply