CAnimSprite Class with Alpha-Blending(Transparency)
CAnimSprite Class with Alpha-Blending(Transparency)
I was wondering how to do Alpha-Blending with the CAnimSprite Class posted in the Wiki
i heard somethin about setVertexColorAlpha(person->getMesh(0),200); somewhere in the Forums but i have no idea how to use it in the Sprite-Class.
i've also tried to set the Alpha at the SColor of the S3DVertex to 0 for example, but nothing happends... after a few other tries i gave it up.
I thought of a function called setAlpha(int alpha) or something like this for setting the transparency of the Sprite.
I hope someone can help me out of this
by the way: How can i set the Alpha at 2D-Images(using draw2dimage) ?
i've been searching a while but i didn't find anything...
i heard somethin about setVertexColorAlpha(person->getMesh(0),200); somewhere in the Forums but i have no idea how to use it in the Sprite-Class.
i've also tried to set the Alpha at the SColor of the S3DVertex to 0 for example, but nothing happends... after a few other tries i gave it up.
I thought of a function called setAlpha(int alpha) or something like this for setting the transparency of the Sprite.
I hope someone can help me out of this
by the way: How can i set the Alpha at 2D-Images(using draw2dimage) ?
i've been searching a while but i didn't find anything...
IrrLicht v0.14
Audiere Sounds-API v1.9.3
Current Project: KoulesXD
Audiere Sounds-API v1.9.3
Current Project: KoulesXD
-
- Posts: 518
- Joined: Tue Mar 29, 2005 9:02 pm
- Location: Alex,Egypt
- Contact:
see the setBlend function of TMovieMesh class,it is what you are looking
for and apply it to CAnimSprite.
here is the link of TMovieMesh class
http://www.irrforge.org/index.php/Playi ... in_texture
for and apply it to CAnimSprite.
here is the link of TMovieMesh class
http://www.irrforge.org/index.php/Playi ... in_texture
Magic 2d Library For Irrlicht : http://www.freewebs.com/bcxgl/index.htm
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/
THX for your help. It looks like what i need...
but could it be, that this function simply sets the first s32-Value of the SColor Object ?
I'm not sure, but i tried that befor i posted my request in here and it didn't work very well. Ok it didn't work at all because simply nothing happend.
Maybe my problem is somewhere else:
if you set the Alpha of a Sprite, is it half-transparent if you put a 2d-Image behind ? Or do you have to but a Sprite in the Background as well ?
i think thats the problem, because i've tried to mix 2D-Images with Sprites(SceneNodes)
i'll try the setBlend() method tomorrow, maybe it works anyway and all my problems are gone ^^
but could it be, that this function simply sets the first s32-Value of the SColor Object ?
I'm not sure, but i tried that befor i posted my request in here and it didn't work very well. Ok it didn't work at all because simply nothing happend.
Maybe my problem is somewhere else:
if you set the Alpha of a Sprite, is it half-transparent if you put a 2d-Image behind ? Or do you have to but a Sprite in the Background as well ?
i think thats the problem, because i've tried to mix 2D-Images with Sprites(SceneNodes)
i'll try the setBlend() method tomorrow, maybe it works anyway and all my problems are gone ^^
IrrLicht v0.14
Audiere Sounds-API v1.9.3
Current Project: KoulesXD
Audiere Sounds-API v1.9.3
Current Project: KoulesXD
i've tried this method from the TMovieMesh to set the transparency of the Sprites:
I've been trying for at least one hour to figure out why it doesn't work right.
I can put a 2D-Image or another Sprite in the Background but whatever i do, it is not transparent at all. The alpha-Value i use doesn't have any effect.
But if i chance some other Values of the Color, for example the Green part, it works. it is not transparent, but there i see that the values of the color can be changed. But if i change the alpha value simply nothin happends...
i'm sorry if it is a noob-error or something but i really have no idea why this shouldn't work.
hopefully someone can help me out of this. thx in adcance
Code: Select all
virtual void setBlend(s32 al)
{
Vertices[0].Color.setAlpha(al);
Vertices[1].Color.setAlpha(al);
Vertices[2].Color.setAlpha(al);
Vertices[3].Color.setAlpha(al);
}
I can put a 2D-Image or another Sprite in the Background but whatever i do, it is not transparent at all. The alpha-Value i use doesn't have any effect.
But if i chance some other Values of the Color, for example the Green part, it works. it is not transparent, but there i see that the values of the color can be changed. But if i change the alpha value simply nothin happends...
i'm sorry if it is a noob-error or something but i really have no idea why this shouldn't work.
hopefully someone can help me out of this. thx in adcance
IrrLicht v0.14
Audiere Sounds-API v1.9.3
Current Project: KoulesXD
Audiere Sounds-API v1.9.3
Current Project: KoulesXD
you can only make it transparrent using vertex alpha if you use vertex alpha mode to draw it, but you also need transparren by colour key or all your sprites will have square borders.
You might need to combine the source code of the two render modes you need to make your own, but first i'd try some of the existing ones to see if any of them work like you need.
You might need to combine the source code of the two render modes you need to make your own, but first i'd try some of the existing ones to see if any of them work like you need.
so it isn't possible to draw a 2D-Image or Sprite with Alpha if you use the Alpha-Channel of the Texture(like in PNG-Images) ?
i don't ike the Color-Keying very much, because you cant make some pixel half-transparent(like pre-rendered Anti-Aliasing, if you know what i mean)
Thx for trying the stuff out for me, at the moment i'm not pretty sure if i understand what you mean with "vertex alpha mode".
hope you can explain that for me i'm not as experienced as it maybe looks like ^^
i don't ike the Color-Keying very much, because you cant make some pixel half-transparent(like pre-rendered Anti-Aliasing, if you know what i mean)
Thx for trying the stuff out for me, at the moment i'm not pretty sure if i understand what you mean with "vertex alpha mode".
hope you can explain that for me i'm not as experienced as it maybe looks like ^^
IrrLicht v0.14
Audiere Sounds-API v1.9.3
Current Project: KoulesXD
Audiere Sounds-API v1.9.3
Current Project: KoulesXD
-
- Posts: 518
- Joined: Tue Mar 29, 2005 9:02 pm
- Location: Alex,Egypt
- Contact:
what drive are you using,OpenGl or Dx?
to be honest, i have moved form using DX to use OpenGL for many
reasons,it is more easy ,and allows you to make some work could not be
done or hard to do with DX.
any way i will take a look and if it is ok,i will let you know.
Edited:
you could do that with OpenGL but not with DX if you are using OpenGL
Driver and want to know how to do it , let me know.
to be honest, i have moved form using DX to use OpenGL for many
reasons,it is more easy ,and allows you to make some work could not be
done or hard to do with DX.
any way i will take a look and if it is ok,i will let you know.
Edited:
you could do that with OpenGL but not with DX if you are using OpenGL
Driver and want to know how to do it , let me know.
Magic 2d Library For Irrlicht : http://www.freewebs.com/bcxgl/index.htm
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/
-
- Posts: 518
- Joined: Tue Mar 29, 2005 9:02 pm
- Location: Alex,Egypt
- Contact:
in your render function of CAnimSprite Class put those afterDaChief wrote: How does it work in OpenGL ?
seting the material
Code: Select all
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_ALPHA_TEST);
glColor4ub(255,255,255,MyALpha);
where
MyALpha = ranged from 0 to 255
Magic 2d Library For Irrlicht : http://www.freewebs.com/bcxgl/index.htm
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/
@Guest
Jup..
@Emil_halim
i've got some problems with your solution. Do i have to compile it with the engine to do that ?
i've been using the class as a header-file of a test-project because i made some little changes to it and for testing it was a lot more comfortable.
Jup..
@Emil_halim
i've got some problems with your solution. Do i have to compile it with the engine to do that ?
i've been using the class as a header-file of a test-project because i made some little changes to it and for testing it was a lot more comfortable.
IrrLicht v0.14
Audiere Sounds-API v1.9.3
Current Project: KoulesXD
Audiere Sounds-API v1.9.3
Current Project: KoulesXD
-
- Posts: 518
- Joined: Tue Mar 29, 2005 9:02 pm
- Location: Alex,Egypt
- Contact:
No you do not have to change the engine.
what kind of problems you got?
what kind of problems you got?
Magic 2d Library For Irrlicht : http://www.freewebs.com/bcxgl/index.htm
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/
well.. simple:
{
glEnable()
GL_BLEND
glBlendFunc()
GL_SRC_ALPHA
GL_ONE_MINUS_SRC_ALPHA
glDisable()
GL_ALPHA_TEST
glColor4ub
} -> not identified...
could it be, that these functions come from the device or the driver ?
all my IrrLicht Stuff is in a namespace called "KXD::irrEngine"
Maybe i have to use them by -> using namespace KXD; using namespace irrEngine;
and maybe i should test someting like this before i cry around that it doesn't work ^^
{
glEnable()
GL_BLEND
glBlendFunc()
GL_SRC_ALPHA
GL_ONE_MINUS_SRC_ALPHA
glDisable()
GL_ALPHA_TEST
glColor4ub
} -> not identified...
could it be, that these functions come from the device or the driver ?
all my IrrLicht Stuff is in a namespace called "KXD::irrEngine"
Maybe i have to use them by -> using namespace KXD; using namespace irrEngine;
and maybe i should test someting like this before i cry around that it doesn't work ^^
IrrLicht v0.14
Audiere Sounds-API v1.9.3
Current Project: KoulesXD
Audiere Sounds-API v1.9.3
Current Project: KoulesXD
-
- Posts: 518
- Joined: Tue Mar 29, 2005 9:02 pm
- Location: Alex,Egypt
- Contact:
it is so simple. you got those errors becouse you did not include OpenGL
Include file and did not telling your compiler the library that has those
functions.
firest you have to download OpenGl Includes&Libs stuff ,i have upload
them with Mixing_OpenGL_stuff_with_Irrlicht tutorial in wiki if you want
here is the link
http://www.irrforge.org/index.php/Mixin ... h_Irrlicht
then you must include the OpenGL headers in your program and tell the
compiler about the Libs for linking stuff.
Include file and did not telling your compiler the library that has those
functions.
firest you have to download OpenGl Includes&Libs stuff ,i have upload
them with Mixing_OpenGL_stuff_with_Irrlicht tutorial in wiki if you want
here is the link
http://www.irrforge.org/index.php/Mixin ... h_Irrlicht
then you must include the OpenGL headers in your program and tell the
compiler about the Libs for linking stuff.
Magic 2d Library For Irrlicht : http://www.freewebs.com/bcxgl/index.htm
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/
ok, i'll try it as soon as i can...
but to go back to my other question:
why can't i do Alpha-Blending by changing the Alpha-Value of SColor at the Sprites or 2DImages ?
is it a bug in the Engine ?
or for what can you use this Alpha-Value instead ?
and how does the Vertex-Alpha Mode works?
Only interested. Maybe i'll need it in another project...
but to go back to my other question:
why can't i do Alpha-Blending by changing the Alpha-Value of SColor at the Sprites or 2DImages ?
is it a bug in the Engine ?
or for what can you use this Alpha-Value instead ?
and how does the Vertex-Alpha Mode works?
Only interested. Maybe i'll need it in another project...
IrrLicht v0.14
Audiere Sounds-API v1.9.3
Current Project: KoulesXD
Audiere Sounds-API v1.9.3
Current Project: KoulesXD