paysages: Small fixes.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@211 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-01-03 17:43:01 +00:00 committed by ThunderK
parent 201bd75625
commit 867ba2513f
3 changed files with 43 additions and 44 deletions

View file

@ -14,10 +14,7 @@ static Color _cbPreviewRenderPixel(SmallPreview* preview, double x, double y, do
result.r = result.g = result.b = terrainGetHeightNormalized(x, y);
result.a = 1.0;
/* TEMP */
//result = terrainGetColor(x, y, 0.01);
return result;
}
@ -25,14 +22,14 @@ static void _cbEditNoiseDone(NoiseGenerator* generator)
{
noiseCopy(generator, _definition.height_noise);
terrainSetDefinition(_definition);
/* TODO Redraw only affected by terrain */
guiPreviewRedrawAll();
}
static void _cbEditNoise(GtkWidget* widget, gpointer data)
{
guiNoiseEdit(texturesGetDefinition(0).bump_noise, _cbEditNoiseDone);
guiNoiseEdit(_definition.height_noise, _cbEditNoiseDone);
}
void guiTerrainInit()

View file

@ -21,6 +21,7 @@ static int _is_rendering = 0;
void autoInit()
{
_cpu_count = (int)sysconf(_SC_NPROCESSORS_ONLN);
_cpu_count = 1;
renderSetBackgroundColor(&COLOR_BLACK);
terrainInit();
@ -222,42 +223,43 @@ void autoGenRealisticLandscape(int seed)
terrain = terrainCreateDefinition();
noiseGenerateBaseNoise(terrain.height_noise, 1048576);
noiseAddLevelsSimple(terrain.height_noise, 8, 10.0, 1.0);
noiseAddLevelsSimple(terrain.height_noise, 10, 10.0, 1.0);
noiseNormalizeHeight(terrain.height_noise, -12.0, 12.0, 0);
terrainSetDefinition(terrain);
terrainDeleteDefinition(terrain);
layer = texturesAddLayer();
texture = texturesCreateDefinition();
noiseGenerateBaseNoise(texture.bump_noise, 102400);
noiseAddLevelsSimple(texture.bump_noise, 6, 0.01, 0.01);
texture.color = COLOR_WHITE;
texture.color.r = 0.6;
texture.color.g = 0.55;
texture.color.b = 0.57;
texturesSetDefinition(layer, texture);
texturesDeleteDefinition(texture);
/*tex = textureCreateFromFile("./data/textures/rock3.jpg");
tex->scaling_x = 0.003;
tex->scaling_y = 0.003;
tex->scaling_z = 0.003;
zone = zoneCreate(1.0);
terrainAddTexture(tex, 0.05, zone, 1.0);
tex = textureCreateFromFile("./data/textures/grass1.jpg");
tex->scaling_x = 0.0004;
tex->scaling_y = 0.0004;
tex->scaling_z = 0.0004;
zone = zoneCreate(0.0);
zoneAddHeightRange(zone, 1.0, -1.0, 0.0, 3.0, 15.0);
zoneAddSteepnessRange(zone, 1.0, 0.0, 0.0, 0.3, 0.4);
terrainAddTexture(tex, 0.15, zone, 0.05);*/
layer = texturesAddLayer();
texture = texturesCreateDefinition();
zoneAddHeightRange(texture.zone, 1.0, -1.0, 0.0, 3.0, 15.0);
zoneAddSteepnessRange(texture.zone, 1.0, 0.0, 0.0, 0.3, 0.4);
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;
texturesSetDefinition(layer, texture);
texturesDeleteDefinition(texture);
/*tex = textureCreateFromFile("./data/textures/snow1.jpg");
tex->scaling_x = 0.001;
tex->scaling_y = 0.001;
tex->scaling_z = 0.001;
zone = zoneCreate(0.0);
zoneAddHeightRange(zone, 1.0, 3.0, 4.0, 100.0, 100.0);
terrainAddTexture(tex, 0.5, zone, 0.1);*/
/*layer = texturesAddLayer();
texture = texturesCreateDefinition();
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;
texturesSetDefinition(layer, texture);
texturesDeleteDefinition(texture);*/
/* DEBUG */
/*mod = modifierCreate();

View file

@ -48,7 +48,7 @@ Zone* zoneCreate()
result->steepness_ranges_count = 0;
result->circles_included_count = 0;
result->circles_excluded_count = 0;
return result;
}
@ -60,7 +60,7 @@ void zoneDelete(Zone* zone)
void zoneSave(Zone* zone, FILE* f)
{
int i;
toolsSaveInt(f, zone->height_ranges_count);
for (i = 0; i < zone->height_ranges_count; i++)
{
@ -70,7 +70,7 @@ void zoneSave(Zone* zone, FILE* f)
toolsSaveDouble(f, zone->height_ranges[i].softmax);
toolsSaveDouble(f, zone->height_ranges[i].hardmax);
}
toolsSaveInt(f, zone->steepness_ranges_count);
for (i = 0; i < zone->steepness_ranges_count; i++)
{
@ -80,7 +80,7 @@ void zoneSave(Zone* zone, FILE* f)
toolsSaveDouble(f, zone->steepness_ranges[i].softmax);
toolsSaveDouble(f, zone->steepness_ranges[i].hardmax);
}
toolsSaveInt(f, zone->circles_included_count);
for (i = 0; i < zone->circles_included_count; i++)
{
@ -90,7 +90,7 @@ void zoneSave(Zone* zone, FILE* f)
toolsSaveDouble(f, zone->circles_included[i].softradius);
toolsSaveDouble(f, zone->circles_included[i].hardradius);
}
toolsSaveInt(f, zone->circles_excluded_count);
for (i = 0; i < zone->circles_excluded_count; i++)
{
@ -105,7 +105,7 @@ void zoneSave(Zone* zone, FILE* f)
void zoneLoad(Zone* zone, FILE* f)
{
int i;
zone->height_ranges_count = toolsLoadInt(f);
for (i = 0; i < zone->height_ranges_count; i++)
{
@ -115,7 +115,7 @@ void zoneLoad(Zone* zone, FILE* f)
zone->height_ranges[i].softmax = toolsLoadDouble(f);
zone->height_ranges[i].hardmax = toolsLoadDouble(f);
}
zone->steepness_ranges_count = toolsLoadInt(f);
for (i = 0; i < zone->steepness_ranges_count; i++)
{
@ -125,7 +125,7 @@ void zoneLoad(Zone* zone, FILE* f)
zone->steepness_ranges[i].softmax = toolsLoadDouble(f);
zone->steepness_ranges[i].hardmax = toolsLoadDouble(f);
}
zone->circles_included_count = toolsLoadInt(f);
for (i = 0; i < zone->circles_included_count; i++)
{
@ -135,7 +135,7 @@ void zoneLoad(Zone* zone, FILE* f)
zone->circles_included[i].softradius = toolsLoadDouble(f);
zone->circles_included[i].hardradius = toolsLoadDouble(f);
}
zone->circles_excluded_count = toolsLoadInt(f);
for (i = 0; i < zone->circles_excluded_count; i++)
{
@ -149,7 +149,7 @@ void zoneLoad(Zone* zone, FILE* f)
void zoneCopy(Zone* source, Zone* destination)
{
*source = *destination;
*destination = *source;
}
void zoneIncludeCircleArea(Zone* zone, double value, double centerx, double centerz, double softradius, double hardradius)
@ -213,11 +213,11 @@ static inline double _getRangeInfluence(Range range, double position)
static inline double _getCircleInfluence(Circle circle, Vector3 position)
{
double radius, dx, dz;
dx = position.x - circle.centerx;
dz = position.z - circle.centerz;
radius = sqrt(dx * dx + dz * dz);
if (radius > circle.hardradius)
{
return 0.0;
@ -236,7 +236,7 @@ double zoneGetValue(Zone* zone, Vector3 location, Vector3 normal)
{
int i;
double value, value_height, value_steepness, value_circle;
if (zone->circles_included_count > 0)
{
value_circle = 0.0;