mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-07 03:12:36 +01:00
Adjusted game clock for 24 minute day
This commit is contained in:
parent
4aad1665a6
commit
d3d2165947
@ -103,6 +103,16 @@ public:
|
||||
*/
|
||||
void destroyObject(GTAObject* object);
|
||||
|
||||
/**
|
||||
* Returns the current hour
|
||||
*/
|
||||
int getHour();
|
||||
|
||||
/**
|
||||
* Returns the current minute
|
||||
*/
|
||||
int getMinute();
|
||||
|
||||
/**
|
||||
* Game Clock
|
||||
*/
|
||||
|
@ -330,4 +330,16 @@ void GameWorld::destroyObject(GTAObject* object)
|
||||
}
|
||||
}
|
||||
delete object;
|
||||
}
|
||||
}
|
||||
|
||||
int GameWorld::getHour()
|
||||
{
|
||||
const float dayseconds = (24.f * 60.f);
|
||||
float daytime = fmod(gameTime, dayseconds);
|
||||
return daytime / 60.f;
|
||||
}
|
||||
|
||||
int GameWorld::getMinute()
|
||||
{
|
||||
return fmod(gameTime, 60.f);
|
||||
}
|
||||
|
@ -220,16 +220,17 @@ void GTARenderer::renderWorld()
|
||||
{
|
||||
glBindVertexArray( vao );
|
||||
|
||||
float gameTime = fmod(engine->gameTime, 24.f);
|
||||
float tod = fmod(engine->gameTime, 24.f * 60.f);
|
||||
|
||||
auto weather = engine->gameData.weatherLoader.getWeatherData(WeatherLoader::Sunny, gameTime);
|
||||
// Requires a float 0-24
|
||||
auto weather = engine->gameData.weatherLoader.getWeatherData(WeatherLoader::Sunny, tod / 60.f);
|
||||
|
||||
glm::vec3 skyTop = weather.skyTopColor;
|
||||
glm::vec3 skyBottom = weather.skyBottomColor;
|
||||
glm::vec3 ambient = weather.ambientColor;
|
||||
glm::vec3 dynamic = weather.directLightColor;
|
||||
|
||||
float theta = (gameTime - 12.f)/24.0 * 2 * 3.14159265;
|
||||
float theta = (tod/(60.f * 24.f) - 0.5f) * 2 * 3.14159265;
|
||||
glm::vec3 sunDirection{
|
||||
sin(theta),
|
||||
0.0,
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <getopt.h>
|
||||
#include <boost/concept_check.hpp>
|
||||
|
||||
@ -400,6 +401,9 @@ void init(std::string gtapath, bool loadWorld)
|
||||
|
||||
gta->load();
|
||||
|
||||
// Set time to noon.
|
||||
gta->gameTime = 12.f * 60.f;
|
||||
|
||||
// Loade all of the IDEs.
|
||||
for(std::map<std::string, std::string>::iterator it = gta->gameData.ideLocations.begin();
|
||||
it != gta->gameData.ideLocations.end();
|
||||
@ -550,7 +554,8 @@ void render()
|
||||
window.resetGLStates();
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "Time: " << fmod(floor(gta->gameTime), 24.f) << ":" << (floor(fmod(gta->gameTime, 1.f) * 60.f)) << std::endl;
|
||||
ss << std::setfill('0') << "Time: " << std::setw(2) << gta->getHour()
|
||||
<< ":" << std::setw(2) << gta->getMinute() << std::endl;
|
||||
ss << "Game Time: " << gta->gameTime << std::endl;
|
||||
ss << "Camera: " << plyPos.x << " " << plyPos.y << " " << plyPos.z << std::endl;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user