how to transparent texture 3d model ( fade in fade out )

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
koller202
Posts: 143
Joined: Tue May 08, 2007 4:53 am
Location: Thailand

how to transparent texture 3d model ( fade in fade out )

Post by koller202 »

how to transparent texture 3d model ( fade in fade out )

i can use in 2d image

but in 3d my texture model can t use

thankyou
________
JUSTIN BIEBER
Last edited by koller202 on Thu Feb 17, 2011 1:09 am, edited 1 time in total.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

You need to set material of your scene node to use alfa chanell of your texture. Look at API for more info.
koller202
Posts: 143
Joined: Tue May 08, 2007 4:53 am
Location: Thailand

Post by koller202 »

how

Code: Select all

void irr::scene::ISceneNode::setMaterialTexture  (  u32  textureLayer,  
  video::ITexture *  texture 
 )  [inline] 
sorry i can t do it

T_T
________
Dodge colt history
Last edited by koller202 on Thu Feb 17, 2011 1:09 am, edited 1 time in total.
Dorth
Posts: 931
Joined: Sat May 26, 2007 11:03 pm

Post by Dorth »

Then I'm terribly sorry but if with the tutorial, the documentation, the api and the search function you can't even get a basis working with which we could help you, then it's quie likelly you're trying something that is out of your league, at least for now. Pratice coding, read a lot on site like gamedev and forums like his one, try small things then try it out yourself THEN come for help with any problems ou might still have.

Good luck ;)
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Look at video::SMaterial Class Reference. SMaterial have public atribute MaterialType. It can be se to type which suports alpha chanel of texture. EMT_TRANSPARENT_ALPHA_CHANNEL is one you are probably looking for.

To change material type of node, use ISceneNode function setMaterialType(video::E_MATERIAL_TYPE newType).

So your code will look something like:

Code: Select all

yournode->setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL);
Of course your texture have to have some transparency. Use png format to load transparent textures or use IVideoDriver::makeColorKeyTexture() function to make one from ordinary texture.

For fade in/ out effect EMT_TRANSPARENT_VERTEX_ALPHA might be more useful. In this material type vertex transparency is used to make node transparent. You need to get mesh buffer out of node then acces vertices and change their transparency one by one.
koller202
Posts: 143
Joined: Tue May 08, 2007 4:53 am
Location: Thailand

Post by koller202 »

- -

i did t mean this

(1) i want to use 1 texture in my node 3d and use fadein fadeout texture

(2) i mean this

Code: Select all

		driver->draw2DImage(SPscreen, core::position2d<s32>(256,280), 
			rect<s32>(0,0,512,128), 0, 
			SColor(255,255,255,255), true); 
(in 2d graphic ) i can set transpent in SColor(this,255,255,255)
variable this i can control transpent
but now i want control node transpent it myself

sorry i bad english thank you everyone
________
Toyota avalon (concept)
Last edited by koller202 on Thu Feb 17, 2011 1:09 am, edited 1 time in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yes, but you have to change to the vertex alpha material first. Then you can use the setVertexColorAlpha meshmanipulator to change the alpha values of all vertices to the desired value. You can also use alpha_channel material and change the textures accordingly, but the former is usually faster.
The fastest version should be the shader based version, though. Search the snippets forum for it.
koller202
Posts: 143
Joined: Tue May 08, 2007 4:53 am
Location: Thailand

Post by koller202 »

thankyou hybird

use shader or setVertexColorAlpha
________
Daihatsu Move
Last edited by koller202 on Thu Feb 17, 2011 1:09 am, edited 1 time in total.
koller202
Posts: 143
Joined: Tue May 08, 2007 4:53 am
Location: Thailand

Post by koller202 »

i can do it

Code: Select all

  scene::IMesh * mesh=smgr->getMesh("../../media/sydney.md2")->getMesh(0); 
   smgr->getMeshManipulator()->setVertexColors( mesh, video::SColor( 0, 20, 20, 20 ) ); 
   scene::ISceneNode *Aqua = smgr->addMeshSceneNode(mesh); 
   Aqua->setMaterialFlag(video::EMF_LIGHTING, false);    
  // Aqua->setAutomaticCulling(false); 
   Aqua->setMaterialFlag(video::EMF_BACK_FACE_CULLING, false); 
   Aqua->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA  ); 
   Aqua->setMaterialTexture(0, driver->getTexture("../../media/sydney.bmp"));
thx
________
Marijuana indica
Last edited by koller202 on Thu Feb 17, 2011 1:09 am, edited 1 time in total.
Irme
Posts: 55
Joined: Sat Jul 16, 2005 8:24 am

Post by Irme »

Ok, so i've gotten your code to work to set a meshes alpha so that its translucent

but how do i change it on a node after i've added the mesh to it?
koller202
Posts: 143
Joined: Tue May 08, 2007 4:53 am
Location: Thailand

Post by koller202 »

u mean fade in fade out in mesh ?

smgr->getMeshManipulator()->setVertexColors( mesh, video::SColor( ****, *****, *****, ***** ) );
change in 255 is 100 % transparent 0 is 0 % transparent
________
Diets advice
Post Reply