Don't draw full texture

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
zyclop
Posts: 17
Joined: Mon Jan 21, 2008 8:48 am

Don't draw full texture

Post by zyclop »

Hi,
hope you can help me ^^ I want to draw a texture at an object, but don't want to see the whole picture.

for example:
Image

I want to see only the tree and not the black background. Is it possible to realize this? Or should I create a model with Blender or Milkshape?

--- zyclop
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

you use texture->makeColorKey() with the colour you wish to be transparent i believe.
Image Image Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Since you have a black background here you can simply use EMT_TRANSPARENT_ADD_COLOR as material type. You will have to use a billboard, though, and not draw the texture with draw2dimage or something like that. Otherwise you have to create an alpha channel (either in e.g. gimp, or by using the makeKeyColorTexture method from Irrlicht) and draw using the alpha channel.
Please check the examples provided in Irrlicht, they use these kinds of transparency quite often.
zyclop
Posts: 17
Joined: Mon Jan 21, 2008 8:48 am

Post by zyclop »

ok thanx for your help ^^ I'm gonna try now.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

I was going to suggest TRANSPARENCY_ADD_COLOR but that would make the tree slightly transparent too wouldn't it? As it makes the image transparent based on the colour so black is completely transparent and white is completely opaque. The fairly dark green of the tree would therefore be fairly transparent right?
Image Image Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Hmm, probably yes. There's also no threshold for that material, so except for pure white everything will be somewhat transparent. So better use the alpha channel, and be sure to change the material type to a small value (depending on how sharp you want the border of your tree).
Post Reply