Fixed and refactored terrain preview
This commit is contained in:
parent
79080c756f
commit
684a64158c
13 changed files with 97 additions and 91 deletions
|
@ -42,7 +42,6 @@ HEADERS += \
|
|||
terrain/paintingbrush.h \
|
||||
terrain/mainterrainform.h \
|
||||
common/freeformhelper.h \
|
||||
terrain/previewterrainshape.h \
|
||||
common/widgetsliderdecimal.h \
|
||||
terrain/widgetterrainbasenoisepreview.h \
|
||||
common/mainwindow.h \
|
||||
|
@ -91,7 +90,6 @@ SOURCES += \
|
|||
terrain/paintingbrush.cpp \
|
||||
terrain/mainterrainform.cpp \
|
||||
common/freeformhelper.cpp \
|
||||
terrain/previewterrainshape.cpp \
|
||||
common/widgetsliderdecimal.cpp \
|
||||
terrain/widgetterrainbasenoisepreview.cpp \
|
||||
common/mainwindow.cpp \
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <QMessageBox>
|
||||
#include "dialogbaseterrainnoise.h"
|
||||
#include "dialogterrainpainting.h"
|
||||
#include "previewterrainshape.h"
|
||||
#include "TerrainShapePreviewRenderer.h"
|
||||
#include "common/freeformhelper.h"
|
||||
#include "tools.h"
|
||||
#include "RenderingScenery.h"
|
||||
|
@ -25,7 +25,7 @@ MainTerrainForm::MainTerrainForm(QWidget *parent) :
|
|||
|
||||
_form_helper = new FreeFormHelper(this);
|
||||
|
||||
_renderer_shape = new PreviewTerrainShape(_terrain);
|
||||
_renderer_shape = new TerrainShapePreviewRenderer(_terrain);
|
||||
_form_helper->addPreview(ui->preview_shape, _renderer_shape);
|
||||
|
||||
_form_helper->addDoubleInputSlider(ui->input_scaling, &_terrain->scaling, 0.1, 3.0, 0.03, 0.3);
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
#include "previewterrainshape.h"
|
||||
|
||||
#include "SoftwareRenderer.h"
|
||||
#include "BasePreview.h"
|
||||
#include "water/public.h"
|
||||
|
||||
PreviewTerrainShape::PreviewTerrainShape(TerrainDefinition* terrain)
|
||||
{
|
||||
_terrain = terrain;
|
||||
_highlight_enabled = true;
|
||||
|
||||
terrainAlterPreviewRenderer(this);
|
||||
}
|
||||
|
||||
void PreviewTerrainShape::bindEvent(BasePreview* preview)
|
||||
{
|
||||
preview->addOsd(QString("geolocation"));
|
||||
//preview->addToggle("highlight", tr("Coverage highlight"), true);
|
||||
|
||||
preview->configScaling(20.0, 1000.0, 20.0, 200.0);
|
||||
preview->configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
||||
}
|
||||
|
||||
void PreviewTerrainShape::updateEvent()
|
||||
{
|
||||
TerrainRendererClass.bind(this, _terrain);
|
||||
}
|
||||
|
||||
Color PreviewTerrainShape::getColor2D(double x, double y, double scaling)
|
||||
{
|
||||
//return waterGetPreviewCoverage(this, x, y, scaling, _highlight_enabled ? 1 : 0);
|
||||
return COLOR_BLACK;
|
||||
}
|
||||
|
||||
void PreviewTerrainShape::toggleChangeEvent(QString key, bool value)
|
||||
{
|
||||
if (key == "highlight")
|
||||
{
|
||||
_highlight_enabled = value;
|
||||
}
|
||||
}
|
|
@ -1,17 +1,17 @@
|
|||
#include "public.h"
|
||||
#include "TerrainShapePreviewRenderer.h"
|
||||
|
||||
#include "../tools/lighting.h"
|
||||
#include "../renderer.h"
|
||||
#include "NoiseGenerator.h"
|
||||
#include "atmosphere/public.h"
|
||||
#include "textures/public.h"
|
||||
#include "TextureLayerDefinition.h"
|
||||
#include "TexturesDefinition.h"
|
||||
#include "TextureLayerDefinition.h"
|
||||
#include "Zone.h"
|
||||
#include "SurfaceMaterial.h"
|
||||
#include "NoiseGenerator.h"
|
||||
#include "BasePreview.h"
|
||||
|
||||
/*
|
||||
* Terrain previews.
|
||||
*/
|
||||
// TEMP
|
||||
#include "atmosphere/public.h"
|
||||
#include "tools/lighting.h"
|
||||
#include "textures/public.h"
|
||||
#include "water/public.h"
|
||||
|
||||
static void _getLightingStatus(Renderer*, LightStatus* status, Vector3, int)
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ static Vector3 _getCameraLocation(Renderer*, Vector3 location)
|
|||
return location;
|
||||
}
|
||||
|
||||
void terrainAlterPreviewRenderer(Renderer* renderer)
|
||||
static void _alterPreviewRenderer(Renderer* renderer)
|
||||
{
|
||||
renderer->render_quality = 3;
|
||||
renderer->getCameraLocation = _getCameraLocation;
|
||||
|
@ -67,13 +67,57 @@ void terrainAlterPreviewRenderer(Renderer* renderer)
|
|||
TexturesRendererClass.bind(renderer, &textures);
|
||||
}
|
||||
|
||||
Color terrainGetPreviewColor(Renderer* renderer, double x, double z, double detail)
|
||||
TerrainShapePreviewRenderer::TerrainShapePreviewRenderer(TerrainDefinition* terrain)
|
||||
{
|
||||
Vector3 point;
|
||||
_terrain = terrain;
|
||||
_highlight_enabled = true;
|
||||
|
||||
point.x = x;
|
||||
point.y = renderer->terrain->getHeight(renderer, x, z, 1);
|
||||
point.z = z;
|
||||
|
||||
return renderer->terrain->getFinalColor(renderer, point, detail);
|
||||
_alterPreviewRenderer(this);
|
||||
}
|
||||
|
||||
void TerrainShapePreviewRenderer::bindEvent(BasePreview* preview)
|
||||
{
|
||||
preview->addOsd(QString("geolocation"));
|
||||
//preview->addToggle("highlight", tr("Coverage highlight"), true);
|
||||
|
||||
preview->configScaling(20.0, 1000.0, 20.0, 200.0);
|
||||
preview->configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
||||
}
|
||||
|
||||
void TerrainShapePreviewRenderer::updateEvent()
|
||||
{
|
||||
TerrainRendererClass.bind(this, _terrain);
|
||||
}
|
||||
|
||||
Color TerrainShapePreviewRenderer::getColor2D(double x, double y, double)
|
||||
{
|
||||
double height;
|
||||
|
||||
height = terrain->getHeight(this, x, y, 1);
|
||||
if (height > terrain->getWaterHeight(this))
|
||||
{
|
||||
return terrain->getFinalColor(this, Vector3(x, height, y), 0.000001);
|
||||
}
|
||||
else
|
||||
{
|
||||
Color base;
|
||||
|
||||
base = water->getResult(this, x, y).final;
|
||||
|
||||
if (_highlight_enabled)
|
||||
{
|
||||
Color mask = {0.5, 0.5, 1.0, 0.5};
|
||||
colorMask(&base, &mask);
|
||||
}
|
||||
|
||||
return base;
|
||||
}
|
||||
}
|
||||
|
||||
void TerrainShapePreviewRenderer::toggleChangeEvent(QString key, bool value)
|
||||
{
|
||||
if (key == "highlight")
|
||||
{
|
||||
_highlight_enabled = value;
|
||||
}
|
||||
}
|
|
@ -1,15 +1,17 @@
|
|||
#ifndef PREVIEWTERRAINSHAPE_H
|
||||
#define PREVIEWTERRAINSHAPE_H
|
||||
#ifndef TERRAINSHAPEPREVIEWRENDERER_H
|
||||
#define TERRAINSHAPEPREVIEWRENDERER_H
|
||||
|
||||
#include "desktop_global.h"
|
||||
#include "preview_global.h"
|
||||
|
||||
#include "Base2dPreviewRenderer.h"
|
||||
#include "terrain/public.h"
|
||||
|
||||
class PreviewTerrainShape : public Base2dPreviewRenderer
|
||||
namespace paysages {
|
||||
namespace preview {
|
||||
|
||||
class TerrainShapePreviewRenderer : public Base2dPreviewRenderer
|
||||
{
|
||||
public:
|
||||
explicit PreviewTerrainShape(TerrainDefinition* terrain);
|
||||
explicit TerrainShapePreviewRenderer(TerrainDefinition* terrain);
|
||||
|
||||
protected:
|
||||
virtual void bindEvent(BasePreview* preview);
|
||||
|
@ -17,10 +19,14 @@ protected:
|
|||
virtual Color getColor2D(double x, double y, double scaling) override;
|
||||
virtual void toggleChangeEvent(QString key, bool value);
|
||||
|
||||
private:
|
||||
TerrainDefinition* _terrain;
|
||||
|
||||
private:
|
||||
bool _highlight_enabled;
|
||||
double _water_height;
|
||||
};
|
||||
|
||||
#endif // PREVIEWTERRAINSHAPE_H
|
||||
}
|
||||
}
|
||||
|
||||
#endif // TERRAINSHAPEPREVIEWRENDERER_H
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "BasePreview.h"
|
||||
#include "Scenery.h"
|
||||
#include "TerrainDefinition.h"
|
||||
|
||||
// TEMP
|
||||
#include "RenderingScenery.h"
|
||||
|
@ -9,11 +10,16 @@
|
|||
#include "water/public.h"
|
||||
|
||||
WaterCoveragePreviewRenderer::WaterCoveragePreviewRenderer(WaterDefinition* definition):
|
||||
definition(definition)
|
||||
TerrainShapePreviewRenderer(new TerrainDefinition(NULL)), definition(definition)
|
||||
{
|
||||
highlight = true;
|
||||
}
|
||||
|
||||
WaterCoveragePreviewRenderer::~WaterCoveragePreviewRenderer()
|
||||
{
|
||||
delete TerrainShapePreviewRenderer::_terrain;
|
||||
}
|
||||
|
||||
void WaterCoveragePreviewRenderer::bindEvent(BasePreview* preview)
|
||||
{
|
||||
preview->addOsd("geolocation");
|
||||
|
@ -27,11 +33,10 @@ void WaterCoveragePreviewRenderer::bindEvent(BasePreview* preview)
|
|||
|
||||
void WaterCoveragePreviewRenderer::updateEvent()
|
||||
{
|
||||
getScenery()->setTerrain(RenderingScenery::getCurrent()->getTerrain());
|
||||
getScenery()->setWater(definition);
|
||||
prepare();
|
||||
|
||||
terrainAlterPreviewRenderer(this);
|
||||
RenderingScenery::getCurrent()->getTerrain(_terrain);
|
||||
TerrainShapePreviewRenderer::updateEvent();
|
||||
}
|
||||
|
||||
Color WaterCoveragePreviewRenderer::getColor2D(double x, double y, double scaling)
|
||||
|
@ -41,7 +46,7 @@ Color WaterCoveragePreviewRenderer::getColor2D(double x, double y, double scalin
|
|||
height = terrain->getHeight(this, x, y, 1);
|
||||
if (height > terrain->getWaterHeight(this))
|
||||
{
|
||||
return terrainGetPreviewColor(this, x, y, scaling);
|
||||
return TerrainShapePreviewRenderer::getColor2D(x, y, scaling);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -3,15 +3,16 @@
|
|||
|
||||
#include "preview_global.h"
|
||||
|
||||
#include "Base2dPreviewRenderer.h"
|
||||
#include "TerrainShapePreviewRenderer.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace preview {
|
||||
|
||||
class PREVIEWSHARED_EXPORT WaterCoveragePreviewRenderer : public Base2dPreviewRenderer
|
||||
class PREVIEWSHARED_EXPORT WaterCoveragePreviewRenderer : public TerrainShapePreviewRenderer
|
||||
{
|
||||
public:
|
||||
WaterCoveragePreviewRenderer(WaterDefinition* definition);
|
||||
virtual ~WaterCoveragePreviewRenderer();
|
||||
|
||||
virtual void bindEvent(BasePreview* preview) override;
|
||||
virtual void updateEvent() override;
|
||||
|
|
|
@ -21,7 +21,8 @@ SOURCES += Base2dPreviewRenderer.cpp \
|
|||
CloudsCoveragePreviewRenderer.cpp \
|
||||
CloudsAspectPreviewRenderer.cpp \
|
||||
WaterCoveragePreviewRenderer.cpp \
|
||||
WaterAspectPreviewRenderer.cpp
|
||||
WaterAspectPreviewRenderer.cpp \
|
||||
TerrainShapePreviewRenderer.cpp
|
||||
|
||||
HEADERS += Base2dPreviewRenderer.h\
|
||||
preview_global.h \
|
||||
|
@ -33,7 +34,8 @@ HEADERS += Base2dPreviewRenderer.h\
|
|||
CloudsCoveragePreviewRenderer.h \
|
||||
CloudsAspectPreviewRenderer.h \
|
||||
WaterCoveragePreviewRenderer.h \
|
||||
WaterAspectPreviewRenderer.h
|
||||
WaterAspectPreviewRenderer.h \
|
||||
TerrainShapePreviewRenderer.h
|
||||
|
||||
unix:!symbian {
|
||||
maemo5 {
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace preview {
|
|||
class CloudsAspectPreviewRenderer;
|
||||
class WaterCoveragePreviewRenderer;
|
||||
class WaterAspectPreviewRenderer;
|
||||
class TerrainShapePreviewRenderer;
|
||||
}
|
||||
}
|
||||
using namespace paysages::preview;
|
||||
|
|
|
@ -19,7 +19,6 @@ SOURCES += main.cpp \
|
|||
clouds/clo_density.cpp \
|
||||
terrain/ter_render.cpp \
|
||||
terrain/ter_raster.cpp \
|
||||
terrain/ter_preview.cpp \
|
||||
terrain/ter_painting.cpp \
|
||||
textures/tex_tools.cpp \
|
||||
textures/tex_rendering.cpp \
|
||||
|
|
|
@ -14,13 +14,6 @@ typedef struct
|
|||
} RayCastingResult;
|
||||
typedef RayCastingResult (*FuncGeneralCastRay)(Renderer* renderer, Vector3 start, Vector3 direction);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double min_height;
|
||||
double max_height;
|
||||
double base_height;
|
||||
} HeightInfo;
|
||||
|
||||
typedef void* (*FuncObjectCreate)();
|
||||
typedef void (*FuncObjectDelete)(void* object);
|
||||
typedef void (*FuncObjectBind)(void* base, void* sub);
|
||||
|
|
|
@ -32,7 +32,4 @@ public:
|
|||
|
||||
RENDERINGSHARED_EXPORT extern StandardRenderer TerrainRendererClass;
|
||||
|
||||
RENDERINGSHARED_EXPORT void terrainAlterPreviewRenderer(Renderer* renderer);
|
||||
RENDERINGSHARED_EXPORT Color terrainGetPreviewColor(Renderer* renderer, double x, double z, double detail);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "../rendering_global.h"
|
||||
#include "../shared/types.h"
|
||||
#include "../tools/lighting.h"
|
||||
#include "TerrainDefinition.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue