Alpha Bug

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
PadrinatoR
Posts: 50
Joined: Tue Mar 09, 2004 9:53 pm
Location: Spain

Alpha Bug

Post by PadrinatoR »

After trying to change the alpha level of my meshes lots of times, I've written a little program that shows why I cannot do this. I've sent that program to Niko. Anyway, I post here the code:

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;
}
I hope it will be fixed :)

Byee!! Viva Irrlicht!!! xDD
There are only 10 types of people: those who understand binary and those who don't

--------------------------------------------

Image
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

It is on my list. Didn't you receive an answer to my mail?
PadrinatoR
Posts: 50
Joined: Tue Mar 09, 2004 9:53 pm
Location: Spain

Post by PadrinatoR »

First, thanks for answering :)
I didn't receive anything :S
There are only 10 types of people: those who understand binary and those who don't

--------------------------------------------

Image
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

PadrinatoR wrote: I didn't receive anything :S
Hm, strange. Sorry. :)
But I wrote something like 'it is on my todo list' :))
puh
Posts: 356
Joined: Tue Aug 26, 2003 3:53 pm

Post by puh »

I think i found a quick-fix for this problem (thanks to POi and PadrinatoR from http://irrlicht.sourceforge.net/phpBB2/ ... hp?p=10477).
I create .x file with simple window, and add two "open" animations (you can download it here). But when I added it to irrlicht envirenment alfa transparent glasses became solid colored. Then I just added:

Code: Select all

video::SMaterial glass_material;
glass_material.EmissiveColor  = video::SColor(0,50,60,60);
glass_material.MaterialType=EMT_TRANSPARENT_ADD_COLOR;
win0->getMaterial(5)=glass_material;
win0->getMaterial(2)=glass_material;
win0->getMaterial(1)=glass_material;
Last three lines valid only for my mesh. In your case it will be different.
This method is not optimal, it's just quick-fix. I hope Niko will add possibility to load partially transparent meshes in all mesh-loaders in future.
Post Reply