Let me ask you a quick question in Irrlicht.
I am using a plane with an alpha png (a blood texture) that I plot on the floor when the player is hit. I am facing two problems with this IMeshSceneNode: i) If I enable lighting, the texture becomes all black, seems like the ambient light do not have any influence at all on my plane. ii) I can't make it transparent over the time by manipulating the alpha (tried diffuse and emissive colors).
Do you know how could I fix these couple issues?
Here is some example code:
Code: Select all
IMesh *poMesh = SMGR->getMesh( "effect/plane.3ds" );
poNode = SMGR->addMeshSceneNode(poMesh, SMGR->getRootSceneNode());
poNode->setMaterialTexture(0, DRIVER->getTexture( "effect/bloodDecal2.png" ));
poNode->setMaterialType( EMT_TRANSPARENT_ALPHA_CHANNEL );
poNode->setMaterialFlag( EMF_LIGHTING, true ); //my game have day and night cycles...
poNode->setMaterialFlag( EMF_FOG_ENABLE, true );
poNode->setPosition(vfPos);
ShadowManager::Get().ExcludeNodeFromDepthPass( poNode );
fTimeToLive = 5.0f; //seconds
fTimeAlive = 0.0f;
TerrainManager::Get().GrabDecal( poNode ); //attach the node to the floor
//Update Loop
int nCurrentAlpha = (int) ( 255.0f * (poDecal->fTimeToLive - poDecal->fTimeAlive) / poDecal->fTimeToLive );
//printf("\nCurrentAlpha [%d]", nCurrentAlpha);
poDecal->poNode->getMaterial(0).DiffuseColor.setAlpha( nCurrentAlpha );
poDecal->poNode->getMaterial(0).EmissiveColor.setAlpha( nCurrentAlpha );
Braun