Topic: Directional Lighting?

Irrlicht 0.14.0 has directional lighting. I cant get it to work with the mods though.
Was it added since 0.13.0?

Re: Directional Lighting?

greetings smile  there should be nothing in the mods that would limit the lights to only point.  could you paste some code?  the default light is a point light.  you will need to alter the SLight structure associated with the light scene node and set the light type to ELT_DIRECTIONAL.  after that, the position vector in the SLight structure is now the direction vector so use that to set the direction the light is coming from.  i believe this is different than using setPosition on the light scene node.  that will only reposition the light itself.

3 (edited by HondaDirtBiker 2006-07-06 14:00:22)

Re: Directional Lighting?

How would I set the light type and change the SLight structure?
This is some code I thought would work.

'Add Directional Light (white)
Local Light:T_irrISceneNode = ..
    Env.addLightSceneNode (Null, T_irrVector3df.createFromVals (0, 0, -40), ..
    T_irrSColorf.createFromRGBA (1.0, 1.0, 1.0, 1.0),ELT_DIRECTIONAL)

BTW, gman your awesome!

4 (edited by HondaDirtBiker 2006-07-08 23:39:22)

Re: Directional Lighting?

I tried some different code that seemed right. When I run it I get a "Unhandled Exception:Attempt to access field or method of Null object".

How do I setup the light handle for a dynamic light?

'Add Directional Light (white)
Local Light:T_irrSLight
Video.addDynamicLight(light)
light.setType(ELT_DIRECTIONAL)

Thank you.

Re: Directional Lighting?

ill see if i can take a more thorough look tonight.  as for the last bit of code, you need to create an instance of T_irrSLight before you can use it.  to do that, use the create() function on the type.  so change your code to:

'Add Directional Light (white)
Local Light:T_irrSLight=T_irrSLight.create()
Video.addDynamicLight(light)
light.setType(ELT_DIRECTIONAL)

Re: Directional Lighting?

I need more help. How would I set the angles and colors? I could only get as far as you showed me.

'Create Directional Light
Local Light:T_irrSLight=T_irrSLight.Create()
Video.addDynamicLight(Light)
Light.setType(ELT_DIRECTIONAL)

Re: Directional Lighting?

there is unfortunately no access to the angles.  there are only two native light types in Irrlicht, point and directional.  for directional, the position of the light is the vector the light is coming from.  point emits light in all directions, but only for the radius the light is set at.  use setRadius() to set the radius.  to get at the colors, you need to use the get() methods on SLight.

Method getAmbientColor:T_irrSColorf()
Method getDiffuseColor:T_irrSColorf()    
Method getSpecularColor:T_irrSColorf()

you then use the returned T_irrSColorf to set the values.  so it looks something like:

light.getAmbientColor().set(.4,0,.8)

HTH!  love seeing folks using Irrlicht smile

Re: Directional Lighting?

I still need to create a Directional Light. I have gotten a light to show.
If I use the Point or Directional Light, the light does'nt appear at the correct position or rotation. Also the specular and diffuse colors don't show, only the ambient.
The Blide IDE returns "Invalid Directionial Light Direction" but still executes.
What could be wrong with my code?

'Add Directional Light
Local LightNode:T_irrILightSceneNode = Scene.addLightSceneNode()
Local Light:T_irrSLight = LightNode.getLightData()
Light.setType(ELT_DIRECTIONAL)
Light.getAmbientColor().set(.5, .7, .5)
Light.getDiffuseColor().set(0, .5, 0)
Light.getSpecularColor().set(.5, .5, 1)
Light.getPosition().set(0, 0, 10)
'light.setRadius(30)

Re: Directional Lighting?