Hi, i have readed the tutorial 6 of irrlicht and i have make some test with it.
I want to make an HUD, so i have placed a Q3 map behind of the 2d images (drawing the 3d world first and 2d images at last).
But in the first test, only appears the irrlicht logo, so what is wrong?
i have attempt to fix that so i in the first try i fix the rectangle of the mouse putting the transparancy (alpha) to 255 (opaque).
so, i have tryed the somthing with the demons and the dragons background but nothing happens.
reading i have noticed that in the function of this 2dimages there are a parameters that specifics the pixel black(0,0,0) int the image file is transparent in the engine, so i have changed this to false and works ! but with black background.
not only the transparency is the problem, also the text arent displayed and dont have transparency becouse the alpha is setted to 255.
This problem is not caused by the q3 map, this is caused by the camera that i have placed with the line :
smgr->addCameraSceneNode(0, core::vector3df(0,10,-40), core::vector3df(0,0,0));
All games have HUD transparent so i want to know if i can make it.
thanks.
Sorry for my english.
Transparent 2d images dont work over a 3d world?
I had simular probs a while back, showed the source code and some peeps here seemed to think the source was fine so it would be interesting ( to me ) to see if your code is OK as well. Unfortunatly I never found a way around it and so far I haven't seen anyone else try it, so hopefully someone has a brain wave when they have a go and gets it to work as I'm pretty much bamboozled 
is the code of tutorial 6 but with the q3 map of tutorial 2.
#include <irrlicht.h>
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")
int main()
{
IrrlichtDevice *device = createDevice(video::DT_OPENGL,core::dimension2d<s32>(512, 384));
device->setWindowCaption(L"Irrlicht Engine - 2D Graphics Demo");
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
device->getFileSystem()->addZipFileArchive("map-20kdm2.pk3");
scene::IAnimatedMesh* mesh = smgr->getMesh("20kdm2.bsp");
scene::ISceneNode* node = 0;
if (mesh)
node = smgr->addOctTreeSceneNode(mesh->getMesh(0));
if (node)
node->setPosition(core::vector3df(-1300,-144,-1249));
smgr->addCameraSceneNode(0, core::vector3df(0,10,-40), core::vector3df(0,0,0));
video::ITexture* images = driver->getTexture("2ddemo.bmp");
driver->makeColorKeyTexture(images, core::position2d<s32>(0,0));
gui::IGUIFont* font = device->getGUIEnvironment()->getBuildInFont();
gui::IGUIFont* font2 = device->getGUIEnvironment()->getFont("fonthaettenschweiler.bmp");
core::rect<s32> imp1(349,15,385,78);
core::rect<s32> imp2(387,15,423,78);
while(device->run() && driver)
{
if (device->isWindowActive())
{
u32 time = device->getTimer()->getTime();
driver->beginScene(true, true, video::SColor(0,122,65,171));
smgr->drawAll();
// draw fire & dragons background world
driver->draw2DImage(images, core::position2d<s32>(50,50),core::rect<s32>(0,0,342,224), 0,video::SColor(255,255,255,255), false);
// draw flying imp
driver->draw2DImage(images, core::position2d<s32>(164,125),(time/100 % 2) ? imp1 : imp2, 0, video::SColor(255,255,255,255), false);
// draw second flying imp with colorcylce
driver->draw2DImage(images, core::position2d<s32>(270,105),(time/1000 % 2) ? imp1 : imp2, 0, video::SColor(255,(time) % 255,255,255), false);
// draw some text
if (font)
font->draw(L"This is some text.",core::rect<s32>(130,10,300,50),video::SColor(255,255,255,255));
// draw some other text
if (font2)
font2->draw(L"This is some other text.",core::rect<s32>(130,20,300,60),video::SColor(255,time % 255,time % 255,255));
// draw logo
driver->draw2DImage(images, core::position2d<s32>(10,10),core::rect<s32>(354,87,442,118));
// draw transparent rect under cursor
core::position2d<s32> m = device->getCursorControl()->getPosition();
driver->draw2DRectangle(video::SColor(255,100,100,100),core::rect<s32>(m.X-20, m.Y-20, m.X+20, m.Y+20));
driver->endScene();
}
}
device->drop();
return 0;
}
#include <irrlicht.h>
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")
int main()
{
IrrlichtDevice *device = createDevice(video::DT_OPENGL,core::dimension2d<s32>(512, 384));
device->setWindowCaption(L"Irrlicht Engine - 2D Graphics Demo");
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
device->getFileSystem()->addZipFileArchive("map-20kdm2.pk3");
scene::IAnimatedMesh* mesh = smgr->getMesh("20kdm2.bsp");
scene::ISceneNode* node = 0;
if (mesh)
node = smgr->addOctTreeSceneNode(mesh->getMesh(0));
if (node)
node->setPosition(core::vector3df(-1300,-144,-1249));
smgr->addCameraSceneNode(0, core::vector3df(0,10,-40), core::vector3df(0,0,0));
video::ITexture* images = driver->getTexture("2ddemo.bmp");
driver->makeColorKeyTexture(images, core::position2d<s32>(0,0));
gui::IGUIFont* font = device->getGUIEnvironment()->getBuildInFont();
gui::IGUIFont* font2 = device->getGUIEnvironment()->getFont("fonthaettenschweiler.bmp");
core::rect<s32> imp1(349,15,385,78);
core::rect<s32> imp2(387,15,423,78);
while(device->run() && driver)
{
if (device->isWindowActive())
{
u32 time = device->getTimer()->getTime();
driver->beginScene(true, true, video::SColor(0,122,65,171));
smgr->drawAll();
// draw fire & dragons background world
driver->draw2DImage(images, core::position2d<s32>(50,50),core::rect<s32>(0,0,342,224), 0,video::SColor(255,255,255,255), false);
// draw flying imp
driver->draw2DImage(images, core::position2d<s32>(164,125),(time/100 % 2) ? imp1 : imp2, 0, video::SColor(255,255,255,255), false);
// draw second flying imp with colorcylce
driver->draw2DImage(images, core::position2d<s32>(270,105),(time/1000 % 2) ? imp1 : imp2, 0, video::SColor(255,(time) % 255,255,255), false);
// draw some text
if (font)
font->draw(L"This is some text.",core::rect<s32>(130,10,300,50),video::SColor(255,255,255,255));
// draw some other text
if (font2)
font2->draw(L"This is some other text.",core::rect<s32>(130,20,300,60),video::SColor(255,time % 255,time % 255,255));
// draw logo
driver->draw2DImage(images, core::position2d<s32>(10,10),core::rect<s32>(354,87,442,118));
// draw transparent rect under cursor
core::position2d<s32> m = device->getCursorControl()->getPosition();
driver->draw2DRectangle(video::SColor(255,100,100,100),core::rect<s32>(m.X-20, m.Y-20, m.X+20, m.Y+20));
driver->endScene();
}
}
device->drop();
return 0;
}
Last edited by Epsilon on Tue Jan 13, 2004 7:10 pm, edited 1 time in total.
Re: Transparent 2d images dont work over a 3d world?
read this thread http://irrlicht.sourceforge.net/phpBB2/ ... .php?t=517Epsilon wrote:All games have HUD transparent so i want to know if i can make it.
you can have 8bit transparency but you will have to tweak the irrlicht source code to do it (in 0.4.2)