I am trying to light any of my own objects, but their lighting seems binary (either completely black, or completly illuminated if using the video::EMF_LIGHTING flag). I have made a simple object as follows:
This works fine, but the object doesn't light up when I add a light from the 'PerPixelLighting example' included with irrlicht. However. if I add the 'room.3ds', this inherits the light fine as the light flies around the room.
Is there another flag I need to apply to my simple object so that it too has light based on the flying light form the example?
Last edited by ozrinaut on Wed Jan 17, 2007 7:51 pm, edited 1 time in total.
You probably have to subdivide your mesh to get more detailed gradients. At least under OpenGL large faces can make the shading impression quite ugly. The cube scene node does not support more detailed meshes, though.
hybrid wrote:You probably have to subdivide your mesh to get more detailed gradients. At least under OpenGL large faces can make the shading impression quite ugly. The cube scene node does not support more detailed meshes, though.
But I have now loaded in the .x dwarf included in the examples. He light's up properly there, but when I load him into my scene he does not. Ideas?
FIXED (sorta)
I commented out the two material flags below, on the dwarf, and now he lights up correctly as the lights fly around the room. However, if I uncomment the simple 'addCubeSceneNode(1)' it still appears black.
Of course you have to set LIGHTING to true (which is is by default). The NORMALIZE_NORMALS is only necessary if you scale the scene node. If you don't scale, this setting would only slow down your scene. But if you don't set it when scaling you might get weird lighting depending on your gfx card capabilities. But I don't know about the other problem.
Are you saying that the cube appears black when lighting is enabled and white when it is disabled?
There could be a problem locating the texture file or loading it. You can check the first thing easily by verifying that the pointer returned by getTexture() is a non-null pointer. If it is null, then the texture was not found or could not be loaded.
The other thing might be that the light is inside the cube. You're making a cube that is 50x50x50. Like putting a flashlight in a shoebox, if the light is inside the cube, the outside will not be lit.
As mentioned by hybrid, if you disable lighting on a node it won't appear properly. Usually they end up being solid white. Typically you want to leave lighting enabled and you set an ambient light so that it isn't pitch black in areas that aren't near the light sources.
I am now able to light objects, however...I have exported the default cube from blender as a .3ds file and loaded fine in my scene. It appears to be lighting fine..
I have a few new issues:
1.] For some reason my cube is not inheriting textures.
2.] When I navigate the camera inside the cube, it clips and turns invisible [unlike the example room.3ds provided with irrlicht]
The second issue is caused by backface culling. The cube has faces with normals that point out from the center of the cube. The side of the face that the normal comes out of is called the front face. The other side, on the inside of your cube, is called the back face. If you want the faces to always render the inside and outside, set the EMF_BACK_FACE_CULLING flag to false for your scene node.
The room.3ds mesh is essentially the inside of a cave. Each of the faces has the normal pointing into the center of the cave. If you move the camera out of the cave, you will see that the outside is not rendered.