PDA

View Full Version : The Way to Set alpha vertex from 0~255



feelthat
02-13-2015, 01:26 AM
//follow code test good in b3d obj 3ds
//demo here
https://plus.google.com/photos/106185541018774360364/albums/5964765088859640225/6115134175228228274?banner=pwa&pid=6115134175228228274&oid=106185541018774360364

////////////////////////////////////////////////////////////////
IAnimatedMesh* mesh;
IAnimatedMeshSceneNode* node;
.
.
.
mesh = smgr->getMesh( memfile );
node = smgr->addAnimatedMeshSceneNode( mesh );
node->setMaterialFlag(EMF_LIGHTING, true); // use light is ok~~~
node->setMaterialFlag(EMF_NORMALIZE_NORMALS, true);

u32 MyAlpha = 150; //0~255
u32 MaterialCount = node->getMaterialCount();
for(u32 i=0; i<MaterialCount; i++)
{
video::SMaterial& tex_mat = node->getMaterial(i);
tex_mat.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
tex_mat.AmbientColor.setAlpha(MyAlpha);
tex_mat.DiffuseColor.setAlpha(MyAlpha);
tex_mat.SpecularColor.setAlpha(MyAlpha);
tex_mat.EmissiveColor.setAlpha(MyAlpha);
}


//this can do or not by ur choice
for(u32 i=0; i<mesh->getMeshBufferCount(); i++)
{
scene::IMeshBuffer* buffer = mesh->getMeshBuffer(i);
video::S3DVertex* vertex = (video::S3DVertex*)buffer->getVertices();
for(u32 j=0; j<buffer->getVertexCount(); j++)
{
vertex[j].Color.setAlpha(MyAlpha);
}
}