image not working

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
gamerfan
Posts: 43
Joined: Mon Nov 30, 2009 9:28 am

image not working

Post by gamerfan »

Hi,
I have added a cross-hair jpg file to my gun node.The image is displaying. But there is background white-square also appearing.I want to remove the white square. Any idea how to fix this?

Thank in advance
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

mind to give more info? or show some pictures to explain your problem.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I guess you want an alpha channel for your image.
gamerfan
Posts: 43
Joined: Mon Nov 30, 2009 9:28 am

Post by gamerfan »

This is my code:

Code: Select all

ISceneNode crosshairnode = smgr.addBillboardSceneNode(camera,  new dimension2df(1, 1));
		 crosshairnode.setMaterialType(E_MATERIAL_TYPE.EMT_TRANSPARENT_ADD_COLOR);
		 crosshairnode.setMaterialTexture(0, driver.getTexture("../media/cross.jpg"));
		 crosshairnode.setMaterialFlag(E_MATERIAL_FLAG.EMF_LIGHTING, false);
		 crosshairnode.setMaterialFlag(E_MATERIAL_FLAG.EMF_GOURAUD_SHADING,true);
 //crosshairnode.setMaterialFlag(E_MATERIAL_FLAG.EMF_ZBUFFER, false);
gamerfan
Posts: 43
Joined: Mon Nov 30, 2009 9:28 am

Post by gamerfan »

Any solution ?,

Thanks in advance
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

gamerfan wrote:This is my code:

Code: Select all

ISceneNode crosshairnode = smgr.addBillboardSceneNode(camera,  new dimension2df(1, 1));
		 crosshairnode.setMaterialType(E_MATERIAL_TYPE.EMT_TRANSPARENT_ADD_COLOR);
		 crosshairnode.setMaterialTexture(0, driver.getTexture("../media/cross.jpg"));
		 crosshairnode.setMaterialFlag(E_MATERIAL_FLAG.EMF_LIGHTING, false);
		 crosshairnode.setMaterialFlag(E_MATERIAL_FLAG.EMF_GOURAUD_SHADING,true);
 //crosshairnode.setMaterialFlag(E_MATERIAL_FLAG.EMF_ZBUFFER, false);
this wont work with transparency as long as you don't make a color key texture... :lol:

try something like this:

Code: Select all

ITexture image = driver.getTexture("../media/cross.jpg");
driver.makeColorKeyTexture(image, position2d<s32>(0,0));

ISceneNode crosshairnode = smgr.addBillboardSceneNode(camera,  new dimension2df(1, 1));
		 crosshairnode.setMaterialType(E_MATERIAL_TYPE.EMT_TRANSPARENT_ADD_COLOR);
		 crosshairnode.setMaterialTexture(0, image);
		 crosshairnode.setMaterialFlag(E_MATERIAL_FLAG.EMF_LIGHTING, false);
		 crosshairnode.setMaterialFlag(E_MATERIAL_FLAG.EMF_GOURAUD_SHADING,true);
 //crosshairnode.setMaterialFlag(E_MATERIAL_FLAG.EMF_ZBUFFER, false);
well, I'm not sure what compiler you use, so I also used the dot operator like you... :shock:
I mean in normal case you do this:

Code: Select all

driver->getTexture("../media/cross.jpg");
instead of this:

Code: Select all

driver.getTexture("../media/cross.jpg");
so for me the code should look like this:

Code: Select all

ITexture* image = driver->getTexture("../media/cross.jpg");
driver->makeColorKeyTexture(image, position2d<s32>(0,0));

ISceneNode* crosshairnode = smgr->addBillboardSceneNode(camera,  dimension2df(1, 1));
       crosshairnode->setMaterialType(EMT_TRANSPARENT_ADD_COLOR);
       crosshairnode->setMaterialTexture(0, image);
       crosshairnode->setMaterialFlag(EMF_LIGHTING, false);
       crosshairnode->setMaterialFlag(EMF_GOURAUD_SHADING,true);
 //crosshairnode->setMaterialFlag(EMF_ZBUFFER, false); 
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
gamerfan
Posts: 43
Joined: Mon Nov 30, 2009 9:28 am

Post by gamerfan »

Thank for your reply.I am using jdk1.6
This is my picture

Code: Select all

 http://www.flickr.com/photos/45746796@N05/4203071963/
 
I am not sure whether you can see this image
gamerfan
Posts: 43
Joined: Mon Nov 30, 2009 9:28 am

Post by gamerfan »

Thanks for the reply.After making changes the way you told me, still I am getting the white square.Please see the above link.
gamerfan
Posts: 43
Joined: Mon Nov 30, 2009 9:28 am

Post by gamerfan »

location for cross.jpeg

Code: Select all

http://www.flickr.com/photos/45746796@N05/4203154803/
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

hmmm, maybe a problem with the jsdk ??? :shock:

or it could be a mipmap problem, bc you're using a billboard node...
so you can also try to regenerate the mipmap levels:

Code: Select all

ITexture image = driver.getTexture("../media/cross.jpg");
driver.makeColorKeyTexture(image, position2d<s32>(0,0));
image.regenerateMipMapLevels();

ISceneNode crosshairnode = smgr.addBillboardSceneNode(camera,  new dimension2df(1, 1));
       crosshairnode.setMaterialType(E_MATERIAL_TYPE.EMT_TRANSPARENT_ADD_COLOR);
       crosshairnode.setMaterialTexture(0, image);
       crosshairnode.setMaterialFlag(E_MATERIAL_FLAG.EMF_LIGHTING, false);
       crosshairnode.setMaterialFlag(E_MATERIAL_FLAG.EMF_GOURAUD_SHADING,true);
 //crosshairnode.setMaterialFlag(E_MATERIAL_FLAG.EMF_ZBUFFER, false); 
gamerfan wrote:location for cross.jpeg

Code: Select all

http://www.flickr.com/photos/45746796@N05/4203154803/
is this the original size you're using (350 x 350) ???
if so then try dimensions with POT (eg 256x256 or 512x512)... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

For TRANSPARENT_ADD_COLOR you don't need white, but black regions which will be transparent (color 0 adds nothing, white will become solid white). You should use TRANSPARENT_ALPHA_CHANNEL and add a transparency mask in the alpha channel.
gamerfan
Posts: 43
Joined: Mon Nov 30, 2009 9:28 am

Post by gamerfan »

should I use any editor to do that else any sample code that is doing this?

However I found similar thread below:

http://irrlicht.sourceforge.net/phpBB2 ... +channel

But it looks like the issue is still there
Post Reply