Game Development Community

Light.brightness = 5; no work

by Yue -Rookie Torque 3D- · in Torque 3D Beginner · 08/24/2013 (2:22 pm) · 5 replies

Hi, I'm adapting myself to the script of torque but it seems that some things do not work and most likely I'm doing something wrong.

Light.brightness = 0.5; //No changes are on the level.
Any suggestions.

About the author

http://www.iris3d.tk -Games Studios- <<I do not speak English: I use the google translator>> My goal as a rookie is knowing Torque 3D


#1
08/24/2013 (2:32 pm)
ok no problem.
Light.hidden       = true;
Light.brightness   = 0.5;
Light.hidden       = false;
#2
08/24/2013 (4:39 pm)
In the first line of code you showed, there was a comma where there should have been a semi-colon
Light.brightness = 0.5, / / No changes are on the level.
//Should be:
Light.brightness = 0.5;
Might just be a typo in the post ofc.
#3
08/24/2013 (6:50 pm)
yeah, sorry, the fact is that to update the changes I hide the light and make it appear again.

// Procedure
function ChangeBrightness(%Light,%Brightnes)
{
  // Entity is hidden light, to update the new changes in the level.
 
  %Light.hidden     = true;            // Hide Light. 
  %Light.brightness = %Brightnes;      // New parameter brightness.
  %Light.hidden     = false;           // Show Light.

}

// Call Procedure
ChangeBrightness(Light,0.5);

Likewise, if I want to change if that light casts shadows or not, then I ran into that problem, but hiding the light, and then making it appear is updated level changes.

i40.tinypic.com/2ywxykp.jpg
#4
08/25/2013 (10:55 am)
From what I understand, changing datablock values via TorqueScript doesn't affect the object. Generally the object should have methods on it to call in order to change properties in real time.Unfortunately it looks like the Light object doesn't have a method to change brightness. One should probably be added.
#5
08/25/2013 (11:47 am)
If you're not opposed to modifying the source you can copy the function used for the sky. Just add this at the bottom of lightBase.cpp:

DefineEngineMethod( LightBase, applyChanges, void, (),,
                   "Apply a full network update of all fields to all clients.")
{
   object->inspectPostApply();
}

Then you can use:

Light.brightness = 5;
Light.applyChanges();

If you don't want to modify the source you can "trick" the light into updating by setting it to play an animation.

Light.brightness = 5;
Light.playAnimation("SpinLightAnim");
Light.pauseAnimation();

That is a pretty ugly way to go about it, though. I quickly looked through the lightBase class and didn't see anything else that sets the update mask but I may have missed something.

EDIT: Ah, sorry, I didn't read the previous post properly, so setting it to hidden and back works as well. Seems the engine method should be added to the lightBase class, though