setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL); problem

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Tooh

setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL); problem

Post 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
Tooh

Post by Tooh »

Please help!
Guest

Post 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.
Guest

Post 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 :)
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

png's as well but Irrlicht doesn't support them. And neither can I see the pix. :wink:
Tooh

Post 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)
Tooh

Post by Tooh »

I tried to use faerie.tga, but the result is the same. :(
http://www.cwinapp.com/faerie.tga
Tooh
Posts: 5
Joined: Fri May 27, 2005 3:56 am

Post by Tooh »

Image

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

Post by Guest »

wow thats a really gay project your doing there, faries and flowers... ::throws up::
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post 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.
Tooh
Posts: 5
Joined: Fri May 27, 2005 3:56 am

Post by Tooh »

Anonymous wrote:wow thats a really gay project your doing there, faries and flowers... ::throws up::
:mrgreen:
hybrid

Post 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?
Tooh
Posts: 5
Joined: Fri May 27, 2005 3:56 am

Post 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:
Post Reply