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.
Donald Duck
Posts: 34 Joined: Sat Jan 21, 2017 6:51 pm
Location: Duckburg
Contact:
Post
by Donald Duck » Thu Feb 23, 2017 3:56 pm
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?
MartinVee
Posts: 139 Joined: Tue Aug 02, 2016 3:38 pm
Location: Québec, Canada
Post
by MartinVee » Thu Feb 23, 2017 4:40 pm
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);
CuteAlien
Admin
Posts: 9734 Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:
Post
by CuteAlien » Fri Feb 24, 2017 1:24 am
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).
Mel
Competition winner
Posts: 2292 Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain
Post
by Mel » Sun Feb 26, 2017 12:37 pm
So far, materials have the difuse color which also might change the alpha value, you can try that.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt