2011-12-25 21:19:32 +00:00
|
|
|
#include "formwater.h"
|
2012-01-29 17:39:56 +00:00
|
|
|
|
2011-12-26 21:53:29 +00:00
|
|
|
#include <QColor>
|
2012-01-05 16:32:41 +00:00
|
|
|
#include <QSlider>
|
2013-11-12 20:34:35 +00:00
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
#include "tools/euclid.h"
|
|
|
|
#include "tools/lighting.h"
|
|
|
|
#include "renderer.h"
|
|
|
|
#include "water/public.h"
|
|
|
|
#include "terrain/public.h"
|
|
|
|
#include "atmosphere/public.h"
|
2012-01-29 17:39:56 +00:00
|
|
|
#include "tools.h"
|
2013-11-17 21:36:18 +00:00
|
|
|
#include "RenderingScenery.h"
|
2013-11-12 22:15:35 +00:00
|
|
|
#include "BasePreview.h"
|
2013-11-14 17:47:03 +00:00
|
|
|
#include "CameraDefinition.h"
|
2013-11-13 19:07:35 +00:00
|
|
|
#include "WaterDefinition.h"
|
2013-11-20 12:06:16 +00:00
|
|
|
#include "WaterCoveragePreviewRenderer.h"
|
|
|
|
#include "WaterAspectPreviewRenderer.h"
|
2011-12-26 21:53:29 +00:00
|
|
|
|
2013-02-27 16:38:27 +00:00
|
|
|
static WaterDefinition* _definition;
|
2011-12-27 19:03:46 +00:00
|
|
|
|
|
|
|
/**************** Form ****************/
|
2013-04-27 19:41:57 +00:00
|
|
|
FormWater::FormWater(QWidget *parent) :
|
|
|
|
BaseForm(parent)
|
2011-12-25 21:19:32 +00:00
|
|
|
{
|
2012-11-24 12:30:51 +00:00
|
|
|
addAutoPreset(tr("Lake surface"));
|
|
|
|
addAutoPreset(tr("Standard sea"));
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2013-11-13 19:07:35 +00:00
|
|
|
_definition = new WaterDefinition(NULL);
|
2011-12-27 19:03:46 +00:00
|
|
|
|
2013-11-20 12:06:16 +00:00
|
|
|
previewCoverage = new BasePreview(this);
|
|
|
|
previewCoverageRenderer = new WaterCoveragePreviewRenderer(_definition);
|
2012-11-19 20:40:57 +00:00
|
|
|
addPreview(previewCoverage, tr("Coverage preview"));
|
2013-11-20 12:06:16 +00:00
|
|
|
previewCoverage->setRenderer(previewCoverageRenderer);
|
|
|
|
|
|
|
|
previewColor = new BasePreview(this);
|
|
|
|
previewColorRenderer = new WaterAspectPreviewRenderer(_definition);
|
2012-11-19 20:40:57 +00:00
|
|
|
addPreview(previewColor, tr("Rendered preview"));
|
2013-11-20 12:06:16 +00:00
|
|
|
previewColor->setRenderer(previewColorRenderer);
|
2012-02-28 13:45:11 +00:00
|
|
|
|
2013-05-11 21:34:30 +00:00
|
|
|
//addInputDouble(tr("Height"), &_definition->height, -15.0, 15.0, 0.1, 1.0);
|
2013-11-13 19:07:35 +00:00
|
|
|
addInputMaterial(tr("Surface material"), _definition->material);
|
|
|
|
addInputColor(tr("Depth color"), _definition->depth_color);
|
2013-02-28 15:34:47 +00:00
|
|
|
addInputDouble(tr("Transparency"), &_definition->transparency, 0.0, 1.0, 0.001, 0.1);
|
|
|
|
addInputDouble(tr("Reflection"), &_definition->reflection, 0.0, 1.0, 0.001, 0.1);
|
|
|
|
addInputDouble(tr("Transparency distance"), &_definition->transparency_depth, 0.0, 20.0, 0.1, 1.0);
|
|
|
|
addInputDouble(tr("Light-through distance"), &_definition->lighting_depth, 0.0, 20.0, 0.1, 1.0);
|
|
|
|
addInputDouble(tr("Waves scaling"), &_definition->scaling, 0.02, 2.0, 0.02, 0.2);
|
|
|
|
addInputDouble(tr("Waves height"), &_definition->waves_height, 0.0, 2.0, 0.02, 0.2);
|
|
|
|
addInputDouble(tr("Waves detail"), &_definition->detail_height, 0.0, 0.3, 0.003, 0.03);
|
|
|
|
addInputDouble(tr("Waves turbulence"), &_definition->turbulence, 0.0, 0.5, 0.005, 0.05);
|
|
|
|
addInputDouble(tr("Foam coverage"), &_definition->foam_coverage, 0.0, 1.0, 0.01, 0.1);
|
2013-11-13 19:07:35 +00:00
|
|
|
addInputMaterial(tr("Foam material"), _definition->foam_material);
|
2011-12-27 19:03:46 +00:00
|
|
|
|
|
|
|
revertConfig();
|
|
|
|
}
|
|
|
|
|
2013-11-20 12:06:16 +00:00
|
|
|
FormWater::~FormWater()
|
|
|
|
{
|
|
|
|
delete _definition;
|
|
|
|
|
|
|
|
delete previewCoverageRenderer;
|
|
|
|
delete previewCoverage;
|
|
|
|
|
|
|
|
delete previewColorRenderer;
|
|
|
|
delete previewCoverage;
|
|
|
|
}
|
|
|
|
|
2012-01-05 18:39:17 +00:00
|
|
|
void FormWater::revertConfig()
|
2011-12-27 19:03:46 +00:00
|
|
|
{
|
2013-11-17 21:36:18 +00:00
|
|
|
RenderingScenery::getCurrent()->getWater(_definition);
|
2012-01-05 18:39:17 +00:00
|
|
|
BaseForm::revertConfig();
|
2011-12-27 19:03:46 +00:00
|
|
|
}
|
|
|
|
|
2012-01-07 16:53:23 +00:00
|
|
|
void FormWater::applyConfig()
|
2011-12-27 19:03:46 +00:00
|
|
|
{
|
2013-11-17 21:36:18 +00:00
|
|
|
RenderingScenery::getCurrent()->setWater(_definition);
|
2012-01-07 16:53:23 +00:00
|
|
|
BaseForm::applyConfig();
|
|
|
|
}
|
2012-11-11 10:52:03 +00:00
|
|
|
|
|
|
|
void FormWater::configChangeEvent()
|
|
|
|
{
|
2013-11-13 19:07:35 +00:00
|
|
|
_definition->validate();
|
2012-11-11 10:52:03 +00:00
|
|
|
BaseForm::configChangeEvent();
|
|
|
|
}
|
2012-11-19 20:40:57 +00:00
|
|
|
|
|
|
|
void FormWater::autoPresetSelected(int preset)
|
|
|
|
{
|
2013-11-17 21:36:18 +00:00
|
|
|
_definition->applyPreset((WaterDefinition::WaterPreset)preset);
|
2012-11-19 20:40:57 +00:00
|
|
|
BaseForm::autoPresetSelected(preset);
|
|
|
|
}
|
|
|
|
|