PDA

View Full Version : Get the value of Light Intensity?



Neochris
06-19-2004, 07:53 AM
hi everyone,
I'm a newbie of writing LScript.

I meet problems here:
I would like to select each light in order, and then get it's Light Intensity value.
after that, I'll do " Intensity = Intensity * 2.5 " to each light, and loop again and again when there is no any lights ever been selected.
therefore, I find I have no ideas to get the Light Intensity of current light selected...
Is there any one give a help?

here is my code:


@warnings
@name int_scalar

generic
{
light_number=20000000;
CurrLightIntensity= ??(I have no idea here) ;
SelectItem=false;
while(!SelectItem)
{
SelectItem(light_number);
ItemProperties();
LightIntensity(CurrLightIntensity = CurrLightIntensity * 2.5);
light_number++;
}
}


very thanks to reply and help for me!
thx all!

:) :) :)

Matt
06-19-2004, 10:43 AM
Looking through the Lscript docs I can't find any reference to the data object that contains the light intensity.

However, the following code may be useful in showing you how to grab a list of all the lights in the scene, and also put them into a list gadget.

Hope it helps!

Cheers
Matt





// light_tester.ls

@version 2.2
@warnings
@script generic
@name Light Tester


// Declare our variables ...

// Our light data arrays
light_names;

// Needed for our list gadget
UI_light_list_gadget;


generic
{


// Grab first light in scene ...
current_light = Light();


// Loop through all the lights in the scene ...
while(current_light)
{

// Store current light name into 'light_names' array
light_names += current_light.name;

// If there was a data object to query the light intensity you would build the list here the same way the
// names list is done. However, it looks like there is no such value to be able to test.
// You can set the light intensity using LightIntensity(VALUE); but it appears you can't test for it?!!!?


// Select next light in scene ...
current_light = current_light.next();
}


// Initialise requester window
reqbegin("Light Tester");

// Specify our requester window size
reqsize(300,300);


// Initialise our gadgets ...


// Command template for the 'list' gadget
// (UDF = User Definable Function, bascially callback functions that supply data, the UDFs are at the bottom of this lscript)
// ctllistbox("TITLE", WIDTH_OF_CONTROL, HEIGHT_OF_CONTROL, "NUMBER_OF_ITEMS_IN_LIST_UDF", "POPULATE_LIST_UDF");

UI_light_list_gadget = ctllistbox("Light Names",175,240,"count_the_lights_in_the_scene","supply_list_of_light_names");
ctlposition(UI_light_list_gadget, 10,10, 260, 250);


// Return if requester can't be opened
return if !reqpost();


// Close requester
reqend();

}

// ----------------------------------------------------------------------------------------------------------------------------------------------------------------

// UDFs ...


// User Definable Function to count how many lights we have
count_the_lights_in_the_scene
{
return(light_names.size());
}


// User Definable Function to populate the light names gadget
supply_list_of_light_names: index
{
return(light_names[index]);
}

faulknermano
06-19-2004, 07:59 PM
Originally posted by Neochris
[B]
therefore, I find I have no ideas to get the Light Intensity of current light selected...
Is there any one give a help?



there is no direct way of doing it.

a workaround might be to select the light, create an envelope for the light and then retrieve the light intensity channel from the envelope (use the envelope object agent so you can get it immediately) and then, if you dont want the envelope anymore, delete it.

otoh, try searching the intensity channel of the light using the channel object agent first. maybe it's there, even though envelopes have no yet been created.

Neochris
06-20-2004, 01:38 AM
to all,
thanks reply!
I'll try more.
you give me good helps!

:) :) :)