dwmitch
02-07-2011 23:44:45
Since there are options to set the observer's latitude and longitude and the setGregorianDateTime function includes day, month, and year I assumed there was a method for calculating the sun's position based on observer coordinates and the time of year. However, it seems to be off by about 4 1/2 hours.
I'm experimenting with a real-time system (whatever time you start the game in the real world is the time in the game world, however long you go in real life between shutting down and loading the save is how long you've been "camping" in the game world, etc.) and I'm doing that through the following method:
In terms of time scale it works pretty well. I started it at 7:00 AM, went out to work in the yard for about 9 hours, came back, and the sun in the game world was right where I expected it to be.
However, to initialize it I had to add 4 to st.wHour and 30 to st.wMinute. I thought it might be an error converting to Julian time so I found a converter on the internet and set the Julian date using the value I got from the converter. The time was still off. On July 2 at 7:00 AM in my location there's already a fair amount of light but in the game world it was as dark as it was in the real world at 2:30 AM.
It wouldn't be an issue if I had the game set in Missouri, USA, but eventually I'd like to add an option for players to select a metropolitan area close to them from a list and calculate the sun's position based on that.
Are the positional and time calculations only approximations? And while I've already found out how to make 7:00 AM in my location sync up to 7:00 AM in-game, what would be required to get 7:00 AM in Moscow, Russia to sync up with 7:00 AM in the game world if the player chooses Moscow as their closest city?
I'm experimenting with a real-time system (whatever time you start the game in the real world is the time in the game world, however long you go in real life between shutting down and loading the save is how long you've been "camping" in the game world, etc.) and I'm doing that through the following method:
...
SYSTEMTIME st;
...
while(!win->isClosed())
{
...
GetLocalTime(&st);
sky->getUniversalClock()->setGregorianDateTime(st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute,st.wSecond);
...
}
In terms of time scale it works pretty well. I started it at 7:00 AM, went out to work in the yard for about 9 hours, came back, and the sun in the game world was right where I expected it to be.
However, to initialize it I had to add 4 to st.wHour and 30 to st.wMinute. I thought it might be an error converting to Julian time so I found a converter on the internet and set the Julian date using the value I got from the converter. The time was still off. On July 2 at 7:00 AM in my location there's already a fair amount of light but in the game world it was as dark as it was in the real world at 2:30 AM.
It wouldn't be an issue if I had the game set in Missouri, USA, but eventually I'd like to add an option for players to select a metropolitan area close to them from a list and calculate the sun's position based on that.
Are the positional and time calculations only approximations? And while I've already found out how to make 7:00 AM in my location sync up to 7:00 AM in-game, what would be required to get 7:00 AM in Moscow, Russia to sync up with 7:00 AM in the game world if the player chooses Moscow as their closest city?