Page 1 of 1

EDT_DIRECTIONAL

Posted: Wed Oct 10, 2007 7:40 pm
by mk.1
I use this code to create a simple cube and directional light:

Code: Select all

    camera = smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,0,0)); // add camera


    node = smgr->addCubeSceneNode();
    node->setMaterialTexture(0,driver->getTexture("lvl1.bmp"));

    ILightSceneNode* light1 = smgr->addLightSceneNode(0,vector3df(-1.f,0.f,0.f));
    light1->getLightData().Type = ELT_DIRECTIONAL;
The problem is that only the Apfelbaum Renderer renders correctly (light coming from the "left"), oGL/d3d8/d3d9 all light the front (no matter what values I enter for the position).

Any ideas?

Posted: Wed Oct 10, 2007 8:03 pm
by hybrid
Directional light has no position. Up to now, Irrlicht used the position to calculate a direction from it. You must change it in the SLight structure, though.
The next release will use the position and rotation of the LightSceneNode.

Posted: Wed Oct 10, 2007 8:09 pm
by mk.1
I left the Position change out because I'm using 1.4.1 Beta but I also tried it with changing the SLight structure:

Code: Select all

    ILightSceneNode* light1 = smgr->addLightSceneNode(0,vector3df(-1.f,0.f,0.f));
    light1->getLightData().Type = ELT_DIRECTIONAL;
	light1->getLightData().Position = vector3df(-1.f,0.f,0.f);
doesn't work as well :(

Posted: Wed Oct 10, 2007 9:43 pm
by hybrid
Please read the API for 1.4. It says that you are not supposed to change the position and direction of the SLight structure anymore. You have to position and rotate the LightSceneNode to do this! So since directional light does not care for positions you simply rotate the node such that the positive z-axis points into your desired direction. But it might be also a good idea to change the position to let everyone know that the light is quite far away.

[solved]

Posted: Thu Oct 11, 2007 12:12 am
by mk.1
Alright, I misunderstood something.
Works fine now, thank you

Posted: Mon Feb 25, 2008 4:05 pm
by drewbacca
hybrid wrote:Please read the API for 1.4. It says that you are not supposed to change the position and direction of the SLight structure anymore. You have to position and rotate the LightSceneNode to do this! So since directional light does not care for positions you simply rotate the node such that the positive z-axis points into your desired direction. But it might be also a good idea to change the position to let everyone know that the light is quite far away.
Looking at the API for LightSceneNode, it says:

"You can switch the light on and off by making it visible or not, and let it be animated by ordinary scene node animators. If you set the light type to be directional, you will need to set the direction of the light source manually in the SLight structure, the position of the scene node will have no effect on this direction."

Is the documentation here out of date?

Posted: Tue Feb 26, 2008 12:04 am
by hybrid
Hmm, the docs seems to have gone with the wind. All information about the light direction is and position is lost. I'll update it for the next release.