LOST IN THE DARK! script relighting not working, editor bug
by J · in Technical Issues · 09/13/2007 (8:25 am) · 12 replies
Alright, I have a sun/moon cycle and i'm changing the lighting as the sun goes down.
The sun is setup with to cast no shadows.
I grab the ambient and color values and change them.
Then update my values: sun.setFieldValue(ambient, "bla bla bla bla");
Then I call a relight: lightScene("",forceAlways);
I get nothing.
I've dug around and I've found some wierd stuff.
In the world editor you can console the functions in and it doesn't do anything,
Or you can use the editor and change your values. Doesn't do anything.
The only time lightScene(); will work is if you actually click on another simobject in the editor (say terrainBlock) and then click back on the sun object. Then you can go to your console and type lightScene("",forceAlways); and it works just fine. It updates the values somehow. No, Hitting apply doesn't work.
So there is a bug there that is hindering me. I think its in the lightScene(); function and how it obtains the values. But then again I'm not that good with torque to determine if that's actually the case.
Any help would be greatly appreciated.
Thank you.
The sun is setup with to cast no shadows.
I grab the ambient and color values and change them.
Then update my values: sun.setFieldValue(ambient, "bla bla bla bla");
Then I call a relight: lightScene("",forceAlways);
I get nothing.
I've dug around and I've found some wierd stuff.
In the world editor you can console the functions in and it doesn't do anything,
Or you can use the editor and change your values. Doesn't do anything.
The only time lightScene(); will work is if you actually click on another simobject in the editor (say terrainBlock) and then click back on the sun object. Then you can go to your console and type lightScene("",forceAlways); and it works just fine. It updates the values somehow. No, Hitting apply doesn't work.
So there is a bug there that is hindering me. I think its in the lightScene(); function and how it obtains the values. But then again I'm not that good with torque to determine if that's actually the case.
Any help would be greatly appreciated.
Thank you.
About the author
I used to be obsessed with building my own open-ended RPG and a 3D Side Scroller RPG. But the job/house/girlfriend got in the way. I know, I know. Now I concentrate on doing architectural renderings (with the help of T3D of course) and VBA programming.
#2
You'll need to force the data up to the clients, try exposing Sun::inspectPostApply to script and calling it after changing the sun, but before relighting. This will simulate selecting the sun in the inspector.
09/13/2007 (11:05 pm)
Torque runs as a client/server app even in single player games. The code posted above is setting the server-side sun object, then relighting, which is client based, even though the changes to the sun are only on the server.You'll need to force the data up to the clients, try exposing Sun::inspectPostApply to script and calling it after changing the sun, but before relighting. This will simulate selecting the sun in the inspector.
#4
I wonder if you could help me out a little more?
Am I exposing the inspectPostApply correctly?
I replicated the ConsoleMethod I found in sky.cc and .h. and placed it in the sun.cc and .h because it is the exact same thing I'm looking to do.
I figured out that when i changed my sky fields, I had to use applySkyChanges...I should have thought it out a little more, would have saved me a few hours of digging. DUH!
But I had no such luck on calling the applySunChanges command: "unknown command applySunChanges"
in sun.cc I put:
ConsoleMethod( Sun, applySunChanges, void, 2, 2, "() - Apply any changes to Sun.")
{
object->applySunChanges();
}
Should the "Sun" be SimObject?
in sun.h I put:
void applySunChanges()
{
inspectPostApply();
}
then I followed inspectPostApply(); on both sky and sun,
They are different as expected, but the questions I have on that are, returning "void" and calling the number of arguments.
void Sun::inspectPostApply()
{
conformLight();
setMaskBits(UpdateMask);
}
If this all looks correct, then maybe there is something else I'm doing wrong.
Gabriel;
I'm running TGE 1.5.2 SDK,
I don't know about your version, but run the "sun handle".dump(); and see if apply(); is a method. I don't think it is.
Thank you guys.
09/14/2007 (3:59 pm)
Thank you for the quick reply Mr. Kabus,I wonder if you could help me out a little more?
Am I exposing the inspectPostApply correctly?
I replicated the ConsoleMethod I found in sky.cc and .h. and placed it in the sun.cc and .h because it is the exact same thing I'm looking to do.
I figured out that when i changed my sky fields, I had to use applySkyChanges...I should have thought it out a little more, would have saved me a few hours of digging. DUH!
But I had no such luck on calling the applySunChanges command: "unknown command applySunChanges"
in sun.cc I put:
ConsoleMethod( Sun, applySunChanges, void, 2, 2, "() - Apply any changes to Sun.")
{
object->applySunChanges();
}
Should the "Sun" be SimObject?
in sun.h I put:
void applySunChanges()
{
inspectPostApply();
}
then I followed inspectPostApply(); on both sky and sun,
They are different as expected, but the questions I have on that are, returning "void" and calling the number of arguments.
void Sun::inspectPostApply()
{
conformLight();
setMaskBits(UpdateMask);
}
If this all looks correct, then maybe there is something else I'm doing wrong.
Gabriel;
I'm running TGE 1.5.2 SDK,
I don't know about your version, but run the "sun handle".dump(); and see if apply(); is a method. I don't think it is.
Thank you guys.
#5
Your code seems to be correct, but you could stream line it to the following (I've have tested this)
Have you properly rebuilt the executable after adding your changes?
Gabriel
09/15/2007 (11:04 am)
Yeah sorry, .apply() is not available in TGE with the sun object. Your code seems to be correct, but you could stream line it to the following (I've have tested this)
ConsoleMethod( Sun, applySunChanges, void, 2, 2, "() - Apply any changes to Sun.")
{
object->inspectPostApply();
}Add the above to Sun.cc.Have you properly rebuilt the executable after adding your changes?
Gabriel
#6
I think that is my problem.
How do you rebuild the executable?
After I make the changes, I delete all the dso's using deleteDSO.bat, then just run the garagegames icon which I have linked to my folder through the main.cs.
09/15/2007 (1:34 pm)
Gabriel,I think that is my problem.
How do you rebuild the executable?
After I make the changes, I delete all the dso's using deleteDSO.bat, then just run the garagegames icon which I have linked to my folder through the main.cs.
#7
If you do not have a c++ compiler installed, the following is a TDN guide to setting up and compiling torque with VC++ 2005 Express Edition:
tdn.garagegames.com/wiki/Torque/vs2k5
Gabriel
09/15/2007 (6:42 pm)
The DSOs are the compiled scripts, what you need to do is recompile the engine c++ code.If you do not have a c++ compiler installed, the following is a TDN guide to setting up and compiling torque with VC++ 2005 Express Edition:
tdn.garagegames.com/wiki/Torque/vs2k5
Gabriel
#10
I was wondering.
Have you happen to figure out a more efficent way to use the relight?
the lightScene is really slow when you have a lot of diffs and kind of ruins the whole effect.
I see you can use draft and lower your relight radius using the light manager (F12 in the world editor).
But how do you set up your relight to use those settings in script?
That might help make it more efficent/quicker.
Or, is there a whole different way to go about the relighting of a scene?
09/19/2007 (10:17 am)
Gabriel,I was wondering.
Have you happen to figure out a more efficent way to use the relight?
the lightScene is really slow when you have a lot of diffs and kind of ruins the whole effect.
I see you can use draft and lower your relight radius using the light manager (F12 in the world editor).
But how do you set up your relight to use those settings in script?
That might help make it more efficent/quicker.
Or, is there a whole different way to go about the relighting of a scene?
#11
That function adds several console variables which control the quality and properties of the lighting. I believe these are the variables manipulated by the light editor. (The light editor script is not available un-compiled, so I can't confirm for sure).
However the lightScene process is really intended to be done offline, so I doubt tweaking these parameters will allow it to run fast enough for realtime.
Gabriel
09/19/2007 (10:58 am)
Have a look in sgLightManager.cc for: LightManager::sgInit()That function adds several console variables which control the quality and properties of the lighting. I believe these are the variables manipulated by the light editor. (The light editor script is not available un-compiled, so I can't confirm for sure).
However the lightScene process is really intended to be done offline, so I doubt tweaking these parameters will allow it to run fast enough for realtime.
Gabriel
#12
09/22/2007 (12:34 pm)
Good job on finding the solution. While this is helpful, please keep in mind that you should not be posting ANY of TGE's engine code in a public forum. This is generally not allowed, and also opens up the door to giving free help and code to those who have pirated the engine.
Torque Owner J
Act 7
I have found the lightScene function, (sgSceneLighting.cc and .h) but I don't understand it...
Can you create a function (or console function) that forces the values in ambient and color to update in the lightScene(); function.
Evidently when you call the lightScene(); function it is tied to the editor and doesn't work worth a darn/has some major bugs.
On that note...anyone else have an idea how to relight the scene without using the lightScene(); function?
I read on the Filtered Relight, how do you implement that?
This is like pulling teeth.
Such a nice day/night Cycle and time manager too....
ERRRRRR!