Where are the lights, bob?
by Sascha Tausend · in · 02/03/2005 (12:20 pm) · 4 replies
Hi, just wondering if there is a way to find the sg lights in the light manager. I assume they are registered with the light manager, i wonder if i could ask the light manager (or one of your classes) to do the following:
for all lights in lightmanager
if sgLight
add to myLightInfoList
next
Or are they just normal lights to the light manager, maybe i can somehow use your light blocks to get a subset of lights. How would i use your light blocks to loop thru a set of lights?
Thanks in advance
Sascha
for all lights in lightmanager
if sgLight
add to myLightInfoList
next
Or are they just normal lights to the light manager, maybe i can somehow use your light blocks to get a subset of lights. How would i use your light blocks to loop thru a set of lights?
Thanks in advance
Sascha
#2
By registered i assume you mean lights that are currently used by the gClientSceneGraph? Like, after i called installGLLights() for example...
One other question while i have your attention: If i get the lights position is it in Object or World coordinates?
I am still learning all the bits and bobs, its really hard if you do not have a clear concept of how all works together.
02/04/2005 (6:16 am)
Magical! Simply splendid! That does make sense, although i have to admit i almost had a seizure thinking about how it actually works.By registered i assume you mean lights that are currently used by the gClientSceneGraph? Like, after i called installGLLights() for example...
One other question while i have your attention: If i get the lights position is it in Object or World coordinates?
I am still learning all the bits and bobs, its really hard if you do not have a clear concept of how all works together.
#3
"By registered i assume you mean lights that are currently used by the gClientSceneGraph? Like, after i called installGLLights() for example..."
Yes, also the LightManager sorts the LightInfo objects from most to least significant relative to the current object, which is very handy.
"One other question while i have your attention: If i get the lights position is it in Object or World coordinates?"
The LightInfo position member is in world space, but you can easily convert this to object space relative to the object you're using the light for.
-John
02/05/2005 (8:09 am)
Hi Sascha,"By registered i assume you mean lights that are currently used by the gClientSceneGraph? Like, after i called installGLLights() for example..."
Yes, also the LightManager sorts the LightInfo objects from most to least significant relative to the current object, which is very handy.
"One other question while i have your attention: If i get the lights position is it in Object or World coordinates?"
The LightInfo position member is in world space, but you can easily convert this to object space relative to the object you're using the light for.
-John
#4
02/05/2005 (9:19 am)
Thanks, that really cleared things up for me!!!. Now i can waste the whole weekend coding and getting yelled at by the missus..... ;)
Torque Owner John Kabus (BobTheCBuilder)
The easiest way would be to use TGE's LightSet and a dynamic cast to identify Lighting Pack light objects. For instance:
SimSet *lightset = Sim::getLightSet(); for(SimObject ** itr = lightset->begin(); itr != lightset->end(); itr++) { sgUniversalStaticLight *light = dynamic_cast<sgUniversalStaticLight*>(*itr); if(!light) continue; // use light object here... }This will search all of the objects that register lights skipping anything that is not a Lighting Pack light object.
If you're only looking for lights currently registered in the LightManager then you'll need to a add a flag to sgLightInfoData (something like 'isLightingPackLight'), add code to initialize the member to false when sgLightInfoData is created, and add code in sgUniversalStaticLight::registerLights to set the value to true. This will allow you to search only the currently registered LightInfo objects for those registered by Lighting Pack light objects.
Let me know if this makes sense!
-John