2012-01-26 23:08:09 +00:00
|
|
|
#include "formtextures.h"
|
|
|
|
|
2013-11-17 21:36:18 +00:00
|
|
|
#include "RenderingScenery.h"
|
2013-11-12 22:15:35 +00:00
|
|
|
#include "BasePreview.h"
|
|
|
|
#include "renderer.h"
|
2012-04-05 16:16:32 +00:00
|
|
|
#include "tools.h"
|
2013-11-14 17:47:03 +00:00
|
|
|
#include "CameraDefinition.h"
|
2013-11-16 18:12:42 +00:00
|
|
|
#include "TexturesDefinition.h"
|
|
|
|
#include "TextureLayerDefinition.h"
|
|
|
|
#include "terrain/public.h"
|
2012-01-26 23:08:09 +00:00
|
|
|
|
|
|
|
/**************** Previews ****************/
|
2013-04-27 19:41:57 +00:00
|
|
|
class PreviewTexturesCoverage : public BasePreview
|
2012-04-03 19:33:40 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-04-27 19:41:57 +00:00
|
|
|
|
2013-11-16 18:12:42 +00:00
|
|
|
PreviewTexturesCoverage(QWidget* parent, TextureLayerDefinition* layer) : BasePreview(parent)
|
2012-04-03 19:33:40 +00:00
|
|
|
{
|
|
|
|
_renderer = rendererCreate();
|
2013-01-20 15:07:45 +00:00
|
|
|
_renderer->render_quality = 3;
|
2012-12-06 14:04:04 +00:00
|
|
|
|
2012-08-26 13:06:42 +00:00
|
|
|
_original_layer = layer;
|
2013-03-31 20:27:21 +00:00
|
|
|
//_preview_definition = (TexturesDefinition*)TexturesDefinitionClass.create();
|
2012-12-06 14:04:04 +00:00
|
|
|
|
2012-06-26 19:36:50 +00:00
|
|
|
addOsd(QString("geolocation"));
|
2012-12-06 14:04:04 +00:00
|
|
|
|
2013-01-31 15:10:11 +00:00
|
|
|
configScaling(20.0, 500.0, 20.0, 50.0);
|
2012-04-15 20:08:01 +00:00
|
|
|
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
2012-04-03 19:33:40 +00:00
|
|
|
}
|
2013-04-27 19:41:57 +00:00
|
|
|
|
2012-08-26 13:06:42 +00:00
|
|
|
~PreviewTexturesCoverage()
|
|
|
|
{
|
2013-03-31 20:27:21 +00:00
|
|
|
//TexturesDefinitionClass.destroy(_preview_layer);
|
2012-08-26 13:06:42 +00:00
|
|
|
}
|
2012-04-03 19:33:40 +00:00
|
|
|
protected:
|
2013-04-27 19:41:57 +00:00
|
|
|
|
2013-01-16 14:26:46 +00:00
|
|
|
Color getColor(double x, double y)
|
2012-04-03 19:33:40 +00:00
|
|
|
{
|
2012-04-05 17:47:43 +00:00
|
|
|
Vector3 location;
|
2013-01-16 14:26:46 +00:00
|
|
|
Color result;
|
2012-04-05 17:47:43 +00:00
|
|
|
location.x = x;
|
2013-01-20 15:07:45 +00:00
|
|
|
location.y = _renderer->terrain->getHeight(_renderer, x, y, 1);
|
2012-04-05 17:47:43 +00:00
|
|
|
location.z = y;
|
2013-03-31 20:27:21 +00:00
|
|
|
//result.r = result.g = result.b = texturesGetLayerCoverage(_preview_layer, _renderer, location, this->scaling);
|
2013-01-16 14:26:46 +00:00
|
|
|
return result;
|
2012-04-03 19:33:40 +00:00
|
|
|
}
|
2013-04-27 19:41:57 +00:00
|
|
|
|
2012-04-03 19:33:40 +00:00
|
|
|
void updateData()
|
|
|
|
{
|
2013-11-17 21:36:18 +00:00
|
|
|
TerrainRendererClass.bind(_renderer, RenderingScenery::getCurrent()->getTerrain());
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2013-03-31 20:27:21 +00:00
|
|
|
//TexturesDefinitionClass.copy(_original_layer, _preview_layer);
|
2012-04-03 19:33:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2013-01-20 15:07:45 +00:00
|
|
|
Renderer* _renderer;
|
2013-11-16 18:12:42 +00:00
|
|
|
TextureLayerDefinition* _original_layer;
|
2013-03-31 20:27:21 +00:00
|
|
|
TexturesDefinition* _preview_definition;
|
2012-04-03 19:33:40 +00:00
|
|
|
};
|
|
|
|
|
2013-04-27 19:41:57 +00:00
|
|
|
class PreviewTexturesColor : public BasePreview
|
2012-04-03 19:33:40 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-04-27 19:41:57 +00:00
|
|
|
|
2013-11-16 18:12:42 +00:00
|
|
|
PreviewTexturesColor(QWidget* parent, TextureLayerDefinition* layer) : BasePreview(parent)
|
2012-04-03 19:33:40 +00:00
|
|
|
{
|
2012-08-26 13:06:42 +00:00
|
|
|
_original_layer = layer;
|
2013-03-31 20:27:21 +00:00
|
|
|
//_preview_layer = (TexturesLayerDefinition*)TexturesDefinitionClass.create();
|
2012-12-06 14:04:04 +00:00
|
|
|
|
2012-04-03 19:33:40 +00:00
|
|
|
_renderer = rendererCreate();
|
2013-01-20 15:07:45 +00:00
|
|
|
_renderer->render_quality = 3;
|
2013-04-27 19:41:57 +00:00
|
|
|
|
2013-11-14 17:47:03 +00:00
|
|
|
_renderer->render_camera->setLocation(Vector3(0.0, 20.0, 0.0));
|
2012-12-06 14:04:04 +00:00
|
|
|
|
2012-05-06 10:13:34 +00:00
|
|
|
configScaling(0.01, 1.0, 0.01, 0.1);
|
2012-04-15 20:08:01 +00:00
|
|
|
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
2012-04-03 19:33:40 +00:00
|
|
|
}
|
2013-04-27 19:41:57 +00:00
|
|
|
|
2012-08-26 13:06:42 +00:00
|
|
|
~PreviewTexturesColor()
|
|
|
|
{
|
2013-03-31 20:27:21 +00:00
|
|
|
//TexturesDefinitionClass.destroy(_preview_layer);
|
2012-08-26 13:06:42 +00:00
|
|
|
}
|
2012-04-03 19:33:40 +00:00
|
|
|
protected:
|
2013-04-27 19:41:57 +00:00
|
|
|
|
2013-01-16 14:26:46 +00:00
|
|
|
Color getColor(double x, double y)
|
2012-04-03 19:33:40 +00:00
|
|
|
{
|
2012-04-05 16:16:32 +00:00
|
|
|
Vector3 location;
|
2012-04-12 20:02:31 +00:00
|
|
|
location.x = x;
|
2012-04-05 16:16:32 +00:00
|
|
|
location.y = 0.0;
|
2012-04-12 20:02:31 +00:00
|
|
|
location.z = y;
|
2013-03-31 20:27:21 +00:00
|
|
|
//return texturesGetLayerColor(_preview_layer, _renderer, location, this->scaling);
|
|
|
|
return COLOR_BLACK;
|
2012-04-03 19:33:40 +00:00
|
|
|
}
|
2013-04-27 19:41:57 +00:00
|
|
|
|
2012-04-03 19:33:40 +00:00
|
|
|
void updateData()
|
|
|
|
{
|
2013-03-31 20:27:21 +00:00
|
|
|
//TexturesDefinitionClass.copy(_original_layer, _preview_layer);
|
2012-04-03 19:33:40 +00:00
|
|
|
}
|
|
|
|
private:
|
2013-01-20 15:07:45 +00:00
|
|
|
Renderer* _renderer;
|
2013-11-16 18:12:42 +00:00
|
|
|
TextureLayerDefinition* _original_layer;
|
|
|
|
TextureLayerDefinition* _preview_layer;
|
2012-04-03 19:33:40 +00:00
|
|
|
};
|
2012-01-26 23:08:09 +00:00
|
|
|
|
|
|
|
/**************** Form ****************/
|
2013-04-27 19:41:57 +00:00
|
|
|
FormTextures::FormTextures(QWidget *parent) :
|
|
|
|
BaseFormLayer(parent)
|
2012-01-26 23:08:09 +00:00
|
|
|
{
|
2013-04-12 20:11:29 +00:00
|
|
|
addAutoPreset(tr("Rock"));
|
|
|
|
addAutoPreset(tr("Grass"));
|
|
|
|
addAutoPreset(tr("Sand"));
|
|
|
|
addAutoPreset(tr("Snow"));
|
|
|
|
|
2013-11-16 18:12:42 +00:00
|
|
|
_definition = new TexturesDefinition(NULL);
|
|
|
|
_layer = new TextureLayerDefinition(NULL);
|
2012-01-26 23:08:09 +00:00
|
|
|
|
2012-08-26 13:36:46 +00:00
|
|
|
_previewCoverage = new PreviewTexturesCoverage(this, _layer);
|
|
|
|
_previewColor = new PreviewTexturesColor(this, _layer);
|
|
|
|
addPreview(_previewCoverage, tr("Coverage preview"));
|
|
|
|
addPreview(_previewColor, tr("Lighted sample"));
|
2012-01-26 23:08:09 +00:00
|
|
|
|
2013-04-12 20:11:29 +00:00
|
|
|
addInputDouble(tr("Displacement height"), &_layer->displacement_height, 0.0, 0.1, 0.001, 0.01);
|
|
|
|
addInputDouble(tr("Displacement scaling"), &_layer->displacement_scaling, 0.003, 0.3, 0.003, 0.03);
|
2013-11-16 18:12:42 +00:00
|
|
|
addInputMaterial(tr("Material"), _layer->material);
|
2013-04-12 20:11:29 +00:00
|
|
|
/*addInputCurve(tr("Coverage by altitude"), _layer->terrain_zone->value_by_height, -20.0, 20.0, 0.0, 1.0, tr("Terrain altitude"), tr("Texture coverage"));
|
|
|
|
addInputCurve(tr("Coverage by slope"), _layer->terrain_zone->value_by_slope, 0.0, 5.0, 0.0, 1.0, tr("Terrain slope"), tr("Texture coverage"));*/
|
|
|
|
|
|
|
|
/*addInputDouble(tr("Amplitude for slope coverage"), &_layer->slope_range, 0.001, 0.1, 0.001, 0.01);
|
2012-08-26 13:06:42 +00:00
|
|
|
addInputDouble(tr("Layer thickness"), &_layer->thickness, 0.0, 0.1, 0.001, 0.01);
|
2013-03-31 20:27:21 +00:00
|
|
|
addInputDouble(tr("Transparency thickness"), &_layer->thickness_transparency, 0.0, 0.1, 0.001, 0.01);*/
|
2012-04-05 20:09:39 +00:00
|
|
|
|
2013-11-16 18:12:42 +00:00
|
|
|
setLayers(_definition);
|
2012-01-26 23:08:09 +00:00
|
|
|
}
|
|
|
|
|
2012-07-02 15:35:10 +00:00
|
|
|
FormTextures::~FormTextures()
|
|
|
|
{
|
2013-11-16 18:12:42 +00:00
|
|
|
delete _definition;
|
|
|
|
delete _layer;
|
2012-07-02 15:35:10 +00:00
|
|
|
}
|
|
|
|
|
2012-01-26 23:08:09 +00:00
|
|
|
void FormTextures::revertConfig()
|
|
|
|
{
|
2013-11-17 21:36:18 +00:00
|
|
|
RenderingScenery::getCurrent()->getTextures(_definition);
|
2012-08-26 13:06:42 +00:00
|
|
|
BaseFormLayer::revertConfig();
|
2012-01-26 23:08:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FormTextures::applyConfig()
|
|
|
|
{
|
2012-08-26 13:06:42 +00:00
|
|
|
BaseFormLayer::applyConfig();
|
2013-11-17 21:36:18 +00:00
|
|
|
RenderingScenery::getCurrent()->setTextures(_definition);
|
2012-07-05 17:05:03 +00:00
|
|
|
}
|
|
|
|
|
2012-12-06 14:04:04 +00:00
|
|
|
void FormTextures::layerReadCurrentFrom(void* layer_definition)
|
2012-04-03 19:33:40 +00:00
|
|
|
{
|
2013-11-16 18:12:42 +00:00
|
|
|
((TextureLayerDefinition*)layer_definition)->copy(_layer);
|
2012-04-03 19:33:40 +00:00
|
|
|
}
|
|
|
|
|
2012-12-06 14:04:04 +00:00
|
|
|
void FormTextures::layerWriteCurrentTo(void* layer_definition)
|
2012-04-03 19:33:40 +00:00
|
|
|
{
|
2013-11-16 18:12:42 +00:00
|
|
|
_layer->copy((TextureLayerDefinition*)layer_definition);
|
2013-03-31 20:27:21 +00:00
|
|
|
}
|
2012-12-06 14:04:04 +00:00
|
|
|
|
2013-03-31 20:27:21 +00:00
|
|
|
void FormTextures::autoPresetSelected(int preset)
|
|
|
|
{
|
2013-11-16 18:12:42 +00:00
|
|
|
_layer->applyPreset((TextureLayerDefinition::TextureLayerPreset)preset);
|
2013-03-31 20:27:21 +00:00
|
|
|
BaseForm::autoPresetSelected(preset);
|
2012-04-03 19:33:40 +00:00
|
|
|
}
|