paysages : Made fileNew work again.
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@509 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
756ff0ec99
commit
ed268098a1
13 changed files with 63 additions and 21 deletions
1
TODO
1
TODO
|
@ -22,7 +22,6 @@ Technology Preview 2 :
|
||||||
=> Add texture shadowing.
|
=> Add texture shadowing.
|
||||||
- Clouds should keep distance to ground.
|
- Clouds should keep distance to ground.
|
||||||
- Fix rendering when inside a cloud layer, with other upper or lower layers.
|
- Fix rendering when inside a cloud layer, with other upper or lower layers.
|
||||||
- Make fileNew work again (call auto presets and randomize all noise offsets).
|
|
||||||
- Improve cloud rendering precision (and beware of precision discontinuity when rendering clouds in front of ground (shorter distance)).
|
- Improve cloud rendering precision (and beware of precision discontinuity when rendering clouds in front of ground (shorter distance)).
|
||||||
|
|
||||||
Technlogy Preview 3 :
|
Technlogy Preview 3 :
|
||||||
|
|
|
@ -139,7 +139,7 @@ void FormClouds::layerWriteCurrentTo(void* layer_definition)
|
||||||
|
|
||||||
void FormClouds::autoPresetSelected(int preset)
|
void FormClouds::autoPresetSelected(int preset)
|
||||||
{
|
{
|
||||||
cloudsAutoPreset(_layer, (CloudsPreset)preset);
|
cloudsLayerAutoPreset(_layer, (CloudsLayerPreset)preset);
|
||||||
BaseForm::autoPresetSelected(preset);
|
BaseForm::autoPresetSelected(preset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,11 +24,7 @@ void autoGenRealisticLandscape(int seed)
|
||||||
}
|
}
|
||||||
srand(seed);
|
srand(seed);
|
||||||
|
|
||||||
/* Cloud layer */
|
sceneryAutoPreset();
|
||||||
CloudsDefinition* clouds = CloudsDefinitionClass.create();
|
|
||||||
layer = layersAddLayer(clouds->layers, NULL);
|
|
||||||
scenerySetClouds(clouds);
|
|
||||||
CloudsDefinitionClass.destroy(clouds);
|
|
||||||
|
|
||||||
/* Water */
|
/* Water */
|
||||||
water = waterCreateDefinition();
|
water = waterCreateDefinition();
|
||||||
|
@ -42,6 +38,7 @@ void autoGenRealisticLandscape(int seed)
|
||||||
layersSetName(textures.layers, layer, "Ground");
|
layersSetName(textures.layers, layer, "Ground");
|
||||||
texture = layersGetLayer(textures.layers, layer);
|
texture = layersGetLayer(textures.layers, layer);
|
||||||
noiseClearLevels(texture->bump_noise);
|
noiseClearLevels(texture->bump_noise);
|
||||||
|
noiseRandomizeOffsets(texture->bump_noise);
|
||||||
noiseAddLevelsSimple(texture->bump_noise, 8, 1.0, -0.5, 0.5);
|
noiseAddLevelsSimple(texture->bump_noise, 8, 1.0, -0.5, 0.5);
|
||||||
texture->bump_height = 0.01;
|
texture->bump_height = 0.01;
|
||||||
texture->bump_scaling = 0.045;
|
texture->bump_scaling = 0.045;
|
||||||
|
@ -59,6 +56,7 @@ void autoGenRealisticLandscape(int seed)
|
||||||
zoneAddHeightRangeQuick(texture->zone, 1.0, -6.0, -5.0, 3.0, 15.0);
|
zoneAddHeightRangeQuick(texture->zone, 1.0, -6.0, -5.0, 3.0, 15.0);
|
||||||
zoneAddSlopeRangeQuick(texture->zone, 1.0, 0.0, 0.0, 0.05, 0.4);
|
zoneAddSlopeRangeQuick(texture->zone, 1.0, 0.0, 0.0, 0.05, 0.4);
|
||||||
noiseClearLevels(texture->bump_noise);
|
noiseClearLevels(texture->bump_noise);
|
||||||
|
noiseRandomizeOffsets(texture->bump_noise);
|
||||||
noiseAddLevelsSimple(texture->bump_noise, 5, 1.0, -0.2, 0.2);
|
noiseAddLevelsSimple(texture->bump_noise, 5, 1.0, -0.2, 0.2);
|
||||||
noiseAddLevelsSimple(texture->bump_noise, 2, 0.03, -0.04, 0.04);
|
noiseAddLevelsSimple(texture->bump_noise, 2, 0.03, -0.04, 0.04);
|
||||||
texture->bump_height = 0.002;
|
texture->bump_height = 0.002;
|
||||||
|
|
|
@ -128,7 +128,7 @@ CloudsLayerDefinition* cloudsLayerCreateDefinition()
|
||||||
result->_shape_noise = noiseCreateGenerator();
|
result->_shape_noise = noiseCreateGenerator();
|
||||||
result->_edge_noise = noiseCreateGenerator();
|
result->_edge_noise = noiseCreateGenerator();
|
||||||
|
|
||||||
cloudsAutoPreset(result, CLOUDS_PRESET_CIRRUS);
|
cloudsLayerAutoPreset(result, CLOUDS_LAYER_PRESET_CIRRUS);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,31 @@
|
||||||
#include "private.h"
|
#include "private.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Clouds presets.
|
* Clouds presets.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cloudsAutoPreset(CloudsLayerDefinition* definition, CloudsPreset preset)
|
void cloudsAutoPreset(CloudsDefinition* definition, CloudsPreset preset)
|
||||||
{
|
{
|
||||||
|
int layer;
|
||||||
|
|
||||||
|
layersClear(definition->layers);
|
||||||
|
|
||||||
|
if (preset == CLOUDS_PRESET_PARTLY_CLOUDY)
|
||||||
|
{
|
||||||
|
layer = layersAddLayer(definition->layers, NULL);
|
||||||
|
cloudsLayerAutoPreset(layersGetLayer(definition->layers, layer), CLOUDS_LAYER_PRESET_CIRRUS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cloudsLayerAutoPreset(CloudsLayerDefinition* definition, CloudsLayerPreset preset)
|
||||||
|
{
|
||||||
|
noiseRandomizeOffsets(definition->_coverage_noise);
|
||||||
|
noiseRandomizeOffsets(definition->_edge_noise);
|
||||||
|
noiseRandomizeOffsets(definition->_shape_noise);
|
||||||
|
|
||||||
definition->material.base.r = 0.7;
|
definition->material.base.r = 0.7;
|
||||||
definition->material.base.g = 0.7;
|
definition->material.base.g = 0.7;
|
||||||
definition->material.base.b = 0.7;
|
definition->material.base.b = 0.7;
|
||||||
|
@ -15,7 +33,7 @@ void cloudsAutoPreset(CloudsLayerDefinition* definition, CloudsPreset preset)
|
||||||
|
|
||||||
switch (preset)
|
switch (preset)
|
||||||
{
|
{
|
||||||
case CLOUDS_PRESET_CIRRUS:
|
case CLOUDS_LAYER_PRESET_CIRRUS:
|
||||||
definition->type = CLOUDS_TYPE_CIRRUS;
|
definition->type = CLOUDS_TYPE_CIRRUS;
|
||||||
definition->lower_altitude = 25.0;
|
definition->lower_altitude = 25.0;
|
||||||
definition->thickness = 2.0;
|
definition->thickness = 2.0;
|
||||||
|
@ -30,7 +48,7 @@ void cloudsAutoPreset(CloudsLayerDefinition* definition, CloudsPreset preset)
|
||||||
definition->edge_length = 0.8;
|
definition->edge_length = 0.8;
|
||||||
definition->base_coverage = 0.6;
|
definition->base_coverage = 0.6;
|
||||||
break;
|
break;
|
||||||
case CLOUDS_PRESET_CUMULUS:
|
case CLOUDS_LAYER_PRESET_CUMULUS:
|
||||||
definition->type = CLOUDS_TYPE_CUMULUS;
|
definition->type = CLOUDS_TYPE_CUMULUS;
|
||||||
definition->lower_altitude = 15.0;
|
definition->lower_altitude = 15.0;
|
||||||
definition->thickness = 15.0;
|
definition->thickness = 15.0;
|
||||||
|
@ -45,7 +63,7 @@ void cloudsAutoPreset(CloudsLayerDefinition* definition, CloudsPreset preset)
|
||||||
definition->edge_length = 0.0;
|
definition->edge_length = 0.0;
|
||||||
definition->base_coverage = 0.7;
|
definition->base_coverage = 0.7;
|
||||||
break;
|
break;
|
||||||
case CLOUDS_PRESET_STRATOCUMULUS:
|
case CLOUDS_LAYER_PRESET_STRATOCUMULUS:
|
||||||
definition->type = CLOUDS_TYPE_STRATOCUMULUS;
|
definition->type = CLOUDS_TYPE_STRATOCUMULUS;
|
||||||
definition->lower_altitude = 5.0;
|
definition->lower_altitude = 5.0;
|
||||||
definition->thickness = 6.0;
|
definition->thickness = 6.0;
|
||||||
|
@ -60,7 +78,7 @@ void cloudsAutoPreset(CloudsLayerDefinition* definition, CloudsPreset preset)
|
||||||
definition->edge_length = 0.3;
|
definition->edge_length = 0.3;
|
||||||
definition->base_coverage = 0.4;
|
definition->base_coverage = 0.4;
|
||||||
break;
|
break;
|
||||||
case CLOUDS_PRESET_STRATUS:
|
case CLOUDS_LAYER_PRESET_STRATUS:
|
||||||
definition->type = CLOUDS_TYPE_STRATUS;
|
definition->type = CLOUDS_TYPE_STRATUS;
|
||||||
definition->lower_altitude = 3.0;
|
definition->lower_altitude = 3.0;
|
||||||
definition->thickness = 4.0;
|
definition->thickness = 4.0;
|
||||||
|
|
|
@ -22,12 +22,17 @@ typedef enum
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
CLOUDS_PRESET_CIRRUS,
|
CLOUDS_PRESET_PARTLY_CLOUDY,
|
||||||
CLOUDS_PRESET_CUMULUS,
|
|
||||||
CLOUDS_PRESET_STRATOCUMULUS,
|
|
||||||
CLOUDS_PRESET_STRATUS
|
|
||||||
} CloudsPreset;
|
} CloudsPreset;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
CLOUDS_LAYER_PRESET_CIRRUS,
|
||||||
|
CLOUDS_LAYER_PRESET_CUMULUS,
|
||||||
|
CLOUDS_LAYER_PRESET_STRATOCUMULUS,
|
||||||
|
CLOUDS_LAYER_PRESET_STRATUS
|
||||||
|
} CloudsLayerPreset;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
CloudsType type;
|
CloudsType type;
|
||||||
|
@ -79,7 +84,8 @@ extern StandardRenderer CloudsRendererClass;
|
||||||
|
|
||||||
|
|
||||||
LayerType cloudsGetLayerType();
|
LayerType cloudsGetLayerType();
|
||||||
void cloudsAutoPreset(CloudsLayerDefinition* definition, CloudsPreset preset);
|
void cloudsAutoPreset(CloudsDefinition* definition, CloudsPreset preset);
|
||||||
|
void cloudsLayerAutoPreset(CloudsLayerDefinition* definition, CloudsLayerPreset preset);
|
||||||
|
|
||||||
Renderer* cloudsCreatePreviewCoverageRenderer();
|
Renderer* cloudsCreatePreviewCoverageRenderer();
|
||||||
Color cloudsGetPreviewCoverage(Renderer* renderer, double x, double y, double scaling, int perspective);
|
Color cloudsGetPreviewCoverage(Renderer* renderer, double x, double y, double scaling, int perspective);
|
||||||
|
|
|
@ -133,6 +133,14 @@ void layersSetName(Layers* layers, int layer, const char* name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void layersClear(Layers* layers)
|
||||||
|
{
|
||||||
|
while (layersCount(layers))
|
||||||
|
{
|
||||||
|
layersDeleteLayer(layers, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int layersCount(Layers* layers)
|
int layersCount(Layers* layers)
|
||||||
{
|
{
|
||||||
return layers->count;
|
return layers->count;
|
||||||
|
|
|
@ -40,6 +40,7 @@ void layersLoad(PackStream* stream, Layers* layers);
|
||||||
const char* layersGetName(Layers* layers, int layer);
|
const char* layersGetName(Layers* layers, int layer);
|
||||||
void layersSetName(Layers* layers, int layer, const char* name);
|
void layersSetName(Layers* layers, int layer, const char* name);
|
||||||
|
|
||||||
|
void layersClear(Layers* layers);
|
||||||
int layersCount(Layers* layers);
|
int layersCount(Layers* layers);
|
||||||
void* layersGetLayer(Layers* layers, int layer);
|
void* layersGetLayer(Layers* layers, int layer);
|
||||||
int layersAddLayer(Layers* layers, void* definition);
|
int layersAddLayer(Layers* layers, void* definition);
|
||||||
|
|
|
@ -221,9 +221,9 @@ void noiseRandomizeOffsets(NoiseGenerator* generator)
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < MAX_LEVEL_COUNT; i++)
|
for (i = 0; i < MAX_LEVEL_COUNT; i++)
|
||||||
{
|
{
|
||||||
result->levels[i].xoffset = toolsRandom();
|
generator->levels[i].xoffset = toolsRandom();
|
||||||
result->levels[i].yoffset = toolsRandom();
|
generator->levels[i].yoffset = toolsRandom();
|
||||||
result->levels[i].zoffset = toolsRandom();
|
generator->levels[i].zoffset = toolsRandom();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,13 @@ void sceneryQuit()
|
||||||
noiseQuit();
|
noiseQuit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sceneryAutoPreset()
|
||||||
|
{
|
||||||
|
terrainAutoPreset(_terrain, TERRAIN_PRESET_STANDARD);
|
||||||
|
atmosphereAutoPreset(_atmosphere, ATMOSPHERE_MODEL_BRUNETON);
|
||||||
|
cloudsAutoPreset(_clouds, CLOUDS_PRESET_PARTLY_CLOUDY);
|
||||||
|
}
|
||||||
|
|
||||||
void scenerySetCustomDataCallback(SceneryCustomDataCallback callback_save, SceneryCustomDataCallback callback_load, void* data)
|
void scenerySetCustomDataCallback(SceneryCustomDataCallback callback_save, SceneryCustomDataCallback callback_load, void* data)
|
||||||
{
|
{
|
||||||
_custom_save = callback_save;
|
_custom_save = callback_save;
|
||||||
|
|
|
@ -26,6 +26,8 @@ typedef void (*SceneryCustomDataCallback)(PackStream* stream, void* data);
|
||||||
void sceneryInit();
|
void sceneryInit();
|
||||||
void sceneryQuit();
|
void sceneryQuit();
|
||||||
|
|
||||||
|
void sceneryAutoPreset();
|
||||||
|
|
||||||
void scenerySetCustomDataCallback(SceneryCustomDataCallback callback_save, SceneryCustomDataCallback callback_load, void* data);
|
void scenerySetCustomDataCallback(SceneryCustomDataCallback callback_save, SceneryCustomDataCallback callback_load, void* data);
|
||||||
|
|
||||||
void scenerySave(PackStream* stream);
|
void scenerySave(PackStream* stream);
|
||||||
|
|
|
@ -12,6 +12,7 @@ void terrainAutoPreset(TerrainDefinition* definition, TerrainPreset preset)
|
||||||
switch (preset)
|
switch (preset)
|
||||||
{
|
{
|
||||||
case TERRAIN_PRESET_STANDARD:
|
case TERRAIN_PRESET_STANDARD:
|
||||||
|
noiseRandomizeOffsets(definition->_height_noise);
|
||||||
noiseClearLevels(definition->_height_noise);
|
noiseClearLevels(definition->_height_noise);
|
||||||
noiseAddLevelsSimple(definition->_height_noise, resolution, pow(2.0, resolution - 1), -12.5, 12.5);
|
noiseAddLevelsSimple(definition->_height_noise, resolution, pow(2.0, resolution - 1), -12.5, 12.5);
|
||||||
noiseSetFunctionParams(definition->_height_noise, NOISE_FUNCTION_SIMPLEX, 0.0, 0.0);
|
noiseSetFunctionParams(definition->_height_noise, NOISE_FUNCTION_SIMPLEX, 0.0, 0.0);
|
||||||
|
|
|
@ -69,6 +69,8 @@ void waterDeleteDefinition(WaterDefinition* definition)
|
||||||
|
|
||||||
void waterAutoPreset(WaterDefinition* definition, WaterPreset preset)
|
void waterAutoPreset(WaterDefinition* definition, WaterPreset preset)
|
||||||
{
|
{
|
||||||
|
noiseRandomizeOffsets(definition->_waves_noise);
|
||||||
|
|
||||||
if (preset == WATER_PRESET_LAKE)
|
if (preset == WATER_PRESET_LAKE)
|
||||||
{
|
{
|
||||||
definition->transparency = 0.5;
|
definition->transparency = 0.5;
|
||||||
|
|
Loading…
Reference in a new issue