Simple IMeshSceneNode Question

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.
Post Reply
hbraun
Posts: 28
Joined: Tue Dec 16, 2008 7:33 pm
Location: Porto Alegre, Brazil
Contact:

Simple IMeshSceneNode Question

Post by hbraun »

Hey Guys!

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 );
 
 
Kind Regards,

Braun
smso
Posts: 246
Joined: Fri Jun 04, 2010 3:28 pm
Location: Hong Kong

Re: Simple IMeshSceneNode Question

Post by smso »

Take a look at RdR's Decal System / Manager:
http://irrlicht.sourceforge.net/forum/v ... =6&t=44968

See the material setup in:

Code: Select all

DecalSceneNode.cpp
Regards,
smso
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Simple IMeshSceneNode Question

Post by hendu »

You need a shader for the alpha effect you want.
Post Reply