PDA

View Full Version : Question for OGLES1 Alpha channel



feelthat
02-14-2015, 05:22 PM
follows are my code example

My question is in OGLES[1]

the {ninja.b3d} can show transparent alpha and use MyAlpha to adjust hi low

why the {dwarf.x} can not show transparent effect?

is the file format problem?


///////////////
mesh = smgr->getMesh( (GetBaseAppPath()+"game/ninja.b3d").c_str() );
node = smgr->addAnimatedMeshSceneNode( mesh );


//////////////////////////////texture/////////////////////////////////////////////////
node->setMaterialTexture( 0, driver->getTexture((GetBaseAppPath()+"game/nskinrd.jpg").c_str()) );
node->setMaterialFlag(EMF_LIGHTING, true);
node->setMaterialFlag(EMF_NORMALIZE_NORMALS, true);

u32 MyAlpha = 100;
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.MaterialTypeParam = 0.1;
tex_mat.MaterialTypeParam2 = 0.1;
tex_mat.AmbientColor.setAlpha(MyAlpha);
tex_mat.DiffuseColor.setAlpha(MyAlpha);
tex_mat.SpecularColor.setAlpha(MyAlpha);
tex_mat.EmissiveColor.setAlpha(MyAlpha);
}

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 = video::SColor(MyAlpha,255,255,255);
vertex[j].Color.setAlpha(MyAlpha);
}
}



https://plus.google.com/photos/106185541018774360364/albums/5964765088859640225/6115134175228228274?banner=pwa&pid=6115134175228228274&oid=106185541018774360364

feelthat
02-14-2015, 05:40 PM
http://irrlicht.sourceforge.net/forum/viewtopic.php?t=37871#p220408

there's no transparency flag in .x, which means that we don't create transparency settings.





follows are my code example

My question is in OGLES[1]

the {ninja.b3d} can show transparent alpha and use MyAlpha to adjust hi low

why the {dwarf.x} can not show transparent effect?

is the file format problem?


///////////////
mesh = smgr->getMesh( (GetBaseAppPath()+"game/ninja.b3d").c_str() );
node = smgr->addAnimatedMeshSceneNode( mesh );


//////////////////////////////texture/////////////////////////////////////////////////
node->setMaterialTexture( 0, driver->getTexture((GetBaseAppPath()+"game/nskinrd.jpg").c_str()) );
node->setMaterialFlag(EMF_LIGHTING, true);
node->setMaterialFlag(EMF_NORMALIZE_NORMALS, true);

u32 MyAlpha = 100;
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.MaterialTypeParam = 0.1;
tex_mat.MaterialTypeParam2 = 0.1;
tex_mat.AmbientColor.setAlpha(MyAlpha);
tex_mat.DiffuseColor.setAlpha(MyAlpha);
tex_mat.SpecularColor.setAlpha(MyAlpha);
tex_mat.EmissiveColor.setAlpha(MyAlpha);
}

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 = video::SColor(MyAlpha,255,255,255);
vertex[j].Color.setAlpha(MyAlpha);
}
}