paysages: Small changes.
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@239 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
d5d9ae219f
commit
9a198c2519
7 changed files with 59 additions and 12 deletions
|
@ -81,6 +81,7 @@ void BaseForm::revertConfig()
|
||||||
void BaseForm::applyConfig()
|
void BaseForm::applyConfig()
|
||||||
{
|
{
|
||||||
revertConfig();
|
revertConfig();
|
||||||
|
emit(configApplied());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseForm::addPreview(Preview* preview, QString label)
|
void BaseForm::addPreview(Preview* preview, QString label)
|
||||||
|
|
|
@ -15,6 +15,9 @@ class BaseForm:public QWidget
|
||||||
public:
|
public:
|
||||||
BaseForm(QWidget* parent);
|
BaseForm(QWidget* parent);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void configApplied();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void revertConfig();
|
virtual void revertConfig();
|
||||||
virtual void applyConfig();
|
virtual void applyConfig();
|
||||||
|
|
|
@ -42,20 +42,40 @@ public:
|
||||||
PreviewTerrainColor(QWidget* parent):Preview(parent)
|
PreviewTerrainColor(QWidget* parent):Preview(parent)
|
||||||
{
|
{
|
||||||
_renderer = rendererGetFake();
|
_renderer = rendererGetFake();
|
||||||
_preview_definition = terrainCreateDefinition();
|
_renderer.applyTextures = _applyTextures;
|
||||||
|
_renderer.getTerrainHeight = _getTerrainHeight;
|
||||||
|
/*_renderer.applyLightingToSurface = _applyLightingToSurface;*/
|
||||||
|
|
||||||
|
_terrain = terrainCreateDefinition();
|
||||||
|
_textures = texturesCreateDefinition();
|
||||||
|
|
||||||
|
_renderer.customData[0] = &_terrain;
|
||||||
|
_renderer.customData[1] = &_textures;
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
QColor getColor(double x, double y)
|
QColor getColor(double x, double y)
|
||||||
{
|
{
|
||||||
return colorToQColor(terrainGetColor(&_preview_definition, &_renderer, x, y, scaling));
|
return colorToQColor(terrainGetColor(&_terrain, &_renderer, x, y, scaling));
|
||||||
}
|
}
|
||||||
void updateData()
|
void updateData()
|
||||||
{
|
{
|
||||||
terrainCopyDefinition(&_definition, &_preview_definition);
|
terrainCopyDefinition(&_definition, &_terrain);
|
||||||
|
sceneryGetTextures(&_textures);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
Renderer _renderer;
|
Renderer _renderer;
|
||||||
TerrainDefinition _preview_definition;
|
TerrainDefinition _terrain;
|
||||||
|
TexturesDefinition _textures;
|
||||||
|
|
||||||
|
static double _getTerrainHeight(Renderer* renderer, double x, double z)
|
||||||
|
{
|
||||||
|
return terrainGetHeight((TerrainDefinition*)(renderer->customData[0]), x, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Color _applyTextures(Renderer* renderer, Vector3 location, double precision)
|
||||||
|
{
|
||||||
|
return texturesGetColor((TexturesDefinition*)(renderer->customData[1]), renderer, location, precision);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**************** Form ****************/
|
/**************** Form ****************/
|
||||||
|
|
|
@ -20,8 +20,8 @@ class PreviewWaterCoverage:public Preview
|
||||||
public:
|
public:
|
||||||
PreviewWaterCoverage(QWidget* parent):Preview(parent)
|
PreviewWaterCoverage(QWidget* parent):Preview(parent)
|
||||||
{
|
{
|
||||||
|
_water = waterCreateDefinition();
|
||||||
_terrain = terrainCreateDefinition();
|
_terrain = terrainCreateDefinition();
|
||||||
sceneryGetTerrain(&_terrain);
|
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
QColor getColor(double x, double y)
|
QColor getColor(double x, double y)
|
||||||
|
@ -39,7 +39,13 @@ protected:
|
||||||
return colorToQColor(_definition.main_color);
|
return colorToQColor(_definition.main_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void updateData()
|
||||||
|
{
|
||||||
|
waterCopyDefinition(&_definition, &_water);
|
||||||
|
sceneryGetTerrain(&_terrain);
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
|
WaterDefinition _water;
|
||||||
TerrainDefinition _terrain;
|
TerrainDefinition _terrain;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -49,6 +55,7 @@ public:
|
||||||
PreviewWaterColor(QWidget* parent):Preview(parent)
|
PreviewWaterColor(QWidget* parent):Preview(parent)
|
||||||
{
|
{
|
||||||
_water = waterCreateDefinition();
|
_water = waterCreateDefinition();
|
||||||
|
|
||||||
_renderer = rendererGetFake();
|
_renderer = rendererGetFake();
|
||||||
_renderer.rayWalking = _rayWalking;
|
_renderer.rayWalking = _rayWalking;
|
||||||
// TODO Lighting
|
// TODO Lighting
|
||||||
|
@ -80,8 +87,12 @@ protected:
|
||||||
return colorToQColor(_rayWalking(&_renderer, eye, look, 0, 0, 0, 0).hit_color);
|
return colorToQColor(_rayWalking(&_renderer, eye, look, 0, 0, 0, 0).hit_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return colorToQColor(waterGetColor(&_water, &_renderer, location, look));
|
||||||
|
}
|
||||||
|
void updateData()
|
||||||
|
{
|
||||||
|
waterCopyDefinition(&_definition, &_water);
|
||||||
_water.height = 0.0;
|
_water.height = 0.0;
|
||||||
return colorToQColor(waterGetColor(&_definition, &_renderer, location, look));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -30,14 +30,26 @@ int main(int argc, char** argv)
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent)
|
QMainWindow(parent)
|
||||||
{
|
{
|
||||||
|
BaseForm* form;
|
||||||
QTabWidget* tabs;
|
QTabWidget* tabs;
|
||||||
QMenu* menu;
|
QMenu* menu;
|
||||||
|
|
||||||
tabs = new QTabWidget(this);
|
tabs = new QTabWidget(this);
|
||||||
tabs->addTab(new FormTerrain(tabs), "Terrain");
|
|
||||||
tabs->addTab(new FormWater(tabs), "Water");
|
form = new FormTerrain(tabs);
|
||||||
tabs->addTab(new FormSky(tabs), "Sky");
|
tabs->addTab(form, "Terrain");
|
||||||
tabs->addTab(new FormRender(tabs), "Render");
|
QObject::connect(form, SIGNAL(configApplied()), this, SLOT(refreshAll()));
|
||||||
|
|
||||||
|
form = new FormWater(tabs);
|
||||||
|
tabs->addTab(form, "Water");
|
||||||
|
QObject::connect(form, SIGNAL(configApplied()), this, SLOT(refreshAll()));
|
||||||
|
|
||||||
|
form = new FormSky(tabs);
|
||||||
|
tabs->addTab(form, "Sky");
|
||||||
|
QObject::connect(form, SIGNAL(configApplied()), this, SLOT(refreshAll()));
|
||||||
|
|
||||||
|
form = new FormRender(tabs);
|
||||||
|
tabs->addTab(form, "Render");
|
||||||
|
|
||||||
menu = menuBar()->addMenu("Scene");
|
menu = menuBar()->addMenu("Scene");
|
||||||
menu->addAction("New", this, SLOT(fileNew()));
|
menu->addAction("New", this, SLOT(fileNew()));
|
||||||
|
|
|
@ -201,7 +201,7 @@ void autoGenRealisticLandscape(int seed)
|
||||||
texture->color.b = 0.57;
|
texture->color.b = 0.57;
|
||||||
texture = texturesGetLayer(&textures, texturesAddLayer(&textures));
|
texture = texturesGetLayer(&textures, texturesAddLayer(&textures));
|
||||||
zoneAddHeightRange(texture->zone, 1.0, -1.0, 0.0, 3.0, 15.0);
|
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);
|
zoneAddSteepnessRange(texture->zone, 1.0, 0.0, 0.0, 0.2, 0.3);
|
||||||
noiseGenerateBaseNoise(texture->bump_noise, 102400);
|
noiseGenerateBaseNoise(texture->bump_noise, 102400);
|
||||||
noiseAddLevelsSimple(texture->bump_noise, 6, 0.02, 0.008);
|
noiseAddLevelsSimple(texture->bump_noise, 6, 0.02, 0.008);
|
||||||
texture->color.r = 0.2;
|
texture->color.r = 0.2;
|
||||||
|
|
|
@ -214,7 +214,7 @@ Color texturesGetLayerColor(TextureLayerDefinition* definition, Renderer* render
|
||||||
SurfaceMaterial material;
|
SurfaceMaterial material;
|
||||||
|
|
||||||
result = COLOR_TRANSPARENT;
|
result = COLOR_TRANSPARENT;
|
||||||
normal = _getNormal(definition, renderer, location, detail * 0.3);
|
normal = _getNormal(definition, renderer, location, detail);
|
||||||
|
|
||||||
coverage = zoneGetValue(definition->zone, location, normal);
|
coverage = zoneGetValue(definition->zone, location, normal);
|
||||||
if (coverage > 0.0)
|
if (coverage > 0.0)
|
||||||
|
|
Loading…
Reference in a new issue