setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL); problem
Posted: Sat May 21, 2005 8:19 am
Hi,
I am trying to use alpha channel in texture Faerie.bmp with Faerie.md2 model. I want to make the wings transparent (I use alpha color at the wings area in the texture), but why all model is transparent. Please help.
Thanks.
Here is Faerie.bmp and its alpha channel.
Result
I am trying to use alpha channel in texture Faerie.bmp with Faerie.md2 model. I want to make the wings transparent (I use alpha color at the wings area in the texture), but why all model is transparent. Please help.
Thanks.
Code: Select all
#include <windows.h>
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace gui;
#pragma comment(lib, "Irrlicht.lib")
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
IrrlichtDevice *device = createDevice(EDT_OPENGL, dimension2d<s32>(640, 480), 32, false, true, false, 0);
device->setWindowCaption(L"Faerie");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
IAnimatedMesh* mesh = smgr->getMesh("Faerie.md2");
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(mesh);
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setFrameLoop(0, 320);
node->setMaterialTexture(0, driver->getTexture("Faerie.bmp"));
// Alpha Channel
node->setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL);
}
smgr->addCameraSceneNode(0, vector3df(0, 10, -50), vector3df(0, 5, 0));
video::ITexture *background = driver->getTexture("Background.jpg");
while (device->run())
{
driver->beginScene(true, true, SColor(0, 0, 0, 0));
driver->draw2DImage(background,
rect<s32>(0, 0, driver->getScreenSize().Width, driver->getScreenSize().Height),
rect<s32>(0, 0, background->getOriginalSize().Width, background->getOriginalSize().Height),
NULL,
0,
true);
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
Result