Page 1 of 1

Change alpha value of mesh in Irrlicht

Posted: Thu Feb 23, 2017 3:56 pm
by Donald Duck
I have a IMeshSceneNode that is usually not transparent, and I would like to make it semi-transparent under certain conditions. Something like this:

Code: Select all

if(condition){
    mesh->setAlpha(128);    //semi-transparent
}
else{
    mesh->setAlpha(255);    //not transparent
}
Is there any way I can do this in Irrlicht?

Re: Change alpha value of mesh in Irrlicht

Posted: Thu Feb 23, 2017 4:40 pm
by MartinVee
Searching the forums, I found that snippet of code that should do what you want :

Code: Select all

 
IAnimatedMesh* mesh = smgr->getMesh("sydney.md2");
IMeshManipulator *manipulator = smgr->getMeshManipulator();
 
int alpha = 128;
manipulator->setVertexColorAlpha(mesh->getMesh(0),alpha);
 

Re: Change alpha value of mesh in Irrlicht

Posted: Fri Feb 24, 2017 1:24 am
by CuteAlien
Basically as MartinVee wrote, but you also need a material which uses vertex colors (EMT_TRANSPARENT_VERTEX_ALPHA or a custom shader ... for others you have to experiment but most won't use it).

Re: Change alpha value of mesh in Irrlicht

Posted: Sun Feb 26, 2017 12:37 pm
by Mel
So far, materials have the difuse color which also might change the alpha value, you can try that.