Page 1 of 1

setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL); problem

Posted: Sat May 21, 2005 8:19 am
by Tooh
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.

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;
}
Here is Faerie.bmp and its alpha channel.
Image

Result :(
Image

Posted: Wed May 25, 2005 4:10 am
by Tooh
Please help!

Posted: Wed May 25, 2005 8:37 am
by Guest
An alpha channel in a BMP? Is that even possible?
I thought BMP supported only palettes and 24 bit RGB modes.

I can't see your pictures by the way.

Posted: Wed May 25, 2005 10:53 am
by Guest
no, bmp has no alpha channels! look at the irrlicht features page, then you will see supported formats....tga or psd have alpha channels for example!

ps: i cannot see your pictures too :)

Posted: Wed May 25, 2005 12:38 pm
by afecelis
png's as well but Irrlicht doesn't support them. And neither can I see the pix. :wink:

Posted: Thu May 26, 2005 2:20 am
by Tooh
This is alpha channel in Faerie.bmp.
Image Image

This is screenshot.
Image

This is my source code (Microsoft Visual Studio .NET 2003).
http://www.cwinapp.com/faerie.zip (531.2K)

Posted: Thu May 26, 2005 2:31 am
by Tooh
I tried to use faerie.tga, but the result is the same. :(
http://www.cwinapp.com/faerie.tga

Posted: Fri Jun 03, 2005 2:08 am
by Tooh
Image

Now I compiled it with Irrlicht 0.10.0.
I don't know why some polygons are transparent.

Posted: Fri Jun 03, 2005 5:09 am
by Guest
wow thats a really gay project your doing there, faries and flowers... ::throws up::

Posted: Fri Jun 03, 2005 5:36 am
by Midnight
looks like a test project to me... maybe someday I'll get to release my Irrlicht model and niko will actually include it.

Posted: Fri Jun 03, 2005 6:31 am
by Tooh
Anonymous wrote:wow thats a really gay project your doing there, faries and flowers... ::throws up::
:mrgreen:

Posted: Fri Jun 03, 2005 8:12 am
by hybrid
Anonymous wrote:wow thats a really gay project your doing there, faries and flowers...
Hmm, interesting. My first impression was something like RPG, so I guess it need some deep experience in gay activities to immediately come up with such an impression :lol:
Anyway BMP supports 32 bit (comment from the sources):

Code: Select all

case 32: // thx to Reinhard Ostermeier
Now, did Irrlicht 0.10 fix your problem then? I thought you wanted to have wings transparent and body solid?

Posted: Sat Jun 04, 2005 11:22 am
by Tooh
hybrid wrote:Now, did Irrlicht 0.10 fix your problem then? I thought you wanted to have wings transparent and body solid?
Yes, I want to have the wings transparent but the body. Irrlicht 0.10.0 did not fix my problem yet.

This is a project that I want to test alpha channel texture. I am not gay. :mrgreen: