How to turn lights on and off?
by C. David Belt · in · 08/17/2005 (5:54 pm) · 12 replies
I want to implement a light switch in a room. I want to turn the lights in the room on and off. I have two sgUniversalStaticLight instances called myLight and myLight2. In the onCollision event for the the light switch object, how do I turn myLight and myLight2 off?
Dave
Dave
#2
BTW, I still not able to get shadows for my DTS objects in my interior. The only lights that I am using are these sgUniversalStaticLight instances in the interior. Any ideas?
Dave
08/17/2005 (6:18 pm)
I knew it had to be something simple! Thanks! BTW, I still not able to get shadows for my DTS objects in my interior. The only lights that I am using are these sgUniversalStaticLight instances in the interior. Any ideas?
Dave
#3
You can also move your DTS objects into the Lighting Pack demo to verify that the objects are setup correctly. If the shadows look correct then move the demo's trees into your project and see if the trees cast proper shadows in your project. This will help identify the problem as being either code or content.
08/17/2005 (6:34 pm)
The DTS objects need to be of type TSStatic or ScopeAlwaysStaticShape, and need to have convex collision hulls. Also the lights need to be static and have shadows enabled in the Light Editor (and make sure the lights are not entirely ambient otherwise the shadows won't show up - ambient lighting doesn't cast shadows).You can also move your DTS objects into the Lighting Pack demo to verify that the objects are setup correctly. If the shadows look correct then move the demo's trees into your project and see if the trees cast proper shadows in your project. This will help identify the problem as being either code or content.
#4
I have a ball that is a TSStatic and has a spherical collision mesh.
I will verify the rest. Thanks!
Dave
08/17/2005 (6:37 pm)
Thank you. I will verify all of that. I have a ball that is a TSStatic and has a spherical collision mesh.
I will verify the rest. Thanks!
Dave
#5
I am turning the lights on and off just fine.
How do I do a filtered relight of the scene dynamically (because the interior stays lit when I turn off the lights)?
Dave
08/18/2005 (10:27 am)
I have SHADOWS! Thanks.I am turning the lights on and off just fine.
How do I do a filtered relight of the scene dynamically (because the interior stays lit when I turn off the lights)?
Dave
#6
Relighting the scene in the middle of a game will cause a noticeable pause, so it's probably not what you want.
Static lights aren't designed to be changed in-game (that's why they're static), dynamic lights can be changed in-game but only cast shadows from dynamic objects like players and vehicles.
If you are trying to prevent dynamic lights from bleeding through walls check out the Lighting Pack Release Notes - there's a section on zone lighting, which prevents this sort of thing (effectively allowing the walls to cast shadows even with dynamic lights).
-John
08/18/2005 (12:32 pm)
Hi David,Relighting the scene in the middle of a game will cause a noticeable pause, so it's probably not what you want.
Static lights aren't designed to be changed in-game (that's why they're static), dynamic lights can be changed in-game but only cast shadows from dynamic objects like players and vehicles.
If you are trying to prevent dynamic lights from bleeding through walls check out the Lighting Pack Release Notes - there's a section on zone lighting, which prevents this sort of thing (effectively allowing the walls to cast shadows even with dynamic lights).
-John
#7
I am turning the lights on and off just fine.
How do I do a filtered relight of the scene dynamically (because the interior stays lit when I turn off the lights)?
Dave
08/18/2005 (3:51 pm)
I have SHADOWS! Thanks.I am turning the lights on and off just fine.
How do I do a filtered relight of the scene dynamically (because the interior stays lit when I turn off the lights)?
Dave
#8
My goal was shadows AND the ability to turn the lights on and off. My understanding is that I MUST use static lighting to get shadows on the interior from static objects.
Is the only real solution to use dynamic lighting AND convert all of that static objects to players or vehicles?
Dave
08/18/2005 (3:54 pm)
The only reason that I am using static lights is to get the shadows from static objects. My goal was shadows AND the ability to turn the lights on and off. My understanding is that I MUST use static lighting to get shadows on the interior from static objects.
Is the only real solution to use dynamic lighting AND convert all of that static objects to players or vehicles?
Dave
#9
(Sorry about the double post earlier. )
Dave
08/18/2005 (3:58 pm)
Also, is there a way to get static objects to cast shadows on other static objects? Or player objects to cast shadows on static objects? (Sorry about the double post earlier. )
Dave
#10
When rigging a scene I use static lights to create shadows and then layer dynamic lights over top in order to create lighting contrast that causes the eye to see shadows. Experimenting with a combination of static and dynamic lights will help you find a suitable method for your scene.
Even if your scene doesn't call for static lights (say you want to walk into a darkened room) you'll still need them - trying to find your way around a pitch black screen is not going to make for a fun game. Use this to your advantage, add static lights to create a radiosity effect (like light pouring in from another room) - use these static lights to cast your underlying shadows, then layer the dynamic light(s) on top.
Also keep the radius of the dynamic lights small, a large radius gives away too much of the scene and creates a flat ambient look.
There's a section in the Modeler's Guide named 'Common DTS Lighting Scenarios' devoted to the different ways you can rig static objects to place them in shadows.
08/18/2005 (4:22 pm)
That's definitely not a good idea. I'm saying that you need to adapt your scene slightly - the proper lighting rig will hide the fact that the DTS objects are not casting dynamic shadows.When rigging a scene I use static lights to create shadows and then layer dynamic lights over top in order to create lighting contrast that causes the eye to see shadows. Experimenting with a combination of static and dynamic lights will help you find a suitable method for your scene.
Even if your scene doesn't call for static lights (say you want to walk into a darkened room) you'll still need them - trying to find your way around a pitch black screen is not going to make for a fun game. Use this to your advantage, add static lights to create a radiosity effect (like light pouring in from another room) - use these static lights to cast your underlying shadows, then layer the dynamic light(s) on top.
Also keep the radius of the dynamic lights small, a large radius gives away too much of the scene and creates a flat ambient look.
There's a section in the Modeler's Guide named 'Common DTS Lighting Scenarios' devoted to the different ways you can rig static objects to place them in shadows.
#12
I have a problem with a pointLight. In the world editor I drag a pointLight named pointLight1 and I set it to isEnabled with false. Then I need to turn it on from torque script when a trigger enters the "onEnterTrigger". The trigger works fine, and I have the line pointLight1.setEnable(true); and you can see that in the world editor, this light is checked to true in the isEnabled property, but in the scene the light doesn't turn on!!! can you tell me what am I doing wrong? Perhaps my light is static and not dynamic? and if that is the problem, how can I drag a dynamic light in the world editor? Thanks
07/16/2010 (3:13 pm)
Hi I have a problem with a pointLight. In the world editor I drag a pointLight named pointLight1 and I set it to isEnabled with false. Then I need to turn it on from torque script when a trigger enters the "onEnterTrigger". The trigger works fine, and I have the line pointLight1.setEnable(true); and you can see that in the world editor, this light is checked to true in the isEnabled property, but in the scene the light doesn't turn on!!! can you tell me what am I doing wrong? Perhaps my light is static and not dynamic? and if that is the problem, how can I drag a dynamic light in the world editor? Thanks
Torque Owner John Kabus (BobTheCBuilder)
Just call 'myLight.setEnable(false)' to disable the light and 'myLight.setEnable(true)' to enable it (make sure the light is dynamic).
-John