paysages: Small fixes.
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@211 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
201bd75625
commit
867ba2513f
3 changed files with 43 additions and 44 deletions
|
@ -14,10 +14,7 @@ static Color _cbPreviewRenderPixel(SmallPreview* preview, double x, double y, do
|
||||||
|
|
||||||
result.r = result.g = result.b = terrainGetHeightNormalized(x, y);
|
result.r = result.g = result.b = terrainGetHeightNormalized(x, y);
|
||||||
result.a = 1.0;
|
result.a = 1.0;
|
||||||
|
|
||||||
/* TEMP */
|
|
||||||
//result = terrainGetColor(x, y, 0.01);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,14 +22,14 @@ static void _cbEditNoiseDone(NoiseGenerator* generator)
|
||||||
{
|
{
|
||||||
noiseCopy(generator, _definition.height_noise);
|
noiseCopy(generator, _definition.height_noise);
|
||||||
terrainSetDefinition(_definition);
|
terrainSetDefinition(_definition);
|
||||||
|
|
||||||
/* TODO Redraw only affected by terrain */
|
/* TODO Redraw only affected by terrain */
|
||||||
guiPreviewRedrawAll();
|
guiPreviewRedrawAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _cbEditNoise(GtkWidget* widget, gpointer data)
|
static void _cbEditNoise(GtkWidget* widget, gpointer data)
|
||||||
{
|
{
|
||||||
guiNoiseEdit(texturesGetDefinition(0).bump_noise, _cbEditNoiseDone);
|
guiNoiseEdit(_definition.height_noise, _cbEditNoiseDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
void guiTerrainInit()
|
void guiTerrainInit()
|
||||||
|
|
|
@ -21,6 +21,7 @@ static int _is_rendering = 0;
|
||||||
void autoInit()
|
void autoInit()
|
||||||
{
|
{
|
||||||
_cpu_count = (int)sysconf(_SC_NPROCESSORS_ONLN);
|
_cpu_count = (int)sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
|
_cpu_count = 1;
|
||||||
renderSetBackgroundColor(&COLOR_BLACK);
|
renderSetBackgroundColor(&COLOR_BLACK);
|
||||||
|
|
||||||
terrainInit();
|
terrainInit();
|
||||||
|
@ -222,42 +223,43 @@ void autoGenRealisticLandscape(int seed)
|
||||||
|
|
||||||
terrain = terrainCreateDefinition();
|
terrain = terrainCreateDefinition();
|
||||||
noiseGenerateBaseNoise(terrain.height_noise, 1048576);
|
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);
|
noiseNormalizeHeight(terrain.height_noise, -12.0, 12.0, 0);
|
||||||
terrainSetDefinition(terrain);
|
terrainSetDefinition(terrain);
|
||||||
terrainDeleteDefinition(terrain);
|
terrainDeleteDefinition(terrain);
|
||||||
|
|
||||||
layer = texturesAddLayer();
|
layer = texturesAddLayer();
|
||||||
texture = texturesCreateDefinition();
|
texture = texturesCreateDefinition();
|
||||||
noiseGenerateBaseNoise(texture.bump_noise, 102400);
|
noiseGenerateBaseNoise(texture.bump_noise, 102400);
|
||||||
noiseAddLevelsSimple(texture.bump_noise, 6, 0.01, 0.01);
|
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);
|
texturesSetDefinition(layer, texture);
|
||||||
texturesDeleteDefinition(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");
|
layer = texturesAddLayer();
|
||||||
tex->scaling_x = 0.0004;
|
texture = texturesCreateDefinition();
|
||||||
tex->scaling_y = 0.0004;
|
zoneAddHeightRange(texture.zone, 1.0, -1.0, 0.0, 3.0, 15.0);
|
||||||
tex->scaling_z = 0.0004;
|
zoneAddSteepnessRange(texture.zone, 1.0, 0.0, 0.0, 0.3, 0.4);
|
||||||
zone = zoneCreate(0.0);
|
noiseGenerateBaseNoise(texture.bump_noise, 102400);
|
||||||
zoneAddHeightRange(zone, 1.0, -1.0, 0.0, 3.0, 15.0);
|
noiseAddLevelsSimple(texture.bump_noise, 6, 0.02, 0.008);
|
||||||
zoneAddSteepnessRange(zone, 1.0, 0.0, 0.0, 0.3, 0.4);
|
texture.color.r = 0.2;
|
||||||
terrainAddTexture(tex, 0.15, zone, 0.05);*/
|
texture.color.g = 0.24;
|
||||||
|
texture.color.b = 0.05;
|
||||||
|
texturesSetDefinition(layer, texture);
|
||||||
|
texturesDeleteDefinition(texture);
|
||||||
|
|
||||||
/*tex = textureCreateFromFile("./data/textures/snow1.jpg");
|
/*layer = texturesAddLayer();
|
||||||
tex->scaling_x = 0.001;
|
texture = texturesCreateDefinition();
|
||||||
tex->scaling_y = 0.001;
|
zoneAddHeightRange(texture.zone, 1.0, 3.0, 4.0, 100.0, 100.0);
|
||||||
tex->scaling_z = 0.001;
|
noiseGenerateBaseNoise(texture.bump_noise, 102400);
|
||||||
zone = zoneCreate(0.0);
|
noiseAddLevelsSimple(texture.bump_noise, 6, 0.04, 0.003);
|
||||||
zoneAddHeightRange(zone, 1.0, 3.0, 4.0, 100.0, 100.0);
|
texture.color.r = 1.0;
|
||||||
terrainAddTexture(tex, 0.5, zone, 0.1);*/
|
texture.color.g = 1.0;
|
||||||
|
texture.color.b = 1.0;
|
||||||
|
texturesSetDefinition(layer, texture);
|
||||||
|
texturesDeleteDefinition(texture);*/
|
||||||
|
|
||||||
/* DEBUG */
|
/* DEBUG */
|
||||||
/*mod = modifierCreate();
|
/*mod = modifierCreate();
|
||||||
|
|
|
@ -48,7 +48,7 @@ Zone* zoneCreate()
|
||||||
result->steepness_ranges_count = 0;
|
result->steepness_ranges_count = 0;
|
||||||
result->circles_included_count = 0;
|
result->circles_included_count = 0;
|
||||||
result->circles_excluded_count = 0;
|
result->circles_excluded_count = 0;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ void zoneDelete(Zone* zone)
|
||||||
void zoneSave(Zone* zone, FILE* f)
|
void zoneSave(Zone* zone, FILE* f)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
toolsSaveInt(f, zone->height_ranges_count);
|
toolsSaveInt(f, zone->height_ranges_count);
|
||||||
for (i = 0; i < zone->height_ranges_count; i++)
|
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].softmax);
|
||||||
toolsSaveDouble(f, zone->height_ranges[i].hardmax);
|
toolsSaveDouble(f, zone->height_ranges[i].hardmax);
|
||||||
}
|
}
|
||||||
|
|
||||||
toolsSaveInt(f, zone->steepness_ranges_count);
|
toolsSaveInt(f, zone->steepness_ranges_count);
|
||||||
for (i = 0; i < zone->steepness_ranges_count; i++)
|
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].softmax);
|
||||||
toolsSaveDouble(f, zone->steepness_ranges[i].hardmax);
|
toolsSaveDouble(f, zone->steepness_ranges[i].hardmax);
|
||||||
}
|
}
|
||||||
|
|
||||||
toolsSaveInt(f, zone->circles_included_count);
|
toolsSaveInt(f, zone->circles_included_count);
|
||||||
for (i = 0; i < zone->circles_included_count; i++)
|
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].softradius);
|
||||||
toolsSaveDouble(f, zone->circles_included[i].hardradius);
|
toolsSaveDouble(f, zone->circles_included[i].hardradius);
|
||||||
}
|
}
|
||||||
|
|
||||||
toolsSaveInt(f, zone->circles_excluded_count);
|
toolsSaveInt(f, zone->circles_excluded_count);
|
||||||
for (i = 0; i < zone->circles_excluded_count; i++)
|
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)
|
void zoneLoad(Zone* zone, FILE* f)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
zone->height_ranges_count = toolsLoadInt(f);
|
zone->height_ranges_count = toolsLoadInt(f);
|
||||||
for (i = 0; i < zone->height_ranges_count; i++)
|
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].softmax = toolsLoadDouble(f);
|
||||||
zone->height_ranges[i].hardmax = toolsLoadDouble(f);
|
zone->height_ranges[i].hardmax = toolsLoadDouble(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
zone->steepness_ranges_count = toolsLoadInt(f);
|
zone->steepness_ranges_count = toolsLoadInt(f);
|
||||||
for (i = 0; i < zone->steepness_ranges_count; i++)
|
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].softmax = toolsLoadDouble(f);
|
||||||
zone->steepness_ranges[i].hardmax = toolsLoadDouble(f);
|
zone->steepness_ranges[i].hardmax = toolsLoadDouble(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
zone->circles_included_count = toolsLoadInt(f);
|
zone->circles_included_count = toolsLoadInt(f);
|
||||||
for (i = 0; i < zone->circles_included_count; i++)
|
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].softradius = toolsLoadDouble(f);
|
||||||
zone->circles_included[i].hardradius = toolsLoadDouble(f);
|
zone->circles_included[i].hardradius = toolsLoadDouble(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
zone->circles_excluded_count = toolsLoadInt(f);
|
zone->circles_excluded_count = toolsLoadInt(f);
|
||||||
for (i = 0; i < zone->circles_excluded_count; i++)
|
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)
|
void zoneCopy(Zone* source, Zone* destination)
|
||||||
{
|
{
|
||||||
*source = *destination;
|
*destination = *source;
|
||||||
}
|
}
|
||||||
|
|
||||||
void zoneIncludeCircleArea(Zone* zone, double value, double centerx, double centerz, double softradius, double hardradius)
|
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)
|
static inline double _getCircleInfluence(Circle circle, Vector3 position)
|
||||||
{
|
{
|
||||||
double radius, dx, dz;
|
double radius, dx, dz;
|
||||||
|
|
||||||
dx = position.x - circle.centerx;
|
dx = position.x - circle.centerx;
|
||||||
dz = position.z - circle.centerz;
|
dz = position.z - circle.centerz;
|
||||||
radius = sqrt(dx * dx + dz * dz);
|
radius = sqrt(dx * dx + dz * dz);
|
||||||
|
|
||||||
if (radius > circle.hardradius)
|
if (radius > circle.hardradius)
|
||||||
{
|
{
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
@ -236,7 +236,7 @@ double zoneGetValue(Zone* zone, Vector3 location, Vector3 normal)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
double value, value_height, value_steepness, value_circle;
|
double value, value_height, value_steepness, value_circle;
|
||||||
|
|
||||||
if (zone->circles_included_count > 0)
|
if (zone->circles_included_count > 0)
|
||||||
{
|
{
|
||||||
value_circle = 0.0;
|
value_circle = 0.0;
|
||||||
|
|
Loading…
Reference in a new issue