help needed on lighting the wall in room

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
baoyicai
Posts: 6
Joined: Tue May 22, 2007 7:28 am

help needed on lighting the wall in room

Post by baoyicai »

hi,
I loaded a room of .my3d format and try to light the room with a lighting node, but it seems that only the floor is lightened, the wall is all black.
I have adjusted the radius of the light and it doesn't work.

the code relevent is as follow

Code: Select all

//code for a room
                scene::IAnimatedMesh *house_mesh;
                house_mesh=smgr->getMesh("Data/media/may20/room2/room17.MY3D");
	scene::IAnimatedMeshSceneNode* house_node=smgr->addAnimatedMeshSceneNode (house_mesh);
	house_node->setPosition (core::vector3df (0,-40,0));
	house_node->setMaterialFlag(video::EMF_LIGHTING, true);


	//add a light
	
	scene::ISceneNode* light_node1 = smgr->addLightSceneNode( 0,core::vector3df(20.0,20.0,30.0), video::SColorf(1.0f,0.9f,0.80f,1.0f), 8000.0f);
//	scene::ISceneNode* light_node2 = smgr->addLightSceneNode( 0,core::vector3df(0.0,400.0,0.0), video::SColorf(1.0f,1.0f,1.0f,1.0f), 1000.0f);
//	scene::ISceneNode* light_node3 = smgr->addLightSceneNode( 0,core::vector3df(0.0,-400.0,0.0), video::SColorf(1.0f,1.0f,1.0f,1.0f), 1000.0f);
	scene::ISceneNodeAnimator* sphere_node_light = smgr->createFlyCircleAnimator(core::vector3df(67,50,0),0.0f);
	light_node1->addAnimator(sphere_node_light);
	sphere_node_light->drop();


	//attach billboard to light
	light_node1 = smgr->addBillboardSceneNode(light_node1,core::dimension2d<f32>(50,50));
	light_node1->setMaterialFlag(video::EMF_LIGHTING, false);
	light_node1->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
	light_node1->setMaterialTexture(0,	driver->getTexture("Data/media/particlewhite.bmp"));
the picture is like this:
Image
what is quite odd is that if I put other two light node below and above the house(light node 2 and 3 ), the wall will be lighted....and also, the model got three shadows...
pic:
Image

and one could help??? really thanks a lot... [/b]
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The normals are wrongly orientated. Even though you can see the wall's front face does not mean that the normal (which is required for lighting calculations) is also oriented that way. In case you scale the mesh inside Irrlicht do not forget to add EMF_NORMALIZE_NORMALS, but also check your mesh in your 3d modelling tool and fix the normals there. You can also use the MeshManipulator to recalculate normals, but inside the modelling tool would be better.
baoyicai
Posts: 6
Joined: Tue May 22, 2007 7:28 am

Post by baoyicai »

thanks:)
I added
house_node->setMaterialFlag(video::EMF_NORMALIZE_NORMALS,true);
but still got the same problem..i guess the wall's normal is not right. but how to use MeshManipulator to change the nromal?
is it using
smgr->getMeshManipulator()->recalculateNormals((house_mesh),true); ?
I tried to change the normal of walls in 3dmax, but still not ok...
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

If you must 'fix' this in code, the mesh manipulator has a function for flipping normals. Use that. The best solution would be to flip the normals in your modelling tool.

Travis
baoyicai
Posts: 6
Joined: Tue May 22, 2007 7:28 am

Post by baoyicai »

thanks:)
tried but still quite weird...
anyway i tried to add all the lighting in irrEdit and save as .irr file and load as a scene and it works fine.
Post Reply