Scripted changes to TimeOfDay object not applying
by PixelSoft Films · in Torque 3D Professional · 06/16/2009 (5:57 pm) · 6 replies
I've been writing some scripts to dynamically control the TimeOfDay object and while all the data fields seem to be changing correctly, the sun in the ScatterSky isn't affected. I do notice that if I open the TimeOfDay object in the World Editor click on a field all the changes I made in script are immediately applied to the sun.
The script isn't complicated just
theTimeOfDay.fieldname = value
I've also tried changing the fields with setFieldValue to no avail
Am I missing a step, or is this a bug?
The script isn't complicated just
theTimeOfDay.fieldname = value
I've also tried changing the fields with setFieldValue to no avail
Am I missing a step, or is this a bug?
#2
06/17/2009 (9:05 am)
Great, that worked like a charm. Thanks.
#3
06/17/2009 (9:12 am)
I agree Dave, it'd be nice to see those in the engine. I haven't come across this, but it had crossed my mind. In the GDC demo the time was being changed (though I don't recall exactly, I think it was via the editor), so this type of control seems like a natural step.
#4
Time of Day is a better method. That's a bit of great functionality there David, thanks!
06/17/2009 (9:50 am)
@Brett: The GDC demo just simply animated the sun in a predetermined path from a keybind, which in turn caused the shadows to move across the scene for demonstration purposes. In fact it looks like it is still there:moveMap.bindCmd(keyboard, "alt s", "theSun.animate(10, 230, 590, 60, 60);", ""); moveMap.bindCmd(gamepad, btn_y, "theSun.animate(10, 230, 590, 60, 60);", "");
Time of Day is a better method. That's a bit of great functionality there David, thanks!
#5
06/17/2009 (11:00 am)
Thanks for the clarification Michael.
#6
06/26/2009 (2:39 pm)
Logging this as THREED-519
Associate David Wyand
Gnometech Inc.
The issue is that your changes are not being sent across the network (even in single player). When the editor makes a change to an object, its inspectPostApply() method is called, which for TimeOfDay looks like this:
void TimeOfDay::inspectPostApply() { _updatePosition(); setMaskBits( OrbitMask ); }The setMaskBits() call triggers the update over the network. So what you'll need to do is expand the TimeOfDay class to provide some accessor functions that also make this call. Here is how I would do it:
timeOfDay.h:
F32 getTimeOfDay() { return mTimeOfDay; } void setTimeOfDay(F32 time) { mTimeOfDay=time; setMaskBits( OrbitMask ); } bool getPlay() { return mPlay; } void setPlay(bool play) { mPlay=play; setMaskBits( OrbitMask ); }timeOfDay.cpp:
ConsoleMethod( TimeOfDay, setTimeOfDay, void, 3, 3, "setTimeOfDay( time )" ) { object->setTimeOfDay( dAtof( argv[2] ) ); } ConsoleMethod( TimeOfDay, setPlay, void, 3, 3, "setPlay( bool )" ) { object->setPlay( dAtob( argv[2] ) ); }As these are likely common functions a game would require, we should probably add them to the engine itself.
- Dave