Code: Select all
/*
* This is an Irrlicht test program to check EMT_TRANSPARENT_VERTEX_ALPHA working
* Excuse my bad English, I'm Spanish :)
* Compiled with Irrlicht Engine v0.6
*/
#include <Irrlicht.h>
irr::IrrlichtDevice *g_pIrrDevice = NULL;
irr::scene::IAnimatedMesh *g_pMyMesh = NULL;
irr::scene::IAnimatedMeshSceneNode *g_pMySceneNode = NULL;
int main(void){
//To change the alpha level
irr::s32 iAlpha = 0;
irr::s32 iSpeed = 1;
//Create the Irrlicht Device. You can try with either OpenGL, DX8 or DX9
// g_pIrrDevice = irr::createDevice(irr::video::EDT_OPENGL,irr::core::dimension2d<irr::s32>(640,480),16,false);
// g_pIrrDevice = irr::createDevice(irr::video::EDT_DIRECTX8,irr::core::dimension2d<irr::s32>(640,480),16,false);
g_pIrrDevice = irr::createDevice(irr::video::EDT_DIRECTX9,irr::core::dimension2d<irr::s32>(640,480),16,false);
g_pIrrDevice->getVideoDriver()->setAmbientLight(irr::video::SColorf(1.0f,1.0f,1.0f,0.0f));
//Then I load my mesh and change its material type
g_pMyMesh = g_pIrrDevice->getSceneManager()->getMesh("casa.3ds");
g_pMySceneNode = g_pIrrDevice->getSceneManager()->addAnimatedMeshSceneNode(g_pMyMesh);
g_pMySceneNode->setMaterialType(irr::video::EMT_TRANSPARENT_VERTEX_ALPHA);
//My camera :P
g_pIrrDevice->getSceneManager()->addCameraSceneNodeFPS(0,50,100);
while(g_pIrrDevice->run() && g_pIrrDevice->isWindowActive()){
//I change the alpha color of my object and see what happens :(
//If you use OpenGL, it's always at the 50% of transparency
//If you use either DirectX8 or DirectX9, it changes but only in some parts of the mesh.
iAlpha += iSpeed;
if(iAlpha>255 || iAlpha<0) iSpeed *= -1;
g_pIrrDevice->getSceneManager()->getMeshManipulator()->setVertexColorAlpha(g_pMyMesh->getMesh(0),iAlpha);
//Render Functions (you know them xDD)
g_pIrrDevice->getVideoDriver()->beginScene(true,true,irr::video::SColor(255,0,0,255));
g_pIrrDevice->getSceneManager()->drawAll();
g_pIrrDevice->getVideoDriver()->endScene();
}
g_pIrrDevice->drop();
return 0;
}
Byee!! Viva Irrlicht!!! xDD