2012-01-24 13:16:20 +00:00
|
|
|
#include "auto.h"
|
|
|
|
|
2011-12-10 13:25:22 +00:00
|
|
|
#include <math.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#include "shared/types.h"
|
|
|
|
#include "shared/constants.h"
|
|
|
|
#include "clouds.h"
|
2012-01-29 17:39:56 +00:00
|
|
|
#include "color.h"
|
|
|
|
#include "lighting.h"
|
2012-01-05 16:32:41 +00:00
|
|
|
#include "modifiers.h"
|
2012-01-29 17:39:56 +00:00
|
|
|
#include "render.h"
|
2012-01-03 15:40:50 +00:00
|
|
|
#include "terrain.h"
|
|
|
|
#include "textures.h"
|
2012-01-23 23:45:33 +00:00
|
|
|
#include "scenery.h"
|
2012-01-29 17:39:56 +00:00
|
|
|
#include "sky.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "water.h"
|
|
|
|
#include "zone.h"
|
2011-12-10 13:25:22 +00:00
|
|
|
|
|
|
|
void autoSetDaytime(int hour, int minute)
|
|
|
|
{
|
|
|
|
autoSetDaytimeFraction((double)hour / 24.0 + (double)minute / 1440.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void autoSetDaytimeFraction(double daytime)
|
|
|
|
{
|
2011-12-17 10:55:37 +00:00
|
|
|
SkyDefinition sky;
|
2012-01-22 18:39:42 +00:00
|
|
|
/*ColorGradation grad_sun;
|
|
|
|
Color sun;*/
|
2011-12-17 10:55:37 +00:00
|
|
|
|
2011-12-10 13:25:22 +00:00
|
|
|
daytime = fmod(daytime, 1.0);
|
|
|
|
if (daytime < 0.0)
|
|
|
|
{
|
|
|
|
daytime += 1.0;
|
|
|
|
}
|
|
|
|
|
2012-01-22 18:39:42 +00:00
|
|
|
/*lightingSetSunAngle(0.0, (daytime + 0.25) * M_PI * 2.0);
|
2011-12-10 13:25:22 +00:00
|
|
|
|
|
|
|
grad_sun = colorGradationCreate();
|
|
|
|
colorGradationAddRgba(&grad_sun, 0.2, 0.1, 0.1, 0.1, 1.0);
|
|
|
|
colorGradationAddRgba(&grad_sun, 0.25, 0.9, 0.5, 0.5, 1.0);
|
|
|
|
colorGradationAddRgba(&grad_sun, 0.3, 0.8, 0.8, 0.8, 1.0);
|
|
|
|
colorGradationAddRgba(&grad_sun, 0.5, 1.0, 1.0, 1.0, 1.0);
|
|
|
|
colorGradationAddRgba(&grad_sun, 0.7, 0.8, 0.8, 0.8, 1.0);
|
|
|
|
colorGradationAddRgba(&grad_sun, 0.75, 0.7, 0.6, 0.5, 1.0);
|
|
|
|
colorGradationAddRgba(&grad_sun, 0.8, 0.1, 0.1, 0.1, 1.0);
|
|
|
|
sun = colorGradationGet(&grad_sun, daytime);
|
2012-01-22 18:39:42 +00:00
|
|
|
lightingSetSunColor(sun);*/
|
2011-12-10 13:25:22 +00:00
|
|
|
|
2012-01-23 23:45:33 +00:00
|
|
|
sky = skyCreateDefinition();
|
|
|
|
sceneryGetSky(&sky);
|
2011-12-17 10:55:37 +00:00
|
|
|
sky.daytime = daytime;
|
2012-01-23 23:45:33 +00:00
|
|
|
scenerySetSky(&sky);
|
|
|
|
skyDeleteDefinition(&sky);
|
2011-12-10 13:25:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void autoGenRealisticLandscape(int seed)
|
|
|
|
{
|
2012-01-24 15:47:49 +00:00
|
|
|
AtmosphereDefinition atmosphere;
|
2012-01-03 15:40:50 +00:00
|
|
|
TerrainDefinition terrain;
|
2011-12-10 13:25:22 +00:00
|
|
|
WaterDefinition water;
|
2012-01-23 23:45:33 +00:00
|
|
|
CloudsDefinition clouds;
|
|
|
|
CloudsLayerDefinition* cloud;
|
2011-12-17 10:55:37 +00:00
|
|
|
SkyDefinition sky;
|
2012-01-23 23:45:33 +00:00
|
|
|
TexturesDefinition textures;
|
|
|
|
TextureLayerDefinition* texture;
|
2012-01-22 18:39:42 +00:00
|
|
|
LightingDefinition lighting;
|
2011-12-10 13:25:22 +00:00
|
|
|
HeightModifier* mod;
|
|
|
|
Zone* zone;
|
|
|
|
|
|
|
|
if (!seed)
|
|
|
|
{
|
|
|
|
seed = time(NULL);
|
|
|
|
}
|
|
|
|
srand(seed);
|
|
|
|
|
|
|
|
/* Cloud layer */
|
2012-01-23 23:45:33 +00:00
|
|
|
clouds = cloudsCreateDefinition();
|
|
|
|
cloud = cloudsGetLayer(&clouds, cloudsAddLayer(&clouds));
|
|
|
|
cloud->ymin = 10.0;
|
|
|
|
cloud->ycenter = 40.0;
|
|
|
|
cloud->ymax = 100.0;
|
2012-02-07 21:03:58 +00:00
|
|
|
cloud->material.base.r = 0.7;
|
|
|
|
cloud->material.base.g = 0.7;
|
|
|
|
cloud->material.base.b = 0.7;
|
|
|
|
cloud->material.reflection = 0.1;
|
|
|
|
cloud->material.shininess = 2.0;
|
|
|
|
cloud->transparencydepth = 20.0;
|
|
|
|
cloud->lighttraversal = 50.0;
|
|
|
|
cloud->minimumlight = 0.8;
|
2012-01-23 23:45:33 +00:00
|
|
|
cloud->scaling = 50.0;
|
|
|
|
cloud->coverage = 0.5;
|
|
|
|
noiseGenerateBaseNoise(cloud->noise, 262144);
|
2012-02-06 20:54:23 +00:00
|
|
|
noiseAddLevelSimple(cloud->noise, 1.0, 1.0);
|
|
|
|
noiseAddLevelSimple(cloud->noise, 1.0 / 2.0, 0.6);
|
|
|
|
noiseAddLevelSimple(cloud->noise, 1.0 / 4.0, 0.3);
|
|
|
|
noiseAddLevelSimple(cloud->noise, 1.0 / 10.0, 0.15);
|
|
|
|
noiseAddLevelSimple(cloud->noise, 1.0 / 20.0, 0.09);
|
|
|
|
noiseAddLevelSimple(cloud->noise, 1.0 / 40.0, 0.06);
|
|
|
|
noiseAddLevelSimple(cloud->noise, 1.0 / 60.0, 0.03);
|
|
|
|
noiseAddLevelSimple(cloud->noise, 1.0 / 80.0, 0.015);
|
|
|
|
noiseAddLevelSimple(cloud->noise, 1.0 / 100.0, 0.06);
|
|
|
|
noiseAddLevelSimple(cloud->noise, 1.0 / 150.0, 0.015);
|
|
|
|
noiseAddLevelSimple(cloud->noise, 1.0 / 200.0, 0.009);
|
|
|
|
noiseAddLevelSimple(cloud->noise, 1.0 / 400.0, 0.024);
|
|
|
|
noiseAddLevelSimple(cloud->noise, 1.0 / 800.0, 0.003);
|
|
|
|
noiseAddLevelSimple(cloud->noise, 1.0 / 1000.0, 0.0015);
|
2012-01-23 23:45:33 +00:00
|
|
|
scenerySetClouds(&clouds);
|
2012-01-26 18:20:19 +00:00
|
|
|
cloudsDeleteDefinition(&clouds);
|
2011-12-17 10:55:37 +00:00
|
|
|
|
2011-12-10 13:25:22 +00:00
|
|
|
/* Water */
|
2012-01-23 23:45:33 +00:00
|
|
|
water = waterCreateDefinition();
|
2011-12-10 13:25:22 +00:00
|
|
|
water.height = 0.0;
|
2011-12-19 20:59:39 +00:00
|
|
|
water.transparency = 0.5;
|
|
|
|
water.reflection = 0.3;
|
|
|
|
water.transparency_depth = 6.0;
|
2012-01-28 18:32:08 +00:00
|
|
|
water.material.base.r = 0.1;
|
|
|
|
water.material.base.g = 0.3;
|
|
|
|
water.material.base.b = 0.4;
|
|
|
|
water.material.base.a = 1.0;
|
|
|
|
water.material.reflection = 1.0;
|
|
|
|
water.material.shininess = 12.0;
|
2011-12-19 20:59:39 +00:00
|
|
|
water.depth_color.r = 0.0;
|
|
|
|
water.depth_color.g = 0.2;
|
|
|
|
water.depth_color.b = 0.3;
|
|
|
|
water.depth_color.a = 1.0;
|
2012-01-28 18:32:08 +00:00
|
|
|
water.lighting_depth = 3.0;
|
2012-01-17 20:54:14 +00:00
|
|
|
water.waves_noise_height = 0.015;
|
|
|
|
water.waves_noise_scale = 0.2;
|
|
|
|
noiseGenerateBaseNoise(water.waves_noise, 262144);
|
|
|
|
noiseAddLevelsSimple(water.waves_noise, 2, 1.0, 1.0);
|
|
|
|
noiseAddLevelsSimple(water.waves_noise, 3, 0.15, 0.1);
|
2012-01-23 23:45:33 +00:00
|
|
|
scenerySetWater(&water);
|
|
|
|
waterDeleteDefinition(&water);
|
2011-12-10 13:25:22 +00:00
|
|
|
|
2011-12-17 10:55:37 +00:00
|
|
|
/* Sky */
|
2012-01-23 23:45:33 +00:00
|
|
|
sky = skyCreateDefinition();
|
2011-12-18 21:59:33 +00:00
|
|
|
colorGradationAddRgba(&sky.sun_color, 0.3, 1.0, 0.91, 0.8, 1.0);
|
|
|
|
colorGradationAddRgba(&sky.sun_color, 0.5, 1.0, 0.95, 0.9, 1.0);
|
|
|
|
colorGradationAddRgba(&sky.sun_color, 0.7, 1.0, 0.91, 0.8, 1.0);
|
2011-12-17 10:55:37 +00:00
|
|
|
colorGradationAddRgba(&sky.zenith_color, 0.2, 0.03, 0.03, 0.05, 1.0);
|
|
|
|
colorGradationAddRgba(&sky.zenith_color, 0.25, 0.25, 0.33, 0.37, 1.0);
|
|
|
|
colorGradationAddRgba(&sky.zenith_color, 0.35, 0.52, 0.63, 0.8, 1.0);
|
|
|
|
colorGradationAddRgba(&sky.zenith_color, 0.65, 0.52, 0.63, 0.8, 1.0);
|
|
|
|
colorGradationAddRgba(&sky.zenith_color, 0.75, 0.25, 0.33, 0.37, 1.0);
|
|
|
|
colorGradationAddRgba(&sky.zenith_color, 0.8, 0.03, 0.03, 0.05, 1.0);
|
|
|
|
colorGradationAddRgba(&sky.haze_color, 0.2, 0.05, 0.05, 0.08, 1.0);
|
|
|
|
colorGradationAddRgba(&sky.haze_color, 0.25, 0.55, 0.42, 0.42, 1.0);
|
|
|
|
colorGradationAddRgba(&sky.haze_color, 0.3, 0.6, 0.6, 0.6, 1.0);
|
|
|
|
colorGradationAddRgba(&sky.haze_color, 0.4, 0.92, 0.93, 1.0, 1.0);
|
|
|
|
colorGradationAddRgba(&sky.haze_color, 0.6, 0.92, 0.93, 1.0, 1.0);
|
|
|
|
colorGradationAddRgba(&sky.haze_color, 0.7, 0.6, 0.6, 0.8, 1.0);
|
|
|
|
colorGradationAddRgba(&sky.haze_color, 0.75, 0.62, 0.50, 0.42, 1.0);
|
|
|
|
colorGradationAddRgba(&sky.haze_color, 0.8, 0.05, 0.05, 0.08, 1.0);
|
|
|
|
sky.daytime = 0.0;
|
|
|
|
sky.haze_height = 0.75;
|
|
|
|
sky.haze_smoothing = 0.3;
|
2011-12-18 21:59:33 +00:00
|
|
|
sky.sun_radius = 0.02;
|
2012-01-23 23:45:33 +00:00
|
|
|
scenerySetSky(&sky);
|
|
|
|
skyDeleteDefinition(&sky);
|
2011-12-17 10:55:37 +00:00
|
|
|
|
2012-01-22 18:39:42 +00:00
|
|
|
/* Lighting */
|
|
|
|
lighting = lightingCreateDefinition();
|
|
|
|
lighting.autosetfromsky = 1;
|
2012-01-23 23:45:33 +00:00
|
|
|
scenerySetLighting(&lighting);
|
|
|
|
lightingDeleteDefinition(&lighting);
|
2012-01-22 18:39:42 +00:00
|
|
|
|
|
|
|
/* Terrain */
|
2012-01-03 15:40:50 +00:00
|
|
|
terrain = terrainCreateDefinition();
|
|
|
|
noiseGenerateBaseNoise(terrain.height_noise, 1048576);
|
2012-01-23 23:45:33 +00:00
|
|
|
noiseAddLevelsSimple(terrain.height_noise, 10, 1.0, 1.0);
|
|
|
|
terrain.height_factor = 12.0 / noiseGetMaxValue(terrain.height_noise);
|
|
|
|
terrain.scaling = 10.0;
|
2012-01-05 11:32:14 +00:00
|
|
|
/* DEBUG */
|
|
|
|
mod = modifierCreate();
|
|
|
|
zone = modifierGetZone(mod);
|
|
|
|
zoneIncludeCircleArea(zone, 0.4, 0.0, 0.0, 8.0, 20.0);
|
|
|
|
modifierActionFixValue(mod, -2.0);
|
|
|
|
terrainAddModifier(&terrain, mod);
|
|
|
|
modifierDelete(mod);
|
|
|
|
mod = modifierCreate();
|
|
|
|
zone = modifierGetZone(mod);
|
|
|
|
zoneIncludeCircleArea(zone, 1.0, 0.0, 0.0, 0.3, 8.0);
|
|
|
|
modifierActionAddValue(mod, 8.0);
|
|
|
|
terrainAddModifier(&terrain, mod);
|
|
|
|
modifierDelete(mod);
|
|
|
|
mod = modifierCreate();
|
|
|
|
zone = modifierGetZone(mod);
|
|
|
|
zoneIncludeCircleArea(zone, 0.8, 0.0, 0.0, 0.3, 4.0);
|
|
|
|
modifierActionFixValue(mod, -8.0);
|
|
|
|
terrainAddModifier(&terrain, mod);
|
|
|
|
/* DEBUG */
|
2012-01-23 23:45:33 +00:00
|
|
|
scenerySetTerrain(&terrain);
|
|
|
|
terrainDeleteDefinition(&terrain);
|
2012-01-03 17:43:01 +00:00
|
|
|
|
2012-01-22 18:39:42 +00:00
|
|
|
/* Textures */
|
2012-01-23 23:45:33 +00:00
|
|
|
textures = texturesCreateDefinition();
|
|
|
|
texture = texturesGetLayer(&textures, texturesAddLayer(&textures));
|
|
|
|
noiseGenerateBaseNoise(texture->bump_noise, 102400);
|
|
|
|
noiseAddLevelsSimple(texture->bump_noise, 6, 0.01, 0.01);
|
|
|
|
texture->color.r = 0.6;
|
|
|
|
texture->color.g = 0.55;
|
|
|
|
texture->color.b = 0.57;
|
|
|
|
texture = texturesGetLayer(&textures, texturesAddLayer(&textures));
|
|
|
|
zoneAddHeightRange(texture->zone, 1.0, -1.0, 0.0, 3.0, 15.0);
|
2012-01-26 22:30:20 +00:00
|
|
|
zoneAddSteepnessRange(texture->zone, 1.0, 0.0, 0.0, 0.2, 0.3);
|
2012-01-23 23:45:33 +00:00
|
|
|
noiseGenerateBaseNoise(texture->bump_noise, 102400);
|
|
|
|
noiseAddLevelsSimple(texture->bump_noise, 6, 0.02, 0.008);
|
|
|
|
texture->color.r = 0.2;
|
|
|
|
texture->color.g = 0.24;
|
|
|
|
texture->color.b = 0.05;
|
|
|
|
/*texture = texturesGetLayer(&textures, texturesAddLayer(&textures));
|
|
|
|
zoneAddHeightRange(texture->zone, 1.0, 3.0, 4.0, 100.0, 100.0);
|
|
|
|
noiseGenerateBaseNoise(texture->bump_noise, 102400);
|
|
|
|
noiseAddLevelsSimple(texture->bump_noise, 6, 0.04, 0.003);
|
|
|
|
texture->color.r = 1.0;
|
|
|
|
texture->color.g = 1.0;
|
|
|
|
texture->color.b = 1.0;
|
2012-01-03 17:43:01 +00:00
|
|
|
texturesSetDefinition(layer, texture);
|
|
|
|
texturesDeleteDefinition(texture);*/
|
2012-01-23 23:45:33 +00:00
|
|
|
scenerySetTextures(&textures);
|
|
|
|
texturesDeleteDefinition(&textures);
|
2011-12-17 10:55:37 +00:00
|
|
|
|
2012-01-24 15:47:49 +00:00
|
|
|
/* Atmosphere */
|
|
|
|
atmosphere = atmosphereCreateDefinition();
|
|
|
|
atmosphere.distance_near = 20.0;
|
|
|
|
atmosphere.distance_far = 100.0;
|
|
|
|
atmosphere.full_mask = 0.6;
|
|
|
|
atmosphere.auto_lock_on_haze = 1;
|
|
|
|
scenerySetAtmosphere(&atmosphere);
|
|
|
|
atmosphereDeleteDefinition(&atmosphere);
|
2011-12-10 13:25:22 +00:00
|
|
|
}
|