lighting issues

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
knutcj
Posts: 5
Joined: Tue Jan 02, 2007 10:14 pm

lighting issues

Post by knutcj »

First of all... hi all.

I've only been working with the Irrlicht engine for about two weeks, and I havent done any programming for about two years, so I'm pretty rusty.
What I'm making isn't a game, as such. It's more like an interactive floorplan. All I need is a camera I can walk arround with, in a completely static environment.

I'm loading in *.obj files exported from Maya with addAnimatedMeshSceneNode:

Code: Select all

IAnimatedMesh* mesh = smgr->getMesh("plan1.obj");
ground = smgr->addAnimatedMeshSceneNode(mesh);
ground->setMaterialType(EMT_SOLID);
Why I'm using an animeted mesh for something that wil be completely static?
No reason really. I was just looking at the examples when I started, and I don't have time to change it now.

Anyways...
To be able to load the texture with the corresponding *.mtl file, I had to erase "-s 0.05 0.05" from in front of every *.jpg that was listed in the file, otherwise Irrlicht tries to load a texture called -s etc.

So that's the background, now for the trouble...

I'm having trouble lighting the geometry.
If I turn lighting of "ground->setMaterialFlag(EMF_LIGHTING, false);" I can see the textures, but nothing, of course, has any depth.
When I turn lighting on, I can't see the textures. I only see a greyscale world!?

This is how I flip the lightswitch:

Code: Select all

ground->setMaterialFlag(EMF_LIGHTING, true);" 
...

ILightSceneNode* sun = smgr->addLightSceneNode(ground, vector3df(0,15,0), SColorf(2.0f, 2.0f, 2.0f), 40.0f, 1);
SLight& sunData = sun->getLightData();
sunData.Type = ELT_POINT;
sunData.CastShadows = true;
sunData.DiffuseColor = SColorf(0, 0, 0);
...

//Back- and Z-Buffer is on
driver->beginScene(true, true, SColor(255, 160, 160, 160));
I've tried using a directional light as well, but that only makes it look like there's a lightningstorm going on inside. Walls flikker like a baby just figured out how to turn on and off the light in there. And it's all just greyscales.

What am I doing wrong?
Do I need to fix the *.mtl file some more? or specify the meshmaterial manually somehow?

Speedy help appreciated, as It's due next Monday :?

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

Post by hybrid »

Could you upload (or mail, check my webpage for the addresse) the mesh so I can have a look at it. Please also include the textures.
harukiblue
Posts: 49
Joined: Sun Dec 10, 2006 6:23 pm

it is the posisiont of your light

Post by harukiblue »

I believe I have the fix. Your light parameters are incorrect.

Code: Select all

ILightSceneNode* sun = smgr->addLightSceneNode(ground, vector3df(0,15,0), SColorf(2.0f, 2.0f, 2.0f), 40.0f, 1);
the 2nd parameter of this light is a vector of the position of the light, it may be behind some geometry. the 4th parameter is the radius of the light wich may be too small.

also, you made the lights color pure black:

Code: Select all

sunData.DiffuseColor = SColorf(0, 0, 0); 
Use this instead:

Code: Select all

sunData.DiffuseColor = SColorf(255,255,255); 
with out seeing your model or a screen shot these are the only things I can tell that may be incorrect. Post a screeny to help :wink:
knutcj
Posts: 5
Joined: Tue Jan 02, 2007 10:14 pm

Post by knutcj »

omg.

I can't believe it. It WAS becaus I had turned the light pure black. I was thinking the other way arround. Gave the light som actual colour, and I can see textures. Wee!

Thnx mate

Everything is moi bright though. Think I'll still have to change the materials either in the .mtl file or when I've loaded the meshes.
harukiblue
Posts: 49
Joined: Sun Dec 10, 2006 6:23 pm

that is what I do 8)

Post by harukiblue »

Not a problem. We gotta help each other! Good luck mate :mrgreen:
Post Reply