Is there a way to temporary disable a single lightsource?

Hi Monkeys,

I have a little question about lights.

My goal is to have a lot of lights which only light up if a player is near it.

Obviously they should turn off if the player is out of range.

I tried a lot of different things.

Figure:


|-- RootNode
...|-- Segments (Currently the PointLights are here)
......|-- Segment 1
......|-- Segment 2
......|-- Segment 3
|-- GUI Node.....
...

1. Setting radius to <= 0 -- Fail. (Really small radius works but eats performance - it's also rather a bad idea i admit :P)
2. Setting color and alpha to (0, 0, 0, 0) -- Fail
3. Extending the PointLight class to be able to access the protected "enabled" member and set it to "false" when needed. -- Fail

I know I can remove it from the node. But IMO it's not really the best method.
I also know I can put it into a Node and cull it.
But since a light only lights its children I don't think this works since culling would also hide all its children...
I also want to do this for performance reasons since a lot of lights are really cost intensive.
Is there any way to disable a single light source temporary without removing it from the scene?

Look at the LightNode.java.

1 Like
glaucomardano said:
Look at the LightNode.java.


Thank you glaucamardano for your input.

But I don't get how to organize them. If I understand correctly they are basicly a Node with a Light attached to it.
So I have the same problem since LightSources only lighten up their children. And I can't put my segments into all LightNodes. Or with other words: I can't add multiple lights to my segments.

Not sure if I am correct. But feel free to correct me :)


|– RootNode
…|– Segments
……|– LightNode 1 (Will only light up segment 1 -> Fail)
…...…|– Segment 1
……|– LightNode 2 (Will only light up segment 2 -> Fail)
…...…|– Segment 2


Greetings,
superm4n.

I would create one light attached to the root node and reposition as needed. If you create a node for every segment, you could use the nodes position to relocate your light.


glaucomardano said:
Look at the LightNode.java.


There is a method [java]public void setEnabled(boolean enabled)[/java] that seems to turn a light on or off.

Just a few thoughts. I have to admit that I am a newbie monkey and could be totally wrong. hehe
1 Like
superm4n said:
Thank you glaucamardano for your input.


I'm Glauco Márdano, not Glauca Márdano...xD

lotekk said:
Just a few thoughts. I have to admit that I am a newbie monkey and could be totally wrong. hehe


No, you are not wrong ;).