EDT_DIRECTIONAL

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
mk.1
Posts: 76
Joined: Wed Oct 10, 2007 7:37 pm

EDT_DIRECTIONAL

Post 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?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
mk.1
Posts: 76
Joined: Wed Oct 10, 2007 7:37 pm

Post 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 :(
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
mk.1
Posts: 76
Joined: Wed Oct 10, 2007 7:37 pm

[solved]

Post by mk.1 »

Alright, I misunderstood something.
Works fine now, thank you
drewbacca
Posts: 38
Joined: Tue Jan 30, 2007 6:49 pm

Post 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?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
Post Reply