Wait to finish game engine rendering
-
Hello,
So I am trying to modify code from this repository. Which is actually capturing images and later plan to use the data for object recognition or some other research problems.
I am trying to capture the data for different lightning conditions, i.e. changing weathers and day time. I am using following code:
Game.Pause(true);
Script.Wait(500);
int d = 0; // delay variable
for (int hour = 0; hour < 24; hour++){
colors = new List<byte[]>();
World.CurrentDayTime = new TimeSpan(hour, 0, 0);
Script.Wait(d);
foreach (var wea in wantedWeather) { // wantedWeather: list of desired weathers
World.TransitionToWeather(wea, 0.0f);
Script.Wait(d);
colors.Add(VisionNative.GetColorBuffer()); // captures the screen
}
// here goes code to save colors as an image on disk.
}
Game.Pause(false);
Excuse me for bad formatting of code, I couldn't find anyway to have right formatting in the editor.
If I don't use loops and change the weather or time once, in the beginning bright objects get a bit exposed, but after some time it brings back all the details.
And when I try to use
d=0
, it does proper transitions to weather and time, but some times specially for day time bright objects (like sky) get over exposed such that there are no details to near by objects i.e. clouds.In my opinion, game engine needs some time to adapt the environment to get back to normal.
I tried to increase the delay i.e.
d=100
ord=1000
, in that case script just waits and there are no transitions to weather or time, and only one image of "environment" (maybeScripthook
is waiting) gets saved.So I was just wondering if I could somehow make my code wait such that game engine brings rendering to normal or lights not get over exposed. Does there any functionality exist?