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()
|
||||
{
|
||||
revertConfig();
|
||||
emit(configApplied());
|
||||
}
|
||||
|
||||
void BaseForm::addPreview(Preview* preview, QString label)
|
||||
|
|
|
@ -15,6 +15,9 @@ class BaseForm:public QWidget
|
|||
public:
|
||||
BaseForm(QWidget* parent);
|
||||
|
||||
signals:
|
||||
void configApplied();
|
||||
|
||||
public slots:
|
||||
virtual void revertConfig();
|
||||
virtual void applyConfig();
|
||||
|
|
|
@ -42,20 +42,40 @@ public:
|
|||
PreviewTerrainColor(QWidget* parent):Preview(parent)
|
||||
{
|
||||
_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:
|
||||
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()
|
||||
{
|
||||
terrainCopyDefinition(&_definition, &_preview_definition);
|
||||
terrainCopyDefinition(&_definition, &_terrain);
|
||||
sceneryGetTextures(&_textures);
|
||||
}
|
||||
private:
|
||||
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 ****************/
|
||||
|
|
|
@ -20,8 +20,8 @@ class PreviewWaterCoverage:public Preview
|
|||
public:
|
||||
PreviewWaterCoverage(QWidget* parent):Preview(parent)
|
||||
{
|
||||
_water = waterCreateDefinition();
|
||||
_terrain = terrainCreateDefinition();
|
||||
sceneryGetTerrain(&_terrain);
|
||||
}
|
||||
protected:
|
||||
QColor getColor(double x, double y)
|
||||
|
@ -39,7 +39,13 @@ protected:
|
|||
return colorToQColor(_definition.main_color);
|
||||
}
|
||||
}
|
||||
void updateData()
|
||||
{
|
||||
waterCopyDefinition(&_definition, &_water);
|
||||
sceneryGetTerrain(&_terrain);
|
||||
}
|
||||
private:
|
||||
WaterDefinition _water;
|
||||
TerrainDefinition _terrain;
|
||||
};
|
||||
|
||||
|
@ -49,6 +55,7 @@ public:
|
|||
PreviewWaterColor(QWidget* parent):Preview(parent)
|
||||
{
|
||||
_water = waterCreateDefinition();
|
||||
|
||||
_renderer = rendererGetFake();
|
||||
_renderer.rayWalking = _rayWalking;
|
||||
// TODO Lighting
|
||||
|
@ -80,8 +87,12 @@ protected:
|
|||
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;
|
||||
return colorToQColor(waterGetColor(&_definition, &_renderer, location, look));
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -30,14 +30,26 @@ int main(int argc, char** argv)
|
|||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent)
|
||||
{
|
||||
BaseForm* form;
|
||||
QTabWidget* tabs;
|
||||
QMenu* menu;
|
||||
|
||||
tabs = new QTabWidget(this);
|
||||
tabs->addTab(new FormTerrain(tabs), "Terrain");
|
||||
tabs->addTab(new FormWater(tabs), "Water");
|
||||
tabs->addTab(new FormSky(tabs), "Sky");
|
||||
tabs->addTab(new FormRender(tabs), "Render");
|
||||
|
||||
form = new FormTerrain(tabs);
|
||||
tabs->addTab(form, "Terrain");
|
||||
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->addAction("New", this, SLOT(fileNew()));
|
||||
|
|
|
@ -201,7 +201,7 @@ void autoGenRealisticLandscape(int seed)
|
|||
texture->color.b = 0.57;
|
||||
texture = texturesGetLayer(&textures, texturesAddLayer(&textures));
|
||||
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);
|
||||
noiseAddLevelsSimple(texture->bump_noise, 6, 0.02, 0.008);
|
||||
texture->color.r = 0.2;
|
||||
|
|
|
@ -214,7 +214,7 @@ Color texturesGetLayerColor(TextureLayerDefinition* definition, Renderer* render
|
|||
SurfaceMaterial material;
|
||||
|
||||
result = COLOR_TRANSPARENT;
|
||||
normal = _getNormal(definition, renderer, location, detail * 0.3);
|
||||
normal = _getNormal(definition, renderer, location, detail);
|
||||
|
||||
coverage = zoneGetValue(definition->zone, location, normal);
|
||||
if (coverage > 0.0)
|
||||
|
|
Loading…
Reference in a new issue