Removed unused preview renderers
This commit is contained in:
parent
42d3ae4ceb
commit
a8ae50df94
33 changed files with 0 additions and 2943 deletions
|
@ -6,7 +6,6 @@ SUBDIRS = \
|
|||
basics \
|
||||
definition \
|
||||
render/software \
|
||||
render/preview \
|
||||
render/opengl \
|
||||
interface/commandline \
|
||||
interface/modeler
|
||||
|
|
|
@ -1,193 +0,0 @@
|
|||
#include "AtmosphereColorPreviewRenderer.h"
|
||||
|
||||
#include "SoftwareRenderer.h"
|
||||
#include "AtmosphereRenderer.h"
|
||||
#include "AtmosphereResult.h"
|
||||
#include "CameraDefinition.h"
|
||||
#include "SurfaceMaterial.h"
|
||||
#include "Scenery.h"
|
||||
#include "BasePreview.h"
|
||||
|
||||
/*
|
||||
* Atmosphere previews.
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Vector3 location;
|
||||
double size;
|
||||
} Mount;
|
||||
|
||||
#define MOUNTS_COUNT 11
|
||||
static Mount MOUNTS[MOUNTS_COUNT] = {
|
||||
{
|
||||
{2.0, 0.0, -6.0}, 4.0
|
||||
},
|
||||
{
|
||||
{-1.5, 0.0, -8.0}, 4.0
|
||||
},
|
||||
{
|
||||
{3.0, 0.0, -10.0}, 6.0
|
||||
},
|
||||
{
|
||||
{-8.0, 0.0, -15.0}, 6.0
|
||||
},
|
||||
{
|
||||
{10.0, 0.0, -20.0}, 6.0
|
||||
},
|
||||
{
|
||||
{-6.0, 0.0, -30.0}, 8.0
|
||||
},
|
||||
{
|
||||
{15.0, 0.0, -40.0}, 8.0
|
||||
},
|
||||
{
|
||||
{-20.0, 0.0, -50.0}, 8.0
|
||||
},
|
||||
{
|
||||
{10.0, 0.0, -60.0}, 10.0
|
||||
},
|
||||
{
|
||||
{-5.0, 0.0, -80.0}, 10.0
|
||||
},
|
||||
{
|
||||
{30.0, 0.0, -100.0}, 10.0
|
||||
},
|
||||
};
|
||||
|
||||
static SurfaceMaterial MOUNT_MATERIAL(Color(0.4, 0.4, 0.4, 1.0));
|
||||
|
||||
static inline int _rayIntersectsTriangle(Vector3 p, Vector3 d, Vector3 v0, Vector3 v1, Vector3 v2, Vector3* hit)
|
||||
{
|
||||
Vector3 e1, e2, h, s, q;
|
||||
double a, f, u, v, t;
|
||||
|
||||
e1 = v1.sub(v0);
|
||||
e2 = v2.sub(v0);
|
||||
|
||||
h = d.crossProduct(e2);
|
||||
a = e1.dotProduct(h);
|
||||
|
||||
if (a > -0.00001 && a < 0.00001)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
f = 1.0 / a;
|
||||
s = p.sub(v0);
|
||||
u = f * s.dotProduct(h);
|
||||
|
||||
if (u < 0.0 || u > 1.0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
q = s.crossProduct(e1);
|
||||
v = f * d.dotProduct(q);
|
||||
|
||||
if (v < 0.0 || u + v > 1.0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
t = f * e2.dotProduct(q);
|
||||
|
||||
if (t > 0.00001)
|
||||
{
|
||||
*hit = p.add(d.scale(t));
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static inline int _checkHitMountain(Vector3 eye, Vector3 direction, Mount mount, Vector3* hit)
|
||||
{
|
||||
Vector3 v0 = mount.location;
|
||||
Vector3 v1 = mount.location;
|
||||
Vector3 v2 = mount.location;
|
||||
v0.x -= mount.size;
|
||||
v1.x += mount.size;
|
||||
v2.y += mount.size;
|
||||
return _rayIntersectsTriangle(eye, direction, v0, v1, v2, hit);
|
||||
}
|
||||
|
||||
static inline int _checkHitGround(Vector3 eye, Vector3 direction, Vector3* hit)
|
||||
{
|
||||
if (direction.y > -0.0001)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
hit->x = eye.x - direction.x * eye.y / direction.y;
|
||||
hit->y = 0.0;
|
||||
hit->z = eye.z - direction.z * eye.y / direction.y;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static inline int _checkHit(Vector3 eye, Vector3 direction, Vector3* hit, Vector3* normal)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < MOUNTS_COUNT; i++)
|
||||
{
|
||||
if (_checkHitMountain(eye, direction, MOUNTS[i], hit))
|
||||
{
|
||||
*normal = VECTOR_SOUTH;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
*normal = VECTOR_UP;
|
||||
return _checkHitGround(eye, direction, hit);
|
||||
}
|
||||
|
||||
AtmosphereColorPreviewRenderer::AtmosphereColorPreviewRenderer(AtmosphereDefinition* definition, double heading):
|
||||
definition(definition), heading(heading)
|
||||
{
|
||||
getScenery()->getCamera()->setLocation(Vector3(0.0, 7.0, 0.0));
|
||||
render_camera->setLocation(Vector3(0.0, 7.0, 0.0));
|
||||
|
||||
disableClouds();
|
||||
}
|
||||
|
||||
void AtmosphereColorPreviewRenderer::bindEvent(BasePreview* preview)
|
||||
{
|
||||
preview->configHdrToneMapping(true);
|
||||
preview->configScaling(0.5, 5.0, 0.5, 2.5);
|
||||
}
|
||||
void AtmosphereColorPreviewRenderer::updateEvent()
|
||||
{
|
||||
getScenery()->setAtmosphere(definition);
|
||||
prepare();
|
||||
}
|
||||
|
||||
Color AtmosphereColorPreviewRenderer::getColor2D(double x, double y, double)
|
||||
{
|
||||
Vector3 eye(0.0, 7.0, 0.0);
|
||||
Vector3 direction = Vector3(x, -y, -1.0).normalize();
|
||||
Vector3 hit, normal;
|
||||
Matrix4 rotation;
|
||||
|
||||
rotation = Matrix4::newRotateY(heading);
|
||||
|
||||
if (_checkHit(eye, direction, &hit, &normal))
|
||||
{
|
||||
Color color;
|
||||
|
||||
normal = rotation.transform(normal);
|
||||
hit = rotation.transform(hit);
|
||||
|
||||
color = applyLightingToSurface(hit, normal, MOUNT_MATERIAL);
|
||||
return applyMediumTraversal(hit, color);
|
||||
}
|
||||
else
|
||||
{
|
||||
direction = rotation.transform(direction);
|
||||
|
||||
return getAtmosphereRenderer()->getSkyColor(direction).final;
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
#ifndef ATMOSPHERECOLORPREVIEWRENDERER_H
|
||||
#define ATMOSPHERECOLORPREVIEWRENDERER_H
|
||||
|
||||
#include "Base2dPreviewRenderer.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace preview {
|
||||
|
||||
class PREVIEWSHARED_EXPORT AtmosphereColorPreviewRenderer:public Base2dPreviewRenderer
|
||||
{
|
||||
public:
|
||||
AtmosphereColorPreviewRenderer(AtmosphereDefinition* definition, double heading);
|
||||
|
||||
void bindEvent(BasePreview* preview) override;
|
||||
void updateEvent() override;
|
||||
virtual Color getColor2D(double x, double y, double scaling) override;
|
||||
|
||||
private:
|
||||
AtmosphereDefinition* definition;
|
||||
double heading;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ATMOSPHERECOLORPREVIEWRENDERER_H
|
|
@ -1,39 +0,0 @@
|
|||
#include "Base2dPreviewRenderer.h"
|
||||
|
||||
#include "Scenery.h"
|
||||
#include "SoftwareRenderer.h"
|
||||
|
||||
Base2dPreviewRenderer::Base2dPreviewRenderer():
|
||||
SoftwareRenderer()
|
||||
{
|
||||
}
|
||||
|
||||
Base2dPreviewRenderer::~Base2dPreviewRenderer()
|
||||
{
|
||||
}
|
||||
|
||||
void Base2dPreviewRenderer::bindEvent(BasePreview*)
|
||||
{
|
||||
}
|
||||
|
||||
void Base2dPreviewRenderer::toggleChangeEvent(const std::string &, bool)
|
||||
{
|
||||
}
|
||||
|
||||
void Base2dPreviewRenderer::choiceChangeEvent(const std::string &, int)
|
||||
{
|
||||
}
|
||||
|
||||
void Base2dPreviewRenderer::updateEvent()
|
||||
{
|
||||
prepare();
|
||||
}
|
||||
|
||||
void Base2dPreviewRenderer::cameraEvent(double, double, double)
|
||||
{
|
||||
}
|
||||
|
||||
Color Base2dPreviewRenderer::getColor2D(double, double, double)
|
||||
{
|
||||
return COLOR_BLACK;
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
#ifndef BASE2DPREVIEWRENDERER_H
|
||||
#define BASE2DPREVIEWRENDERER_H
|
||||
|
||||
#include "preview_global.h"
|
||||
|
||||
#include "SoftwareRenderer.h"
|
||||
|
||||
#include "Color.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace preview {
|
||||
|
||||
class PREVIEWSHARED_EXPORT Base2dPreviewRenderer: protected SoftwareRenderer
|
||||
{
|
||||
|
||||
public:
|
||||
Base2dPreviewRenderer();
|
||||
virtual ~Base2dPreviewRenderer();
|
||||
|
||||
virtual void bindEvent(BasePreview* preview);
|
||||
|
||||
virtual void toggleChangeEvent(const std::string &key, bool value);
|
||||
virtual void choiceChangeEvent(const std::string &key, int position);
|
||||
|
||||
virtual void updateEvent();
|
||||
virtual void cameraEvent(double x, double y, double scaling);
|
||||
virtual Color getColor2D(double x, double y, double scaling);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // BASE2DPREVIEWRENDERER_H
|
File diff suppressed because it is too large
Load diff
|
@ -1,144 +0,0 @@
|
|||
#ifndef BASEPREVIEW_H
|
||||
#define BASEPREVIEW_H
|
||||
|
||||
#include "preview_global.h"
|
||||
|
||||
#include "DrawingWidget.h"
|
||||
#include <QImage>
|
||||
#include <QStringList>
|
||||
class QPainter;
|
||||
class QMutex;
|
||||
class QLabel;
|
||||
|
||||
namespace paysages {
|
||||
namespace preview {
|
||||
|
||||
class _ContextChoice
|
||||
{
|
||||
public:
|
||||
QString title;
|
||||
QStringList items;
|
||||
int current;
|
||||
};
|
||||
|
||||
class _ContextToggle
|
||||
{
|
||||
public:
|
||||
QString title;
|
||||
bool value;
|
||||
};
|
||||
|
||||
class PREVIEWSHARED_EXPORT BasePreview : public DrawingWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BasePreview(QWidget* parent);
|
||||
~BasePreview();
|
||||
|
||||
void setRenderer(Base2dPreviewRenderer* renderer);
|
||||
|
||||
virtual void savePack(PackStream* stream);
|
||||
virtual void loadPack(PackStream* stream);
|
||||
|
||||
static void initDrawers();
|
||||
static void stopDrawers();
|
||||
static void reviveAll();
|
||||
|
||||
void redraw();
|
||||
|
||||
QImage startChunkTransaction(int x, int y, int w, int h, int* revision);
|
||||
bool commitChunkTransaction(const QImage &chunk, int x, int y, int w, int h, int revision);
|
||||
void rollbackChunkTransaction();
|
||||
|
||||
QColor getPixelColor(int x, int y);
|
||||
|
||||
void addOsd(QString name);
|
||||
|
||||
void configHdrToneMapping(bool active);
|
||||
void configScaling(double min, double max, double step, double init, bool logarithmic = true);
|
||||
void configScrolling(double xmin, double xmax, double xinit, double ymin, double ymax, double yinit);
|
||||
|
||||
void addChoice(const QString &key, const QString &title, const QStringList &choices, int init_value);
|
||||
virtual void choiceChangeEvent(const QString &key, int position);
|
||||
|
||||
void addToggle(const QString &key, const QString &text, bool init_value);
|
||||
virtual void toggleChangeEvent(const QString &key, bool value);
|
||||
|
||||
protected:
|
||||
virtual void updateData();
|
||||
virtual void cameraEvent();
|
||||
virtual Color getColor(double x, double y);
|
||||
|
||||
double xoffset;
|
||||
double yoffset;
|
||||
double scaling;
|
||||
|
||||
private:
|
||||
void updateScaling();
|
||||
void updateChunks();
|
||||
void invalidatePixbuf(int value);
|
||||
|
||||
void timerEvent(QTimerEvent* event);
|
||||
void showEvent(QShowEvent* event);
|
||||
void resizeEvent(QResizeEvent* event);
|
||||
|
||||
void doDrawing(QPainter* painter);
|
||||
|
||||
void contextMenuEvent(QContextMenuEvent* event);
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
void mouseMoveEvent(QMouseEvent* event);
|
||||
void wheelEvent(QWheelEvent* event);
|
||||
void leaveEvent(QEvent* event);
|
||||
|
||||
QMutex* _lock_drawing;
|
||||
QImage* _pixbuf;
|
||||
QVector<PreviewOsd*> _osd;
|
||||
QHash<QString, _ContextChoice> _choices;
|
||||
QHash<QString, _ContextToggle> _toggles;
|
||||
|
||||
QLabel* _info;
|
||||
|
||||
Base2dPreviewRenderer* _renderer;
|
||||
|
||||
int _width;
|
||||
int _height;
|
||||
|
||||
int _revision;
|
||||
int _transactions_count;
|
||||
bool _redraw_requested;
|
||||
|
||||
int mousex;
|
||||
int mousey;
|
||||
|
||||
double scalingbase;
|
||||
|
||||
bool alive;
|
||||
bool _hdr_enabled;
|
||||
ColorProfile* _hdr_profile;
|
||||
|
||||
double conf_scroll_xmin;
|
||||
double conf_scroll_xmax;
|
||||
double conf_scroll_xinit;
|
||||
double conf_scroll_ymin;
|
||||
double conf_scroll_ymax;
|
||||
double conf_scroll_yinit;
|
||||
|
||||
double conf_scale_min;
|
||||
double conf_scale_max;
|
||||
double conf_scale_init;
|
||||
double conf_scale_step;
|
||||
bool conf_scroll_logarithmic;
|
||||
|
||||
signals:
|
||||
void contentChange();
|
||||
void redrawRequested();
|
||||
|
||||
private slots:
|
||||
void choiceSelected(QAction* action);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // BASEPREVIEW_H
|
|
@ -1,133 +0,0 @@
|
|||
#include "CloudsAspectPreviewRenderer.h"
|
||||
|
||||
#include "BasePreview.h"
|
||||
#include "Scenery.h"
|
||||
#include "clouds/BaseCloudsModel.h"
|
||||
#include "CloudsDefinition.h"
|
||||
#include "CloudLayerDefinition.h"
|
||||
#include "CloudsRenderer.h"
|
||||
#include "LightStatus.h"
|
||||
#include "LightComponent.h"
|
||||
#include "AtmosphereResult.h"
|
||||
|
||||
class FakeCloudModel:public BaseCloudsModel
|
||||
{
|
||||
public:
|
||||
FakeCloudModel(BaseCloudsModel* real_model):
|
||||
BaseCloudsModel(real_model->getLayer()), real_model(real_model)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~FakeCloudModel()
|
||||
{
|
||||
delete real_model;
|
||||
}
|
||||
|
||||
virtual void update()
|
||||
{
|
||||
real_model->update();
|
||||
}
|
||||
|
||||
virtual void getAltitudeRange(double *min_altitude, double *max_altitude) const
|
||||
{
|
||||
real_model->getAltitudeRange(min_altitude, max_altitude);
|
||||
}
|
||||
|
||||
virtual void getDetailRange(double *min_step, double *max_step) const
|
||||
{
|
||||
real_model->getDetailRange(min_step, max_step);
|
||||
*min_step *= 0.4;
|
||||
*max_step *= 0.4;
|
||||
}
|
||||
|
||||
virtual double getProbability(const Vector3 &location, double radius) const
|
||||
{
|
||||
return real_model->getProbability(location, radius);
|
||||
}
|
||||
|
||||
virtual Color filterLight(const Color &light, double length, double density) const
|
||||
{
|
||||
return real_model->filterLight(light, length, density);
|
||||
}
|
||||
|
||||
virtual Color applyLightExit(const Color &light, const Vector3 &light_direction, const Vector3 &direction_to_eye) const
|
||||
{
|
||||
return real_model->applyLightExit(light, light_direction, direction_to_eye);
|
||||
}
|
||||
|
||||
virtual double getDensity(const Vector3 &location) const override
|
||||
{
|
||||
Vector3 location_ext(location.x * 0.5, location.y, location.z * 0.5);
|
||||
double ymin, ymax, thickness;
|
||||
getAltitudeRange(&ymin, &ymax);
|
||||
thickness = ymax - ymin;
|
||||
|
||||
Vector3 center(0.0, ymin + thickness * 0.5, 0.0);
|
||||
double distance = 2.0 * location_ext.sub(center).getNorm() / thickness;
|
||||
double fallout = 0.7;
|
||||
if (distance > 1.0)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
else if (distance < 1.0 - fallout)
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
double factor = (1.0 - distance) / fallout;
|
||||
return real_model->getDensity(location_ext) * (1.0 - factor) + factor;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
BaseCloudsModel* real_model;
|
||||
};
|
||||
|
||||
CloudsAspectPreviewRenderer::CloudsAspectPreviewRenderer(CloudLayerDefinition* layer):
|
||||
layer(layer)
|
||||
{
|
||||
CloudsDefinition* clouds = getScenery()->getClouds();
|
||||
clouds->clear();
|
||||
clouds->addLayer();
|
||||
|
||||
render_quality = 6;
|
||||
}
|
||||
|
||||
void CloudsAspectPreviewRenderer::bindEvent(BasePreview* preview)
|
||||
{
|
||||
preview->configScaling(0.5, 2.0, 0.1, 2.0);
|
||||
preview->configHdrToneMapping(true);
|
||||
}
|
||||
|
||||
void CloudsAspectPreviewRenderer::updateEvent()
|
||||
{
|
||||
CloudLayerDefinition* preview_layer = getScenery()->getClouds()->getCloudLayer(0);
|
||||
layer->copy(preview_layer);
|
||||
preview_layer->coverage = 0.5;
|
||||
|
||||
prepare();
|
||||
|
||||
disableAtmosphere();
|
||||
BaseCloudsModel* real_model = getCloudsRenderer()->getLayerModel(0);
|
||||
getCloudsRenderer()->setLayerModel(0, new FakeCloudModel(real_model), false);
|
||||
}
|
||||
|
||||
Color CloudsAspectPreviewRenderer::getColor2D(double x, double y, double)
|
||||
{
|
||||
Vector3 start, end;
|
||||
BaseCloudsModel* model = getCloudsRenderer()->getLayerModel(0);
|
||||
double ymin, ymax, thickness;
|
||||
model->getAltitudeRange(&ymin, &ymax);
|
||||
thickness = ymax - ymin;
|
||||
|
||||
start.x = x * thickness;
|
||||
start.y = ymin + (1.0 - y) * thickness * 0.5;
|
||||
start.z = thickness;
|
||||
|
||||
end.x = start.x;
|
||||
end.y = start.y;
|
||||
end.z = -start.z;
|
||||
|
||||
return getCloudsRenderer()->getColor(start, end, COLOR_BLUE);
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
#ifndef CLOUDSASPECTPREVIEWRENDERER_H
|
||||
#define CLOUDSASPECTPREVIEWRENDERER_H
|
||||
|
||||
#include "preview_global.h"
|
||||
|
||||
#include "Base2dPreviewRenderer.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace preview {
|
||||
|
||||
class PREVIEWSHARED_EXPORT CloudsAspectPreviewRenderer : public Base2dPreviewRenderer
|
||||
{
|
||||
public:
|
||||
CloudsAspectPreviewRenderer(CloudLayerDefinition* layer);
|
||||
|
||||
virtual void bindEvent(BasePreview* preview) override;
|
||||
virtual void updateEvent() override;
|
||||
virtual Color getColor2D(double x, double y, double scaling) override;
|
||||
|
||||
private:
|
||||
CloudLayerDefinition* layer;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // CLOUDSASPECTPREVIEWRENDERER_H
|
|
@ -1,73 +0,0 @@
|
|||
#include "CloudsCoveragePreviewRenderer.h"
|
||||
|
||||
#include "BasePreview.h"
|
||||
#include "Scenery.h"
|
||||
#include "CloudsDefinition.h"
|
||||
#include "CloudLayerDefinition.h"
|
||||
#include "CloudsRenderer.h"
|
||||
|
||||
CloudsCoveragePreviewRenderer::CloudsCoveragePreviewRenderer(CloudLayerDefinition* layer):
|
||||
layer(layer)
|
||||
{
|
||||
perspective = true;
|
||||
|
||||
render_quality = 6;
|
||||
|
||||
CloudsDefinition* clouds = getScenery()->getClouds();
|
||||
clouds->clear();
|
||||
clouds->addLayer();
|
||||
}
|
||||
|
||||
void CloudsCoveragePreviewRenderer::bindEvent(BasePreview* preview)
|
||||
{
|
||||
preview->addToggle("3d", "Perspective", perspective);
|
||||
preview->configScaling(100.0, 1000.0, 20.0, 200.0);
|
||||
}
|
||||
|
||||
void CloudsCoveragePreviewRenderer::updateEvent()
|
||||
{
|
||||
layer->copy(getScenery()->getClouds()->getCloudLayer(0));
|
||||
prepare();
|
||||
}
|
||||
|
||||
Color CloudsCoveragePreviewRenderer::getColor2D(double x, double y, double scaling)
|
||||
{
|
||||
if (perspective)
|
||||
{
|
||||
Vector3 eye, look;
|
||||
|
||||
eye.x = 0.0;
|
||||
eye.y = scaling;
|
||||
eye.z = -10.0 * scaling;
|
||||
look.x = x * 0.01 / scaling;
|
||||
look.y = -(y * 0.01 - 0.3) / scaling;
|
||||
look.z = 1.0;
|
||||
look = look.normalize();
|
||||
|
||||
return getCloudsRenderer()->getColor(eye, eye.add(look.scale(1000.0)), COLOR_BLUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector3 start, end;
|
||||
|
||||
start.x = end.x = x;
|
||||
start.z = end.z = y;
|
||||
start.y = 1000.0;
|
||||
end.y = -1000.0;
|
||||
|
||||
return getCloudsRenderer()->getColor(start, end, COLOR_BLUE);
|
||||
}
|
||||
}
|
||||
|
||||
void CloudsCoveragePreviewRenderer::toggleChangeEvent(const std::string &key, bool value)
|
||||
{
|
||||
if (key == "3d")
|
||||
{
|
||||
perspective = value;
|
||||
}
|
||||
}
|
||||
|
||||
Color CloudsCoveragePreviewRenderer::applyLightingToSurface(const Vector3 &, const Vector3 &, const SurfaceMaterial &)
|
||||
{
|
||||
return COLOR_WHITE;
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
#ifndef CLOUDSCOVERAGEPREVIEWRENDERER_H
|
||||
#define CLOUDSCOVERAGEPREVIEWRENDERER_H
|
||||
|
||||
#include "preview_global.h"
|
||||
|
||||
#include "Base2dPreviewRenderer.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace preview {
|
||||
|
||||
class PREVIEWSHARED_EXPORT CloudsCoveragePreviewRenderer : public Base2dPreviewRenderer
|
||||
{
|
||||
public:
|
||||
CloudsCoveragePreviewRenderer(CloudLayerDefinition* layer);
|
||||
|
||||
virtual void bindEvent(BasePreview* preview) override;
|
||||
virtual void updateEvent() override;
|
||||
virtual Color getColor2D(double x, double y, double scaling) override;
|
||||
|
||||
virtual void toggleChangeEvent(const std::string &key, bool value) override;
|
||||
|
||||
virtual Color applyLightingToSurface(const Vector3 &location, const Vector3 &normal, const SurfaceMaterial &material) override;
|
||||
|
||||
private:
|
||||
bool perspective;
|
||||
CloudLayerDefinition* layer;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // CLOUDSCOVERAGEPREVIEWRENDERER_H
|
|
@ -1,23 +0,0 @@
|
|||
#include "DrawingWidget.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
|
||||
DrawingWidget::DrawingWidget(QWidget* parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void DrawingWidget::paintEvent(QPaintEvent*)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
QPainterPath mask;
|
||||
mask.addRoundedRect(rect(), 8.0, 8.0);
|
||||
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
painter.setClipPath(mask);
|
||||
painter.setRenderHint(QPainter::Antialiasing, false);
|
||||
|
||||
doDrawing(&painter);
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
#ifndef DRAWINGWIDGET_H
|
||||
#define DRAWINGWIDGET_H
|
||||
|
||||
#include "preview_global.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QPaintEvent;
|
||||
class QPainter;
|
||||
|
||||
namespace paysages {
|
||||
namespace preview {
|
||||
|
||||
class PREVIEWSHARED_EXPORT DrawingWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DrawingWidget(QWidget* parent = 0);
|
||||
protected:
|
||||
virtual void doDrawing(QPainter* painter) = 0;
|
||||
private:
|
||||
virtual void paintEvent(QPaintEvent* event);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* DRAWINGWIDGET_H */
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
#include "PreviewOsd.h"
|
||||
|
||||
#include <QImage>
|
||||
#include <QHash>
|
||||
#include <QPainter>
|
||||
#include "PreviewOsdItem.h"
|
||||
|
||||
static QHash<QString, PreviewOsd*> _instances;
|
||||
|
||||
/*************** PreviewOsd ***************/
|
||||
PreviewOsd::PreviewOsd()
|
||||
{
|
||||
}
|
||||
|
||||
PreviewOsd::~PreviewOsd()
|
||||
{
|
||||
for (int i = 0; i < _items.size(); i++)
|
||||
{
|
||||
delete _items[i];
|
||||
}
|
||||
}
|
||||
|
||||
PreviewOsd* PreviewOsd::getInstance(QString name)
|
||||
{
|
||||
if (_instances.contains(name))
|
||||
{
|
||||
return _instances[name];
|
||||
}
|
||||
else
|
||||
{
|
||||
PreviewOsd* instance = new PreviewOsd();
|
||||
_instances.insert(name, instance);
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewOsd::clearItems()
|
||||
{
|
||||
for (int i = 0; i < _items.size(); i++)
|
||||
{
|
||||
delete _items[i];
|
||||
}
|
||||
_items.clear();
|
||||
}
|
||||
|
||||
PreviewOsdItem* PreviewOsd::newItem(int width, int height)
|
||||
{
|
||||
PreviewOsdItem* item = new PreviewOsdItem(width, height);
|
||||
_items.append(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
PreviewOsdItem* PreviewOsd::newItem(const QImage &image)
|
||||
{
|
||||
PreviewOsdItem* item = newItem(image.width(), image.height());
|
||||
QPainter painter(item);
|
||||
painter.drawImage(0, 0, image);
|
||||
return item;
|
||||
}
|
||||
|
||||
void PreviewOsd::apply(QImage *mask, double xoffset, double yoffset, double scaling)
|
||||
{
|
||||
QPainter painter(mask);
|
||||
|
||||
for (int i = 0; i < _items.size(); i++)
|
||||
{
|
||||
PreviewOsdItem* item = _items[i];
|
||||
int x = (int) (mask->width() / 2 - (xoffset - item->xlocation()) / scaling - item->width() / 2);
|
||||
int y = (int) (mask->height() / 2 - (yoffset - item->ylocation()) / scaling - item->height() / 2);
|
||||
painter.drawImage(x, y, *item);
|
||||
}
|
||||
}
|
||||
|
||||
QString PreviewOsd::getToolTip(double x, double y, double scaling)
|
||||
{
|
||||
for (int i = 0; i < _items.size(); i++)
|
||||
{
|
||||
PreviewOsdItem* item = _items[i];
|
||||
QString tooltip = item->getToolTip(x, y, scaling);
|
||||
if (not tooltip.isEmpty())
|
||||
{
|
||||
return tooltip;
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
#ifndef PREVIEWOSD_H
|
||||
#define PREVIEWOSD_H
|
||||
|
||||
#include "preview_global.h"
|
||||
|
||||
#include <QVector>
|
||||
class QImage;
|
||||
|
||||
namespace paysages {
|
||||
namespace preview {
|
||||
|
||||
class PREVIEWSHARED_EXPORT PreviewOsd
|
||||
{
|
||||
public:
|
||||
PreviewOsd();
|
||||
~PreviewOsd();
|
||||
|
||||
static PreviewOsd* getInstance(QString name);
|
||||
|
||||
void clearItems();
|
||||
PreviewOsdItem* newItem(int width, int height);
|
||||
PreviewOsdItem* newItem(const QImage& image);
|
||||
void apply(QImage* mask, double xoffset, double yoffset, double scaling);
|
||||
QString getToolTip(double x, double y, double scaling);
|
||||
|
||||
private:
|
||||
QVector<PreviewOsdItem*> _items;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,52 +0,0 @@
|
|||
#include "PreviewOsdItem.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include "Vector3.h"
|
||||
#include "CameraDefinition.h"
|
||||
|
||||
PreviewOsdItem::PreviewOsdItem(int width, int height) : QImage(width, height, QImage::Format_ARGB32)
|
||||
{
|
||||
_xlocation = 0.0;
|
||||
_ylocation = 0.0;
|
||||
fill(0x00000000);
|
||||
}
|
||||
|
||||
void PreviewOsdItem::setLocation(double x, double y)
|
||||
{
|
||||
_xlocation = x;
|
||||
_ylocation = y;
|
||||
}
|
||||
|
||||
void PreviewOsdItem::drawCamera(CameraDefinition* camera)
|
||||
{
|
||||
Vector3 camera_location = camera->getLocation();
|
||||
VectorSpherical camera_direction = camera->getDirectionSpherical();
|
||||
int w2 = width() / 2;
|
||||
int h2 = height() / 2;
|
||||
|
||||
_xlocation = camera_location.x;
|
||||
_ylocation = camera_location.z;
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setPen(QPen(Qt::red, 2));
|
||||
painter.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing, true);
|
||||
painter.drawLine(w2, h2, w2 + w2 * cos(camera_direction.phi - M_PI_4), h2 - h2 * sin(camera_direction.phi - M_PI_4));
|
||||
painter.drawLine(w2, h2, w2 + w2 * cos(camera_direction.phi + M_PI_4), h2 - h2 * sin(camera_direction.phi + M_PI_4));
|
||||
}
|
||||
|
||||
void PreviewOsdItem::setToolTip(QString text)
|
||||
{
|
||||
_tooltip = text;
|
||||
}
|
||||
|
||||
QString PreviewOsdItem::getToolTip(double x, double y, double scaling)
|
||||
{
|
||||
if (_tooltip.isEmpty() or (x > _xlocation - (width() / 2) * scaling and x < _xlocation + (width() / 2) * scaling and y > _ylocation - (height() / 2) * scaling and y < _ylocation + (height() / 2) * scaling))
|
||||
{
|
||||
return _tooltip;
|
||||
}
|
||||
else
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
#ifndef PREVIEWOSDITEM_H
|
||||
#define PREVIEWOSDITEM_H
|
||||
|
||||
#include "preview_global.h"
|
||||
|
||||
#include <QImage>
|
||||
|
||||
namespace paysages {
|
||||
namespace preview {
|
||||
|
||||
class PREVIEWSHARED_EXPORT PreviewOsdItem:public QImage
|
||||
{
|
||||
public:
|
||||
PreviewOsdItem(int width, int height);
|
||||
|
||||
void setLocation(double x, double y);
|
||||
inline double xlocation() {return _xlocation;}
|
||||
inline double ylocation() {return _ylocation;}
|
||||
|
||||
void setToolTip(QString text);
|
||||
QString getToolTip(double x, double y, double scaling);
|
||||
|
||||
void drawCamera(CameraDefinition* camera);
|
||||
|
||||
private:
|
||||
double _xlocation;
|
||||
double _ylocation;
|
||||
QString _tooltip;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // PREVIEWOSDITEM_H
|
|
@ -1,97 +0,0 @@
|
|||
#include "SceneryTopDownPreviewRenderer.h"
|
||||
|
||||
#include "CloudsDefinition.h"
|
||||
#include "BasePreview.h"
|
||||
#include "Scenery.h"
|
||||
#include "TerrainRenderer.h"
|
||||
#include "WaterRenderer.h"
|
||||
#include "CloudsRenderer.h"
|
||||
#include "LightingManager.h"
|
||||
|
||||
SceneryTopDownPreviewRenderer::SceneryTopDownPreviewRenderer(Scenery* scenery):
|
||||
scenery(scenery)
|
||||
{
|
||||
clouds_enabled = true;
|
||||
render_quality = 3;
|
||||
}
|
||||
|
||||
void SceneryTopDownPreviewRenderer::bindEvent(BasePreview* preview)
|
||||
{
|
||||
no_clouds = new CloudsDefinition(NULL);
|
||||
clouds_enabled = true;
|
||||
|
||||
// TODO Translation
|
||||
preview->addOsd("geolocation");
|
||||
preview->addToggle("clouds", "Clouds", false);
|
||||
preview->addToggle("specularity", "Light reflection", false);
|
||||
|
||||
preview->configHdrToneMapping(true);
|
||||
preview->configScaling(0.5, 200.0, 3.0, 50.0);
|
||||
preview->configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
||||
}
|
||||
|
||||
void SceneryTopDownPreviewRenderer::updateEvent()
|
||||
{
|
||||
setScenery(scenery);
|
||||
|
||||
if (not clouds_enabled)
|
||||
{
|
||||
getScenery()->getClouds()->clear();
|
||||
}
|
||||
getLightingManager()->setSpecularity(specularity_enabled);
|
||||
|
||||
prepare();
|
||||
}
|
||||
|
||||
Color SceneryTopDownPreviewRenderer::getColor2D(double x, double y, double scaling)
|
||||
{
|
||||
Vector3 location;
|
||||
double height = getTerrainRenderer()->getHeight(x, y, true);
|
||||
|
||||
if (height < getWaterRenderer()->getHeightInfo().max_height)
|
||||
{
|
||||
return getWaterRenderer()->getResult(x, y).final;
|
||||
}
|
||||
else
|
||||
{
|
||||
location.x = x;
|
||||
location.y = height;
|
||||
location.z = y;
|
||||
return getTerrainRenderer()->getFinalColor(location, scaling);
|
||||
}
|
||||
}
|
||||
|
||||
void SceneryTopDownPreviewRenderer::toggleChangeEvent(const std::string &key, bool value)
|
||||
{
|
||||
if (key == "clouds")
|
||||
{
|
||||
clouds_enabled = value;
|
||||
}
|
||||
else if (key == "specularity")
|
||||
{
|
||||
specularity_enabled = value;
|
||||
}
|
||||
}
|
||||
|
||||
double SceneryTopDownPreviewRenderer::getPrecision(const Vector3 &)
|
||||
{
|
||||
return 0.0000001;
|
||||
}
|
||||
|
||||
Vector3 SceneryTopDownPreviewRenderer::getCameraLocation(const Vector3 &target)
|
||||
{
|
||||
return target.add(VECTOR_UP.scale(50.0));
|
||||
}
|
||||
|
||||
Color SceneryTopDownPreviewRenderer::applyMediumTraversal(Vector3 location, Color color)
|
||||
{
|
||||
if (clouds_enabled)
|
||||
{
|
||||
return getCloudsRenderer()->getColor(getCameraLocation(location), location, color);
|
||||
}
|
||||
else
|
||||
{
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
#ifndef SCENERYTOPDOWNPREVIEWRENDERER_H
|
||||
#define SCENERYTOPDOWNPREVIEWRENDERER_H
|
||||
|
||||
#include "preview_global.h"
|
||||
|
||||
#include "Base2dPreviewRenderer.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace preview {
|
||||
|
||||
class PREVIEWSHARED_EXPORT SceneryTopDownPreviewRenderer : public Base2dPreviewRenderer
|
||||
{
|
||||
public:
|
||||
SceneryTopDownPreviewRenderer(Scenery* scenery);
|
||||
|
||||
protected:
|
||||
virtual void bindEvent(BasePreview* preview) override;
|
||||
virtual void updateEvent() override;
|
||||
virtual Color getColor2D(double x, double y, double scaling) override;
|
||||
|
||||
virtual void toggleChangeEvent(const std::string &key, bool value) override;
|
||||
|
||||
virtual double getPrecision(const Vector3 &location) override;
|
||||
virtual Vector3 getCameraLocation(const Vector3 &target) override;
|
||||
virtual Color applyMediumTraversal(Vector3 location, Color color) override;
|
||||
|
||||
private:
|
||||
Scenery* scenery;
|
||||
bool clouds_enabled;
|
||||
bool specularity_enabled;
|
||||
CloudsDefinition* no_clouds;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SCENERYTOPDOWNPREVIEWRENDERER_H
|
|
@ -1,74 +0,0 @@
|
|||
#include "TerrainShapePreviewRenderer.h"
|
||||
|
||||
#include "TexturesDefinition.h"
|
||||
#include "TextureLayerDefinition.h"
|
||||
#include "Zone.h"
|
||||
#include "SurfaceMaterial.h"
|
||||
#include "NoiseGenerator.h"
|
||||
#include "BasePreview.h"
|
||||
#include "Scenery.h"
|
||||
#include "LightComponent.h"
|
||||
#include "LightStatus.h"
|
||||
#include "TerrainRenderer.h"
|
||||
|
||||
TerrainShapePreviewRenderer::TerrainShapePreviewRenderer(TerrainDefinition* terrain)
|
||||
{
|
||||
_terrain = terrain;
|
||||
|
||||
render_quality = 3;
|
||||
|
||||
disableClouds();
|
||||
|
||||
getScenery()->getTextures()->clear();
|
||||
getScenery()->getTextures()->addLayer();
|
||||
TextureLayerDefinition* layer = getScenery()->getTextures()->getTextureLayer(0);
|
||||
layer->terrain_zone->clear();
|
||||
layer->displacement_height = 0.0;
|
||||
layer->material->base = colorToHSL(COLOR_WHITE);
|
||||
layer->material->reflection = 0.05;
|
||||
layer->material->shininess = 2.0;
|
||||
layer->validate();
|
||||
layer->_detail_noise->clearLevels();
|
||||
}
|
||||
|
||||
Vector3 TerrainShapePreviewRenderer::getCameraLocation(const Vector3 &target)
|
||||
{
|
||||
return target.add(Vector3(-10.0, 15.0, 10.0));
|
||||
}
|
||||
|
||||
void TerrainShapePreviewRenderer::bindEvent(BasePreview* preview)
|
||||
{
|
||||
preview->addOsd(QString("geolocation"));
|
||||
|
||||
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()
|
||||
{
|
||||
getScenery()->setTerrain(_terrain);
|
||||
|
||||
prepare();
|
||||
|
||||
disableAtmosphere();
|
||||
}
|
||||
|
||||
Color TerrainShapePreviewRenderer::getColor2D(double x, double y, double scaling)
|
||||
{
|
||||
double height;
|
||||
|
||||
height = getTerrainRenderer()->getHeight(x, y, true);
|
||||
if (height > 0.0)
|
||||
{
|
||||
return getTerrainRenderer()->getFinalColor(Vector3(x, height, y), 0.000001);
|
||||
}
|
||||
else
|
||||
{
|
||||
return getWaterColor(x, y, scaling);
|
||||
}
|
||||
}
|
||||
|
||||
Color TerrainShapePreviewRenderer::getWaterColor(double, double, double)
|
||||
{
|
||||
return COLOR_BLUE;
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
#ifndef TERRAINSHAPEPREVIEWRENDERER_H
|
||||
#define TERRAINSHAPEPREVIEWRENDERER_H
|
||||
|
||||
#include "preview_global.h"
|
||||
|
||||
#include "Base2dPreviewRenderer.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace preview {
|
||||
|
||||
class PREVIEWSHARED_EXPORT TerrainShapePreviewRenderer : public Base2dPreviewRenderer
|
||||
{
|
||||
public:
|
||||
explicit TerrainShapePreviewRenderer(TerrainDefinition* terrain);
|
||||
|
||||
protected:
|
||||
virtual Vector3 getCameraLocation(const Vector3 &target) override;
|
||||
|
||||
virtual void bindEvent(BasePreview* preview) override;
|
||||
virtual void updateEvent() override;
|
||||
virtual Color getColor2D(double x, double y, double scaling) override;
|
||||
|
||||
virtual Color getWaterColor(double x, double y, double scaling);
|
||||
|
||||
TerrainDefinition* _terrain;
|
||||
|
||||
private:
|
||||
double _water_height;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // TERRAINSHAPEPREVIEWRENDERER_H
|
|
@ -1,51 +0,0 @@
|
|||
#include "TextureLayerAspectPreviewRenderer.h"
|
||||
|
||||
#include "Scenery.h"
|
||||
#include "BasePreview.h"
|
||||
#include "TexturesRenderer.h"
|
||||
|
||||
TextureLayerAspectPreviewRenderer::TextureLayerAspectPreviewRenderer():
|
||||
Base2dPreviewRenderer()
|
||||
{
|
||||
textures = NULL;
|
||||
|
||||
render_quality = 3;
|
||||
}
|
||||
|
||||
void TextureLayerAspectPreviewRenderer::setTextures(TexturesDefinition* textures)
|
||||
{
|
||||
this->textures = textures;
|
||||
}
|
||||
|
||||
void TextureLayerAspectPreviewRenderer::setLayer(int layer)
|
||||
{
|
||||
this->layer = layer;
|
||||
}
|
||||
|
||||
void TextureLayerAspectPreviewRenderer::bindEvent(BasePreview* preview)
|
||||
{
|
||||
preview->addOsd(QString("geolocation"));
|
||||
|
||||
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 TextureLayerAspectPreviewRenderer::updateEvent()
|
||||
{
|
||||
Base2dPreviewRenderer::updateEvent();
|
||||
|
||||
if (textures)
|
||||
{
|
||||
getScenery()->setTextures(textures);
|
||||
}
|
||||
|
||||
disableAtmosphere();
|
||||
disableClouds();
|
||||
}
|
||||
|
||||
Color TextureLayerAspectPreviewRenderer::getColor2D(double x, double y, double)
|
||||
{
|
||||
TexturesRenderer* textures_renderer = getTexturesRenderer();
|
||||
|
||||
return textures_renderer->applyToTerrain(x, y).final_color;
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
#ifndef TEXTURELAYERASPECTPREVIEWRENDERER_H
|
||||
#define TEXTURELAYERASPECTPREVIEWRENDERER_H
|
||||
|
||||
#include "preview_global.h"
|
||||
|
||||
#include "Base2dPreviewRenderer.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace preview {
|
||||
|
||||
class PREVIEWSHARED_EXPORT TextureLayerAspectPreviewRenderer: public Base2dPreviewRenderer
|
||||
{
|
||||
public:
|
||||
TextureLayerAspectPreviewRenderer();
|
||||
|
||||
void setTextures(TexturesDefinition* textures);
|
||||
void setLayer(int layer);
|
||||
|
||||
protected:
|
||||
virtual void bindEvent(BasePreview* preview);
|
||||
virtual void updateEvent();
|
||||
virtual Color getColor2D(double x, double y, double scaling);
|
||||
|
||||
private:
|
||||
TexturesDefinition* textures;
|
||||
int layer;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // TEXTURELAYERASPECTPREVIEWRENDERER_H
|
|
@ -1,59 +0,0 @@
|
|||
#include "TextureLayerCoveragePreviewRenderer.h"
|
||||
|
||||
#include "Scenery.h"
|
||||
#include "BasePreview.h"
|
||||
#include "TexturesRenderer.h"
|
||||
|
||||
TextureLayerCoveragePreviewRenderer::TextureLayerCoveragePreviewRenderer():
|
||||
Base2dPreviewRenderer()
|
||||
{
|
||||
textures = NULL;
|
||||
|
||||
render_quality = 3;
|
||||
}
|
||||
|
||||
void TextureLayerCoveragePreviewRenderer::setTextures(TexturesDefinition* textures)
|
||||
{
|
||||
this->textures = textures;
|
||||
}
|
||||
|
||||
void TextureLayerCoveragePreviewRenderer::setTerrain(TerrainDefinition *terrain)
|
||||
{
|
||||
getScenery()->setTerrain(terrain);
|
||||
}
|
||||
|
||||
void TextureLayerCoveragePreviewRenderer::setLayer(int layer)
|
||||
{
|
||||
this->layer = layer;
|
||||
}
|
||||
|
||||
void TextureLayerCoveragePreviewRenderer::bindEvent(BasePreview* preview)
|
||||
{
|
||||
preview->addOsd(QString("geolocation"));
|
||||
|
||||
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 TextureLayerCoveragePreviewRenderer::updateEvent()
|
||||
{
|
||||
Base2dPreviewRenderer::updateEvent();
|
||||
|
||||
if (textures)
|
||||
{
|
||||
getScenery()->setTextures(textures);
|
||||
}
|
||||
|
||||
disableAtmosphere();
|
||||
disableClouds();
|
||||
}
|
||||
|
||||
Color TextureLayerCoveragePreviewRenderer::getColor2D(double x, double y, double)
|
||||
{
|
||||
TexturesRenderer* textures_renderer = getTexturesRenderer();
|
||||
TerrainRenderer* terrain_renderer = getTerrainRenderer();
|
||||
|
||||
double presence = textures_renderer->getBasePresence(layer, terrain_renderer->getResult(x, y, true, false));
|
||||
|
||||
return Color(presence, presence, presence);
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
#ifndef TEXTURELAYERCOVERAGEPREVIEWRENDERER_H
|
||||
#define TEXTURELAYERCOVERAGEPREVIEWRENDERER_H
|
||||
|
||||
#include "preview_global.h"
|
||||
|
||||
#include "Base2dPreviewRenderer.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace preview {
|
||||
|
||||
class PREVIEWSHARED_EXPORT TextureLayerCoveragePreviewRenderer: public Base2dPreviewRenderer
|
||||
{
|
||||
public:
|
||||
TextureLayerCoveragePreviewRenderer();
|
||||
|
||||
void setTextures(TexturesDefinition* textures);
|
||||
void setTerrain(TerrainDefinition* terrain);
|
||||
void setLayer(int layer);
|
||||
|
||||
protected:
|
||||
virtual void bindEvent(BasePreview* preview);
|
||||
virtual void updateEvent();
|
||||
virtual Color getColor2D(double x, double y, double scaling);
|
||||
|
||||
private:
|
||||
TexturesDefinition* textures;
|
||||
int layer;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // TEXTURELAYERCOVERAGEPREVIEWRENDERER_H
|
|
@ -1,58 +0,0 @@
|
|||
#include "TexturesMixPreviewRenderer.h"
|
||||
|
||||
#include "Scenery.h"
|
||||
#include "BasePreview.h"
|
||||
#include "TerrainRenderer.h"
|
||||
|
||||
TexturesMixPreviewRenderer::TexturesMixPreviewRenderer():
|
||||
Base2dPreviewRenderer()
|
||||
{
|
||||
textures = NULL;
|
||||
|
||||
render_quality = 3;
|
||||
}
|
||||
|
||||
void TexturesMixPreviewRenderer::setTextures(TexturesDefinition* textures)
|
||||
{
|
||||
this->textures = textures;
|
||||
}
|
||||
|
||||
void TexturesMixPreviewRenderer::setTerrain(TerrainDefinition *terrain)
|
||||
{
|
||||
getScenery()->setTerrain(terrain);
|
||||
}
|
||||
|
||||
void TexturesMixPreviewRenderer::setLayer(int layer)
|
||||
{
|
||||
this->layer = layer;
|
||||
}
|
||||
|
||||
void TexturesMixPreviewRenderer::bindEvent(BasePreview* preview)
|
||||
{
|
||||
preview->addOsd(QString("geolocation"));
|
||||
|
||||
preview->configHdrToneMapping(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 TexturesMixPreviewRenderer::updateEvent()
|
||||
{
|
||||
Base2dPreviewRenderer::updateEvent();
|
||||
|
||||
if (textures)
|
||||
{
|
||||
getScenery()->setTextures(textures);
|
||||
}
|
||||
|
||||
disableAtmosphere();
|
||||
disableClouds();
|
||||
}
|
||||
|
||||
Color TexturesMixPreviewRenderer::getColor2D(double x, double y, double scaling)
|
||||
{
|
||||
TerrainRenderer* terrain_renderer = getTerrainRenderer();
|
||||
Vector3 location(x, terrain_renderer->getHeight(x, y, true), y);
|
||||
return terrain_renderer->getFinalColor(location, scaling);
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
#ifndef TEXTURESMIXPREVIEWRENDERER_H
|
||||
#define TEXTURESMIXPREVIEWRENDERER_H
|
||||
|
||||
#include "preview_global.h"
|
||||
|
||||
#include "Base2dPreviewRenderer.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace preview {
|
||||
|
||||
class PREVIEWSHARED_EXPORT TexturesMixPreviewRenderer:public Base2dPreviewRenderer
|
||||
{
|
||||
public:
|
||||
TexturesMixPreviewRenderer();
|
||||
|
||||
void setTextures(TexturesDefinition* textures);
|
||||
void setTerrain(TerrainDefinition* terrain);
|
||||
void setLayer(int layer);
|
||||
|
||||
protected:
|
||||
virtual void bindEvent(BasePreview* preview) override;
|
||||
virtual void updateEvent() override;
|
||||
virtual Color getColor2D(double x, double y, double scaling) override;
|
||||
|
||||
private:
|
||||
int layer;
|
||||
TexturesDefinition* textures;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // TEXTURESMIXPREVIEWRENDERER_H
|
|
@ -1,160 +0,0 @@
|
|||
#include "WaterAspectPreviewRenderer.h"
|
||||
|
||||
#include "BasePreview.h"
|
||||
#include "Scenery.h"
|
||||
#include "WaterDefinition.h"
|
||||
#include "CameraDefinition.h"
|
||||
#include "WaterRenderer.h"
|
||||
#include "LightComponent.h"
|
||||
|
||||
WaterAspectPreviewRenderer::WaterAspectPreviewRenderer(WaterDefinition* definition):
|
||||
definition(definition)
|
||||
{
|
||||
lighting = true;
|
||||
background = 2;
|
||||
|
||||
render_quality = 3;
|
||||
|
||||
customData[0] = &lighting;
|
||||
customData[1] = &background;
|
||||
}
|
||||
|
||||
void WaterAspectPreviewRenderer::bindEvent(BasePreview* preview)
|
||||
{
|
||||
preview->configScaling(10.0, 1000.0, 10.0, 250.0);
|
||||
//configScrolling(-30.0, 30.0, 0.0, -20.0, 20.0, 0.0);
|
||||
|
||||
// TODO Translation
|
||||
preview->addChoice("bg", "Background", QStringList("None") << "Grid" << "Sinusoid", 2);
|
||||
preview->addToggle("light", "Light reflection", true);
|
||||
|
||||
//preview->configHdrToneMapping(true);
|
||||
}
|
||||
|
||||
void WaterAspectPreviewRenderer::updateEvent()
|
||||
{
|
||||
getScenery()->setWater(definition);
|
||||
getScenery()->getCamera()->setTarget(VECTOR_ZERO);
|
||||
prepare();
|
||||
|
||||
LightComponent light;
|
||||
std::vector<LightComponent> lights;
|
||||
light.color = COLOR_WHITE;
|
||||
light.direction.x = 0.0;
|
||||
light.direction.y = -0.4794;
|
||||
light.direction.z = -0.8776;
|
||||
light.altered = 0;
|
||||
if (lighting)
|
||||
{
|
||||
light.reflection = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
light.reflection = 0.0;
|
||||
}
|
||||
lights.push_back(light);
|
||||
disableAtmosphere(lights);
|
||||
}
|
||||
|
||||
void WaterAspectPreviewRenderer::cameraEvent(double, double, double scaling)
|
||||
{
|
||||
Vector3 camera_location(0.0, scaling, -10.0 * scaling);
|
||||
getScenery()->getCamera()->setLocation(camera_location);
|
||||
render_camera->setLocation(camera_location);
|
||||
}
|
||||
|
||||
Color WaterAspectPreviewRenderer::getColor2D(double x, double y, double scaling)
|
||||
{
|
||||
Vector3 eye, look;
|
||||
double target_x, target_z;
|
||||
|
||||
eye = render_camera->getLocation();
|
||||
look = Vector3(x * 0.01 / scaling, -y * 0.01 / scaling - 0.3, 1.0).normalize();
|
||||
|
||||
if (look.y > -0.0001)
|
||||
{
|
||||
return rayWalking(eye, look, 0, 0, 0, 0).hit_color;
|
||||
}
|
||||
|
||||
target_x = eye.x - look.x * eye.y / look.y;
|
||||
target_z = eye.z - look.z * eye.y / look.y;
|
||||
|
||||
if (target_z > 0.0)
|
||||
{
|
||||
return rayWalking(eye, look, 0, 0, 0, 0).hit_color;
|
||||
}
|
||||
|
||||
return getWaterRenderer()->getResult(target_x, target_z).final;
|
||||
}
|
||||
|
||||
void WaterAspectPreviewRenderer::toggleChangeEvent(const std::string &key, bool value)
|
||||
{
|
||||
if (key == "light")
|
||||
{
|
||||
lighting = value;
|
||||
}
|
||||
}
|
||||
|
||||
void WaterAspectPreviewRenderer::choiceChangeEvent(const std::string &key, int position)
|
||||
{
|
||||
if (key == "bg")
|
||||
{
|
||||
background = position;
|
||||
}
|
||||
}
|
||||
|
||||
double WaterAspectPreviewRenderer::getPrecision(const Vector3 &)
|
||||
{
|
||||
return 0.000001;
|
||||
}
|
||||
|
||||
RayCastingResult WaterAspectPreviewRenderer::rayWalking(const Vector3 &location, const Vector3 &direction, int, int, int, int)
|
||||
{
|
||||
RayCastingResult result;
|
||||
double x, y;
|
||||
|
||||
result.hit = 1;
|
||||
if (direction.z < 0.0001)
|
||||
{
|
||||
result.hit_color = COLOR_WHITE;
|
||||
result.hit_location = location;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = location.x + direction.x * (0.0 - location.z) / direction.z;
|
||||
y = location.y + direction.y * (0.0 - location.z) / direction.z;
|
||||
|
||||
switch (background)
|
||||
{
|
||||
case 1:
|
||||
result.hit_color = (((int) ceil(x * 0.2) % 2 == 0) ^ ((int) ceil(y * 0.2 - 0.5) % 2 == 0)) ? COLOR_WHITE : COLOR_BLACK;
|
||||
break;
|
||||
case 2:
|
||||
result.hit_color = (y * 0.1 > x * 0.03 + sin(x - M_PI_2)) ? COLOR_WHITE : COLOR_BLACK;
|
||||
break;
|
||||
default:
|
||||
result.hit_color = COLOR_WHITE;
|
||||
}
|
||||
result.hit_location.x = x;
|
||||
result.hit_location.y = y;
|
||||
result.hit_location.z = 0.0;
|
||||
|
||||
if (result.hit_location.y < 0.0)
|
||||
{
|
||||
double lighting_depth = getScenery()->getWater()->lighting_depth;
|
||||
if (result.hit_location.y < -lighting_depth)
|
||||
{
|
||||
result.hit_color = COLOR_BLACK;
|
||||
}
|
||||
else
|
||||
{
|
||||
double attenuation = -result.hit_location.y / lighting_depth;
|
||||
result.hit_color.r *= 1.0 - attenuation;
|
||||
result.hit_color.g *= 1.0 - attenuation;
|
||||
result.hit_color.b *= 1.0 - attenuation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
#ifndef WATERASPECTPREVIEWRENDERER_H
|
||||
#define WATERASPECTPREVIEWRENDERER_H
|
||||
|
||||
#include "preview_global.h"
|
||||
|
||||
#include "Base2dPreviewRenderer.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace preview {
|
||||
|
||||
class PREVIEWSHARED_EXPORT WaterAspectPreviewRenderer : public Base2dPreviewRenderer
|
||||
{
|
||||
public:
|
||||
WaterAspectPreviewRenderer(WaterDefinition* definition);
|
||||
|
||||
virtual void bindEvent(BasePreview* preview) override;
|
||||
virtual void updateEvent() override;
|
||||
virtual void cameraEvent(double x, double y, double scaling) override;
|
||||
virtual Color getColor2D(double x, double y, double scaling) override;
|
||||
|
||||
virtual void toggleChangeEvent(const std::string &key, bool value) override;
|
||||
virtual void choiceChangeEvent(const std::string &key, int position) override;
|
||||
|
||||
virtual double getPrecision(const Vector3 &location) override;
|
||||
virtual RayCastingResult rayWalking(const Vector3 &location, const Vector3 &direction, int terrain, int water, int sky, int clouds) override;
|
||||
|
||||
private:
|
||||
WaterDefinition* definition;
|
||||
bool lighting;
|
||||
int background;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // WATERASPECTPREVIEWRENDERER_H
|
|
@ -1,63 +0,0 @@
|
|||
#include "WaterCoveragePreviewRenderer.h"
|
||||
|
||||
#include "BasePreview.h"
|
||||
#include "Scenery.h"
|
||||
#include "TerrainDefinition.h"
|
||||
#include "WaterRenderer.h"
|
||||
|
||||
WaterCoveragePreviewRenderer::WaterCoveragePreviewRenderer(WaterDefinition* definition):
|
||||
TerrainShapePreviewRenderer(new TerrainDefinition(NULL)), definition(definition)
|
||||
{
|
||||
highlight = true;
|
||||
}
|
||||
|
||||
WaterCoveragePreviewRenderer::~WaterCoveragePreviewRenderer()
|
||||
{
|
||||
delete TerrainShapePreviewRenderer::_terrain;
|
||||
}
|
||||
|
||||
void WaterCoveragePreviewRenderer::setTerrain(TerrainDefinition *terrain)
|
||||
{
|
||||
terrain->copy(TerrainShapePreviewRenderer::_terrain);
|
||||
getScenery()->setTerrain(terrain);
|
||||
}
|
||||
|
||||
void WaterCoveragePreviewRenderer::bindEvent(BasePreview* preview)
|
||||
{
|
||||
TerrainShapePreviewRenderer::bindEvent(preview);
|
||||
|
||||
// TODO Translation
|
||||
preview->addToggle("highlight", "Coverage highlight", true);
|
||||
|
||||
// TODO Keep camera above center (for reflections)
|
||||
}
|
||||
|
||||
void WaterCoveragePreviewRenderer::toggleChangeEvent(const std::string &key, bool value)
|
||||
{
|
||||
if (key == "highlight")
|
||||
{
|
||||
highlight = value;
|
||||
}
|
||||
}
|
||||
|
||||
void WaterCoveragePreviewRenderer::updateEvent()
|
||||
{
|
||||
getScenery()->setWater(definition);
|
||||
|
||||
TerrainShapePreviewRenderer::updateEvent();
|
||||
}
|
||||
|
||||
Color WaterCoveragePreviewRenderer::getWaterColor(double x, double y, double)
|
||||
{
|
||||
Color base;
|
||||
|
||||
base = getWaterRenderer()->getResult(x, y).final;
|
||||
|
||||
if (highlight)
|
||||
{
|
||||
Color mask = {0.5, 0.5, 1.0, 0.5};
|
||||
base.mask(mask);
|
||||
}
|
||||
|
||||
return base;
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
#ifndef WATERCOVERAGEPREVIEWRENDERER_H
|
||||
#define WATERCOVERAGEPREVIEWRENDERER_H
|
||||
|
||||
#include "preview_global.h"
|
||||
|
||||
#include "TerrainShapePreviewRenderer.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace preview {
|
||||
|
||||
class PREVIEWSHARED_EXPORT WaterCoveragePreviewRenderer : public TerrainShapePreviewRenderer
|
||||
{
|
||||
public:
|
||||
WaterCoveragePreviewRenderer(WaterDefinition* definition);
|
||||
virtual ~WaterCoveragePreviewRenderer();
|
||||
|
||||
void setTerrain(TerrainDefinition* terrain);
|
||||
|
||||
virtual void bindEvent(BasePreview* preview) override;
|
||||
virtual void updateEvent() override;
|
||||
|
||||
virtual Color getWaterColor(double x, double y, double scaling) override;
|
||||
|
||||
virtual void toggleChangeEvent(const std::string &key, bool value) override;
|
||||
|
||||
private:
|
||||
WaterDefinition* definition;
|
||||
bool highlight;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // WATERCOVERAGEPREVIEWRENDERER_H
|
|
@ -1,79 +0,0 @@
|
|||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2013-11-11T17:56:07
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
TARGET = paysages_render_preview
|
||||
TEMPLATE = lib
|
||||
QT += gui widgets
|
||||
|
||||
DEFINES += PREVIEW_LIBRARY
|
||||
|
||||
include(../../common.pri)
|
||||
|
||||
SOURCES += Base2dPreviewRenderer.cpp \
|
||||
AtmosphereColorPreviewRenderer.cpp \
|
||||
BasePreview.cpp \
|
||||
PreviewOsd.cpp \
|
||||
DrawingWidget.cpp \
|
||||
PreviewOsdItem.cpp \
|
||||
CloudsCoveragePreviewRenderer.cpp \
|
||||
CloudsAspectPreviewRenderer.cpp \
|
||||
WaterCoveragePreviewRenderer.cpp \
|
||||
WaterAspectPreviewRenderer.cpp \
|
||||
TerrainShapePreviewRenderer.cpp \
|
||||
SceneryTopDownPreviewRenderer.cpp \
|
||||
TexturesMixPreviewRenderer.cpp \
|
||||
TextureLayerCoveragePreviewRenderer.cpp \
|
||||
TextureLayerAspectPreviewRenderer.cpp
|
||||
|
||||
HEADERS += Base2dPreviewRenderer.h\
|
||||
preview_global.h \
|
||||
AtmosphereColorPreviewRenderer.h \
|
||||
BasePreview.h \
|
||||
PreviewOsd.h \
|
||||
DrawingWidget.h \
|
||||
PreviewOsdItem.h \
|
||||
CloudsCoveragePreviewRenderer.h \
|
||||
CloudsAspectPreviewRenderer.h \
|
||||
WaterCoveragePreviewRenderer.h \
|
||||
WaterAspectPreviewRenderer.h \
|
||||
TerrainShapePreviewRenderer.h \
|
||||
SceneryTopDownPreviewRenderer.h \
|
||||
TexturesMixPreviewRenderer.h \
|
||||
TextureLayerCoveragePreviewRenderer.h \
|
||||
TextureLayerAspectPreviewRenderer.h
|
||||
|
||||
unix:!symbian {
|
||||
maemo5 {
|
||||
target.path = /opt/usr/lib
|
||||
} else {
|
||||
target.path = /usr/lib
|
||||
}
|
||||
INSTALLS += target
|
||||
}
|
||||
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../system/release/ -lpaysages_system
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../system/debug/ -lpaysages_system
|
||||
else:unix: LIBS += -L$$OUT_PWD/../../system/ -lpaysages_system
|
||||
INCLUDEPATH += $$PWD/../../system
|
||||
DEPENDPATH += $$PWD/../../system
|
||||
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../basics/release/ -lpaysages_basics
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../basics/debug/ -lpaysages_basics
|
||||
else:unix: LIBS += -L$$OUT_PWD/../../basics/ -lpaysages_basics
|
||||
INCLUDEPATH += $$PWD/../../basics
|
||||
DEPENDPATH += $$PWD/../../basics
|
||||
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../definition/release/ -lpaysages_definition
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../definition/debug/ -lpaysages_definition
|
||||
else:unix: LIBS += -L$$OUT_PWD/../../definition/ -lpaysages_definition
|
||||
INCLUDEPATH += $$PWD/../../definition
|
||||
DEPENDPATH += $$PWD/../../definition
|
||||
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../software/release/ -lpaysages_render_software
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../software/debug/ -lpaysages_render_software
|
||||
else:unix: LIBS += -L$$OUT_PWD/../software/ -lpaysages_render_software
|
||||
INCLUDEPATH += $$PWD/../software
|
||||
DEPENDPATH += $$PWD/../software
|
|
@ -1,33 +0,0 @@
|
|||
#ifndef PREVIEW_GLOBAL_H
|
||||
#define PREVIEW_GLOBAL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#if defined(PREVIEW_LIBRARY)
|
||||
# define PREVIEWSHARED_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
# define PREVIEWSHARED_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#include "software_global.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace preview {
|
||||
class PreviewOsd;
|
||||
class PreviewOsdItem;
|
||||
class BasePreview;
|
||||
class Base2dPreviewRenderer;
|
||||
class AtmosphereColorPreviewRenderer;
|
||||
class CloudsCoveragePreviewRenderer;
|
||||
class CloudsAspectPreviewRenderer;
|
||||
class WaterCoveragePreviewRenderer;
|
||||
class WaterAspectPreviewRenderer;
|
||||
class TerrainShapePreviewRenderer;
|
||||
class TexturesMixPreviewRenderer;
|
||||
class TextureLayerCoveragePreviewRenderer;
|
||||
class TextureLayerAspectPreviewRenderer;
|
||||
}
|
||||
}
|
||||
using namespace paysages::preview;
|
||||
|
||||
#endif // PREVIEW_GLOBAL_H
|
Loading…
Reference in a new issue