Probleme with transparency
-
- Posts: 28
- Joined: Wed Oct 08, 2003 9:09 am
- Location: Annecy - FRANCE
Probleme with transparency
Hello
When i use
"Node->setMaterialType(EMT_TRANSPARENT_VERTEX_ALPHA)", the transparency is 50%.
I try "Node->getMaterial(0).AmbientColor.setAlpha(alpha)" with
alpha between 0 and 255,but it dosnt work.
My question is how to make node 20% or x% transparent?
Thanks a lot.
When i use
"Node->setMaterialType(EMT_TRANSPARENT_VERTEX_ALPHA)", the transparency is 50%.
I try "Node->getMaterial(0).AmbientColor.setAlpha(alpha)" with
alpha between 0 and 255,but it dosnt work.
My question is how to make node 20% or x% transparent?
Thanks a lot.
-
- Posts: 28
- Joined: Wed Oct 08, 2003 9:09 am
- Location: Annecy - FRANCE
Thank you for reply, but it dosn't work for my.
This is my code
What is wrong?
This is my code
Code: Select all
#include <windows.h>
#include <commctrl.h>
#include <stdio.h>
#include "irrlicht.h"
using namespace irr;
using namespace scene;
using namespace video;
ICameraSceneNode* Camera = 0;
IrrlichtDevice *Ecran = 0;
IMesh *mesh=0;
IAnimatedMesh *Bateau = 0;
ISceneManager *smgr= 0;
ISceneNode *Node =0;
IVideoDriver *Driver=0;
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
Ecran=createDevice(EDT_OPENGL ,core::dimension2d<s32>(640,480),32,false,false,false);
Driver= Ecran->getVideoDriver();
smgr= Ecran->getSceneManager();
Camera = smgr->addCameraSceneNodeFPS(0,100,20);
Bateau=smgr->getMesh("M_man1.3ds");
mesh=Bateau->getMesh(0);
s32 Alpha=0;
smgr->getMeshManipulator()->setVertexColorAlpha(mesh, Alpha);
// mesh->setMaterialFlag(EMF_WIREFRAME,true);//test
Node=smgr->addOctTreeSceneNode(mesh);
Node->setMaterialType(EMT_TRANSPARENT_VERTEX_ALPHA);
while(Ecran->run())
{
Driver->beginScene(true, true, SColor(0,0,0,0));
Alpha++;if(Alpha>255) Alpha=0;
smgr->getMeshManipulator()->setVertexColorAlpha(mesh, Alpha);
smgr->drawAll();
Driver->endScene();
}
Ecran->drop();
return 0;
}
-
- Posts: 28
- Joined: Wed Oct 08, 2003 9:09 am
- Location: Annecy - FRANCE
-
- Posts: 63
- Joined: Thu Aug 05, 2004 9:40 am
- Location: Germany
Hi this sounds very familiar to me!POi wrote:Have the same problem here ... when i set the alpha to 128 i get a semitransparent mesh but when i go lower <128 the mesh turns white??
Maybe even worse:
I use the EDT_DIRECTX9 driver, have a custom sceneNode as background and a *.3ds mesh in the front. Further I use E_TEXTURE_CREATION_FLAG:: ETCF_ALWAYS_32_BIT and all textures are *.tga with rgb and alpha channels. The background texture is set to E_MATERIAL_TYPE::EMT_SOLID, alpa opaque, the texture of the mesh in front is set to E_MATERIAL_TYPE::EMT_TRANSPARENT_ALPHA_CHANNEL alpha 128.
Now:
If I rotate my background only, sometimes my mesh becomes partially opaque white colored! This observation is independent of the actual value of the alpha channel of the mesh's texture. It seem's to be dependent of the color variation of the background somehow. If I switch to E_MATERIAL_TYPE::EMT_SOLID for the mesh also, the effect vanishes.
???
-
- Posts: 28
- Joined: Wed Oct 08, 2003 9:09 am
- Location: Annecy - FRANCE
Yea, now I see. It's a problem definatly. The only way I could achieve some kind of the effect you want is:
But this is only for solid-colored mesh, e.g. no texture (and only with EmissiveColor!). So this is unacceptable I think...
Code: Select all
video::SMaterial glass;
while(Ecran->run())
{
Driver->beginScene(true, true, SColor(0,0,0,0));
Alpha++;if(Alpha>255) Alpha=0;
glass.EmissiveColor = video::SColor(Alpha, Alpha, Alpha, Alpha);
Node->getMaterial(0)=glass;
smgr->drawAll();
Driver->endScene();
}
-
- Posts: 28
- Joined: Wed Oct 08, 2003 9:09 am
- Location: Annecy - FRANCE
thx puh,but that 's only change the emissive color from black (0,0,0) to
white (255,255,255) and transparency will not change.
try this:
if i only change alpha transparency, there is no change.
And thx for your help
white (255,255,255) and transparency will not change.
try this:
Code: Select all
Alpha++;if(Alpha>255) Alpha=0;
glass.EmissiveColor = video::SColor(Alpha, 0, 0, 0);
Node->getMaterial(0)=glass;
And thx for your help
-
- Posts: 28
- Joined: Wed Oct 08, 2003 9:09 am
- Location: Annecy - FRANCE
-
- Posts: 28
- Joined: Wed Oct 08, 2003 9:09 am
- Location: Annecy - FRANCE