2011-12-10 13:25:22 +00:00
|
|
|
/* Terrain tab */
|
|
|
|
|
|
|
|
#include "common.h"
|
2011-12-23 22:39:13 +00:00
|
|
|
#include "lib_paysages/shared/functions.h"
|
2012-01-03 15:40:50 +00:00
|
|
|
#include "lib_paysages/terrain.h"
|
|
|
|
#include "lib_paysages/textures.h"
|
2011-12-10 13:25:22 +00:00
|
|
|
|
|
|
|
static SmallPreview* _preview;
|
2012-01-03 15:40:50 +00:00
|
|
|
static TerrainDefinition _definition;
|
2011-12-10 13:25:22 +00:00
|
|
|
|
|
|
|
static Color _cbPreviewRenderPixel(SmallPreview* preview, double x, double y, double xoffset, double yoffset, double scaling)
|
|
|
|
{
|
|
|
|
Color result;
|
|
|
|
|
|
|
|
result.r = result.g = result.b = terrainGetHeightNormalized(x, y);
|
|
|
|
result.a = 1.0;
|
2012-01-03 15:40:50 +00:00
|
|
|
|
|
|
|
/* TEMP */
|
|
|
|
//result = terrainGetColor(x, y, 0.01);
|
|
|
|
|
2011-12-10 13:25:22 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _cbEditNoiseDone(NoiseGenerator* generator)
|
|
|
|
{
|
2012-01-03 15:40:50 +00:00
|
|
|
noiseCopy(generator, _definition.height_noise);
|
|
|
|
terrainSetDefinition(_definition);
|
|
|
|
|
2011-12-10 13:25:22 +00:00
|
|
|
/* TODO Redraw only affected by terrain */
|
|
|
|
guiPreviewRedrawAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _cbEditNoise(GtkWidget* widget, gpointer data)
|
|
|
|
{
|
2012-01-03 15:40:50 +00:00
|
|
|
guiNoiseEdit(texturesGetDefinition(0).bump_noise, _cbEditNoiseDone);
|
2011-12-10 13:25:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void guiTerrainInit()
|
|
|
|
{
|
|
|
|
g_signal_connect(GET_WIDGET("terrain_noise_edit"), "clicked", G_CALLBACK(_cbEditNoise), NULL);
|
2011-12-23 22:39:13 +00:00
|
|
|
|
2011-12-10 13:25:22 +00:00
|
|
|
_preview = guiPreviewNew(GTK_IMAGE(GET_WIDGET("terrain_preview")));
|
|
|
|
guiPreviewConfigScaling(_preview, 0.01, 1.0, 0.05);
|
|
|
|
guiPreviewConfigScrolling(_preview, -1000.0, 1000.0, -1000.0, 1000.0);
|
|
|
|
guiPreviewSetViewport(_preview, 0.0, 0.0, 0.2);
|
|
|
|
guiPreviewSetRenderer(_preview, _cbPreviewRenderPixel);
|
|
|
|
}
|
|
|
|
|