TGEDayNight revisited
by John Vanderbeck · in Torque Game Engine · 03/21/2004 (5:10 pm) · 22 replies
We needed some form of a day/night cycle for Mayhem, so I dug around the forums and came up with an old implementation of a day/night cycle in Torque. While the implementation was kindly provided as a patch, it was older and so did not apply correctly to Torque 1.2.1 that we are using. So I decided to grab a fresh HEAD and update this wonderful implementation so that others could take advantage of it easier. In addition to just updating it to make it patch right, I also implemented a couple additional changes that the author had done after, as well as some changes of our own in order to provide more flexability.
TGEDayNight
The original implementation can be found here. It appeared to be about a year or so old (The notice at the bottom indicated a revision of Feb 2003).
What did Novus Delta change?
The original implementation had everything hardcoded. Our design calls for the level designer having the ability to specify the starting time of the level. Time then progresses forward from that indicated time. I also figured, if i'm goign to expose this, I might as well expose the ability to set the time scale factor in the level as well. So I did. This modified version allows you to set the initial starting time of the level, as well as the time scale factor. You do this by editing the properites of the SKY object in the world editor. There is a new group for these options.
Where do I get it?
You can download the files from here.
How do I apply this?
The implementation is provided as a .patch file. First read this if you don't know how to apply patches.
1) Download a fresh HEAD of Torque. I can only say for certain that this will work against a head checkout from today, 3/21/04.
2) Apply the .patch inlcuded in the above zip file.
3) copy the directory "ARPG" included in the zip file to your Torque/Engine directory.
4) add the files in this new directory to your torque project.
5) compile.
How do I set the Day Night settings in my level?
Open up your level in the World Editor and go to the Inspector mode. Left click on the SKY object, and expand the group named "DayNight". In there you will see 3 fields. ScaleFactor sets how fast time moves in your world. A value of 1.0 is about 2.5 minutes = 1 game hour. Higher values mean faster time. StartingHour is the hour your map begins at, in military time. StartingMinute is the minute your map begins at. Just set these as you want them, press APPLY, and save your map. You can see your changes immediately after hitting APPLY, so you can easily tweak them as needed without having to restart.
If you have any questions let me know. It is possible I missed something when putting all this together, and if so I apologize.
TGEDayNight
The original implementation can be found here. It appeared to be about a year or so old (The notice at the bottom indicated a revision of Feb 2003).
What did Novus Delta change?
The original implementation had everything hardcoded. Our design calls for the level designer having the ability to specify the starting time of the level. Time then progresses forward from that indicated time. I also figured, if i'm goign to expose this, I might as well expose the ability to set the time scale factor in the level as well. So I did. This modified version allows you to set the initial starting time of the level, as well as the time scale factor. You do this by editing the properites of the SKY object in the world editor. There is a new group for these options.
Where do I get it?
You can download the files from here.
How do I apply this?
The implementation is provided as a .patch file. First read this if you don't know how to apply patches.
1) Download a fresh HEAD of Torque. I can only say for certain that this will work against a head checkout from today, 3/21/04.
2) Apply the .patch inlcuded in the above zip file.
3) copy the directory "ARPG" included in the zip file to your Torque/Engine directory.
4) add the files in this new directory to your torque project.
5) compile.
How do I set the Day Night settings in my level?
Open up your level in the World Editor and go to the Inspector mode. Left click on the SKY object, and expand the group named "DayNight". In there you will see 3 fields. ScaleFactor sets how fast time moves in your world. A value of 1.0 is about 2.5 minutes = 1 game hour. Higher values mean faster time. StartingHour is the hour your map begins at, in military time. StartingMinute is the minute your map begins at. Just set these as you want them, press APPLY, and save your map. You can see your changes immediately after hitting APPLY, so you can easily tweak them as needed without having to restart.
If you have any questions let me know. It is possible I missed something when putting all this together, and if so I apologize.
#2
I did notice the sun never moves though. Should it?
Thanks!
03/21/2004 (5:58 pm)
Sweet! I was able to apply the patch and see it change.I did notice the sun never moves though. Should it?
Thanks!
#3
03/21/2004 (6:07 pm)
Set a high scale, like 30 and you should see it move. It does for me in the Stronghold mission.
#4
03/21/2004 (6:11 pm)
Well I can see the sun now but it goes one way, turns around and goes back the other. Odd.
#5
03/21/2004 (6:13 pm)
Yeah it does, and I don't know what the deal is with that. Since I didint' write the original code, for the moment i'm assuming thats what its supposed to do. The implementation is there, and the main thing is the lighting. At some point i'm sure we will revist this and make the sun move the correct way. The movement of the sun isn't a huge deal though right now. That seems to be a minor issue. Its probably just some wierdness with fxSunLight.
#6
This was a cleaned up version of the Day/Night Code. You might want to look at it instead of the origional source.
03/21/2004 (6:16 pm)
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4050This was a cleaned up version of the Day/Night Code. You might want to look at it instead of the origional source.
#7
After all that work manually applying all this :(
I can't deal with doing this all over again tonight. I'm way too tired. I'll do it in the morning.
03/21/2004 (6:24 pm)
GAH!After all that work manually applying all this :(
I can't deal with doing this all over again tonight. I'm way too tired. I'll do it in the morning.
#8
/Stefan
03/22/2004 (8:07 am)
John Vanderbeck: Mate, don't work too much or you'll burn yourself out before you know it./Stefan
#9
Not good if you cant see a lot cos it dark, but smoeone else near you has full sun.
03/22/2004 (9:07 am)
Does this sync with server/client so that some clients are not at night, and soem at day etc..Not good if you cant see a lot cos it dark, but smoeone else near you has full sun.
#10
03/22/2004 (10:01 am)
Everyone will be in the same time of day. It stays in synch.
#11
Would someone be able to provide instructions on how to apply the patch for this that are something better than the ones from GG? They refer to it being tricky the first time, but then proceed to layout the steps assuming the person already knows where/how to do everything - and that is not a status I'd apply to myself at this point :-).
For example:
It says that WinCVS comes with the ability to patch the file. I have WinCVS installed - however, I don't see any such executable, or any instructions on how to use it in the GG docs, or in the WinCVS docs.
Where is the HEAD file stored and how am I supposed to modify it?
What are the command-line options, if any, that I'm supposed to use in order to properly patch the file?
...and so on. This is my first time trying to patch something (obviously :-), and unfortunately, none of the documentation I've found really explains it very well.
Thanks in advance for any help! Much appreciated.
Mike
04/03/2004 (9:01 am)
Hmm..Would someone be able to provide instructions on how to apply the patch for this that are something better than the ones from GG? They refer to it being tricky the first time, but then proceed to layout the steps assuming the person already knows where/how to do everything - and that is not a status I'd apply to myself at this point :-).
For example:
It says that WinCVS comes with the ability to patch the file. I have WinCVS installed - however, I don't see any such executable, or any instructions on how to use it in the GG docs, or in the WinCVS docs.
Where is the HEAD file stored and how am I supposed to modify it?
What are the command-line options, if any, that I'm supposed to use in order to properly patch the file?
...and so on. This is my first time trying to patch something (obviously :-), and unfortunately, none of the documentation I've found really explains it very well.
Thanks in advance for any help! Much appreciated.
Mike
#12
To apply patches read this It talks about how to create a patch AND Test the patch works. This "TEST" is how you perform a patch. From the page linked above:
As the page linked above states, you can get the "patch" tool at click here
Good luck,
04/04/2004 (7:07 am)
The HEAD is the "TIP" or the top revision without a TAG Specified. To get the "head" perform a check out with clearing all "stickies" with out a TAG specified.To apply patches read this It talks about how to create a patch AND Test the patch works. This "TEST" is how you perform a patch. From the page linked above:
Quote:
Testing the Patch
Testing the patch is the most important part of the patch process. To test the patch you'll need a copy of the SDK source at the current HEAD. If you saved a copy off before you started working on the patch, you can make a test copy of the saved SDK and update it to the HEAD revision.
Apply the patch from the command line: (assuming your test copy of the source is in the "c:\test"):
cd c:\test
patch -p0 < ..\patchname.patch
If patch complains about anything, or fails to apply part of the patch, you should fix the problems before submitting the patch. If any new files are include as part of the patch, make sure to copy them over at this point.
Next you should build and test the patched SDK. If everything looks good, you're done. Its time to send it in to GarageGames!
As the page linked above states, you can get the "patch" tool at click here
Good luck,
#13
Did you ever get the updates from the other thread in your patch? I was hoping to use the goodness you have rather than add it all myself.
Thanks,
04/04/2004 (7:10 am)
John,Did you ever get the updates from the other thread in your patch? I was hoping to use the goodness you have rather than add it all myself.
Thanks,
#14
Yeah, I actually got the patch part fine. Now I just need to figure out how to get the files "checked in" to the makefile.
I have one of two IDE's downloaded that I can use: DevC++ and Eclipse.. I just don't know which to use or how to configure either one for Torque... (again, the whole "total newbie" thing). Of course, if there's a pretty simple way to just edit the Makefile myself manually.. I'd be fine with that.
It's the two files placed under C:\Torque\engine\ARPG\environment; atgeDayNight.cc and atgeDayNight.h, right?
Thanks..
Mike
04/04/2004 (7:55 am)
Heya..Yeah, I actually got the patch part fine. Now I just need to figure out how to get the files "checked in" to the makefile.
I have one of two IDE's downloaded that I can use: DevC++ and Eclipse.. I just don't know which to use or how to configure either one for Torque... (again, the whole "total newbie" thing). Of course, if there's a pretty simple way to just edit the Makefile myself manually.. I'd be fine with that.
It's the two files placed under C:\Torque\engine\ARPG\environment; atgeDayNight.cc and atgeDayNight.h, right?
Thanks..
Mike
#15
Sorry,
04/04/2004 (9:31 am)
Yes that would be correct. I use Visual Studio 6.0 so I can't help with DevC++.Sorry,
#16
Actually, I now have Eclipse set up.. So I need to figure it out for that.
I'll see what I can work out. Does anyone have any experience with this?
Edit: Well, I'm at a complete loss :(.
After several attempts, I cannot get this patch to "take". I can't figure out how to add the two files you unzip into the engine\ARPG\environment folder, so they are correctly added and compiled; all I end up with are errors.
I tried it with Eclipse, and there just doesn't seem to be any way to do it that I can find.
It's kind of a bummer, because I'm literally no more than 1 step away from getting this to work, and it's the one step I can't figure out.
Oh well...
Mike
04/04/2004 (9:56 am)
Ahh.. Okay.. Hmm..Actually, I now have Eclipse set up.. So I need to figure it out for that.
I'll see what I can work out. Does anyone have any experience with this?
Edit: Well, I'm at a complete loss :(.
After several attempts, I cannot get this patch to "take". I can't figure out how to add the two files you unzip into the engine\ARPG\environment folder, so they are correctly added and compiled; all I end up with are errors.
I tried it with Eclipse, and there just doesn't seem to be any way to do it that I can find.
It's kind of a bummer, because I'm literally no more than 1 step away from getting this to work, and it's the one step I can't figure out.
Oh well...
Mike
#17
04/05/2004 (8:37 am)
My apologies for my being missing the last few days. I tried to install Linux as a multi-boot on my system the other day and the end result was a completely unsuable machine. I just finished reinstallign Windows so at least I can get online now, but I still have to reinstall all my apps. I'll get back to this soon as I can.
#18
Top stuff so far!
04/10/2004 (1:02 am)
Did you manage to get the sun sorted out (the sunflareythingy)?Top stuff so far!
#19
Yeah!
I like it! I noticed that the sun sorta hovers at the horizon for what would be the period (I'm assuming) where it would be below the horizon and going around the other side of the planet... then it starts going back the other direction. I'm sure that's something that'll be modified, or perhaps even can be modified in code (though I wouldn't know how).
I was also thinking it would be awesome to have the ability to have a moon, or more, arc over head similarly to the sun in the evening periods.
All in all, yeah.. I think it's really great. Would definitely add alot of atmosphere to a game. Especially if you could tie that in with a time-of-day system that would trigger certain events at the appropriate times... crickets chirping at night, certain nocturnal creatures that only come out after sunset, others that are only around during the day, etc. Other things like a change in the ambient "noise" when you're in a village.. for example, during the day you might hear some distant "background chatter" as folks are going about their business.. after a certain time, the streets fall quiet. At least, that's all part of what I would utilize a day-to-night system for.
Great stuff!
04/10/2004 (7:39 am)
Hey hey...Yeah!
I like it! I noticed that the sun sorta hovers at the horizon for what would be the period (I'm assuming) where it would be below the horizon and going around the other side of the planet... then it starts going back the other direction. I'm sure that's something that'll be modified, or perhaps even can be modified in code (though I wouldn't know how).
I was also thinking it would be awesome to have the ability to have a moon, or more, arc over head similarly to the sun in the evening periods.
All in all, yeah.. I think it's really great. Would definitely add alot of atmosphere to a game. Especially if you could tie that in with a time-of-day system that would trigger certain events at the appropriate times... crickets chirping at night, certain nocturnal creatures that only come out after sunset, others that are only around during the day, etc. Other things like a change in the ambient "noise" when you're in a village.. for example, during the day you might hear some distant "background chatter" as folks are going about their business.. after a certain time, the streets fall quiet. At least, that's all part of what I would utilize a day-to-night system for.
Great stuff!
Torque Owner Willbkool
Gamebox Creations
I've been trying to get the old resource working in 1.2.x but no luck so far. I'm going to try this right away.