Mesh Lighting 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
gavinj64738
Posts: 11
Joined: Sat Jun 21, 2008 4:10 am

Mesh Lighting Problem

Post by gavinj64738 »

Hi guys,

Im having trouble lighting some meshes loaded from .3ds files and then materials attached. Here is the what im talking about

Image
With lighting turned off

Image
With lighting turned on

Here is my code

Code: Select all

	// draw something else eg.. spacestation, comet, etc.
			scene::IAnimatedMesh* nmesh = 0;
			nmesh = smgr->getMesh(mesh);
			
			node = smgr->addAnimatedMeshSceneNode(nmesh);
			if(strcmp(this->skin,"DefaultName")!=0)
			{
				node->setMaterialTexture(0, driver->getTexture(skin));
			}
			if (meshsize!=0)
			{
				node->setScale(irr::core::vector3df(meshsize,meshsize,meshsize));
				node->setMaterialFlag(video::E_MATERIAL_FLAG::EMF_NORMALIZE_NORMALS, true);
			}
			node->setMaterialFlag(video::EMF_LIGHTING, false);
			node->setMaterialFlag(video::EMF_FOG_ENABLE, true);
			
			return true;
Ive tried messing with the flags etc but dont seem to be having any luck.. Anybody know what im doing wrong?

Thx
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

You say there is a problem, but you don't tell us what it is, and then you show pictures, but you don't tell us where to look. Perhaps it would help if you described the problem a little bit. Then, if it is necessary, you could provide screenshots that show the problem, possibly with some annotations so we know what we're looking for?

Travis
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

After looking at the pictures many times, I think that the problem is with the object floating to the right of the player's aircraft (the one in the center of the screenshots). Is this what you're talking about? When lighting is off it looks reasonable, but with lighting on faces are either solid white or solid black?

Travis
gavinj64738
Posts: 11
Joined: Sat Jun 21, 2008 4:10 am

Post by gavinj64738 »

Yes the lighting totally removes the texture and replaces it with white and the shadows are completly black, but as you can see with the players ship model which has its own materials attached to the model and no skin property, the vehicale does not display as black and white only with the same lighting.

The planets are spheres with a material attached to them and under the same lighting they are displaying correctly. Im guessing its a material type or flag or combination of both to adjust how much the lighting is effecting the materials.. any help would be appreciated...
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Post by cobra »

Did you try, in the 3D editor (like Blender, 3DSMax etc.) to set the normals of it? I use .obj for all of my meshes, and before I export them, if I get shading errors in Irrlicht, I just set it to do advanced normals calculation on it and it fixes any errors, but tends to leave your meshes a bit blockier.

Try saving a backup of the module/capsule setting the normals, and saving over the original, and see if that helps. :)
Josiah Hartzell
Image
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

wasn't there a problem with .3ds meshes and it's normals in Irrlicht ???
IIRC the normals of .3ds meshes are not correct interpreted by Irrlicht...
try to use another format (.x or .obj)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
gavinj64738
Posts: 11
Joined: Sat Jun 21, 2008 4:10 am

Post by gavinj64738 »

Many thanks, it seems that the issue was caused by my choise of format. I simple exported the object from within 3dsmax to an OBJ and it looks much much better.

Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I'd say it's a problem with one of the lighting parameters. The normals should be ok, just make sure you use RENORMALIZE_NORMALS when scaling the mesh. But you may need to disable emissive values or something. Maybe upload the mesh somewhere.
gavinj64738
Posts: 11
Joined: Sat Jun 21, 2008 4:10 am

Post by gavinj64738 »

Ive set it to adjust the normals when the size is altered. It would be much easier if i didnt have to convert all of the models. Any idea of what settings i should use?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

hybrid wrote:Maybe upload the mesh somewhere.
It depends on the mesh properties what's going wrong here. We can only guess - so if you cannot upload the mesh, just play around with the material settings.
Post Reply