Big WIP refactoring (preview + atmosphere renderer)

This commit is contained in:
Michaël Lemaire 2013-11-12 21:34:35 +01:00
parent dcc36990b7
commit d9f2f3878f
101 changed files with 718 additions and 448 deletions

View file

@ -14,6 +14,7 @@ namespace paysages {
namespace basics {
class Vector3;
class SpaceSegment;
class NoiseGenerator;
}
}
using namespace paysages::basics;

View file

@ -1,7 +1,6 @@
#ifndef DEFINITION_GLOBAL_H
#define DEFINITION_GLOBAL_H
/* Shared object helpers */
#include <QtCore/qglobal.h>
#if defined(DEFINITION_LIBRARY)
# define DEFINITIONSHARED_EXPORT Q_DECL_EXPORT
@ -9,15 +8,12 @@
# define DEFINITIONSHARED_EXPORT Q_DECL_IMPORT
#endif
/* Namespace using */
#include "basics_global.h"
namespace paysages
{
namespace system {}
namespace basics {}
namespace definition {}
}
using namespace paysages::system;
using namespace paysages::basics;
using namespace paysages::definition;
#endif // DEFINITION_GLOBAL_H

View file

@ -6,10 +6,10 @@
#include "basepreview.h"
#include "baseinput.h"
#include "dialoglayers.h"
#include "rendering/shared/types.h"
#include "rendering/tools/curve.h"
#include "rendering/tools/color.h"
#include "rendering/tools/lighting.h"
#include "shared/types.h"
#include "tools/curve.h"
#include "tools/color.h"
#include "tools/lighting.h"
class QPushButton;
class QComboBox;

View file

@ -11,10 +11,10 @@
#include <QLabel>
#include <QHash>
#include "editing/previewosd.h"
#include "editing/common/DrawingWidget.h"
#include "editing/common/previewrenderer.h"
#include "rendering/tools/color.h"
#include "previewosd.h"
#include "common/DrawingWidget.h"
#include "common/previewrenderer.h"
#include "tools/color.h"
namespace paysages {
namespace system {

View file

@ -12,7 +12,7 @@
#include "dialogrender.h"
#include "dialogexplorer.h"
#include "Scenery.h"
#include "rendering/renderer.h"
#include "renderer.h"
#include "tools.h"
Q_DECLARE_METATYPE(double*)

View file

@ -23,7 +23,7 @@
#include "dialogrender.h"
#include "dialogexplorer.h"
#include "rendering/main.h"
#include "main.h"
#include "Scenery.h"
#include "PackStream.h"
#include "tools.h"

View file

@ -1,17 +1,16 @@
#include "previewrenderer.h"
PreviewRenderer::PreviewRenderer(QObject *parent) :
QObject(parent)
#include "SoftwareRenderer.h"
PreviewRenderer::PreviewRenderer()
{
renderer = rendererCreate();
}
PreviewRenderer::~PreviewRenderer()
{
rendererDelete(renderer);
}
Color PreviewRenderer::getColor2D(double, double, double)
Color PreviewRenderer::getColor2D(double, double, double) const
{
return COLOR_BLACK;
}
@ -22,4 +21,5 @@ void PreviewRenderer::bindEvent(BasePreview*)
void PreviewRenderer::updateEvent()
{
renderer->prepare();
}

View file

@ -1,30 +1,22 @@
#ifndef PREVIEWRENDERER_H
#define PREVIEWRENDERER_H
#include <QObject>
#include "rendering/tools/color.h"
#include "rendering/renderer.h"
#include "rendering_global.h"
#include "Base2dPreviewRenderer.h"
#include "renderer.h"
class BasePreview;
class PreviewRenderer : public QObject
class PreviewRenderer : public Base2dPreviewRenderer
{
Q_OBJECT
public:
explicit PreviewRenderer(QObject *parent = 0);
~PreviewRenderer();
PreviewRenderer();
virtual ~PreviewRenderer();
virtual void bindEvent(BasePreview* preview);
virtual void updateEvent();
virtual Color getColor2D(double x, double y, double scaling);
signals:
public slots:
protected:
Renderer* renderer;
virtual Color getColor2D(double x, double y, double scaling) const override;
};
#endif // PREVIEWRENDERER_H

View file

@ -2,12 +2,13 @@
#define _PAYSAGES_QT_DIALOGCOLORGRADATION_H_
#include <QDialog>
#include <QPushButton>
#include "widgetcurveeditor.h"
#include "previewcolorgradation.h"
#include "rendering/tools/color.h"
#include "rendering/tools/curve.h"
#include "tools/color.h"
#include "tools/curve.h"
class QPushButton;
class DialogColorGradation : public QDialog
{

View file

@ -5,7 +5,7 @@
#include <QPushButton>
#include "widgetcurveeditor.h"
#include "rendering/tools/curve.h"
#include "tools/curve.h"
class DialogCurve : public QDialog
{

View file

@ -5,8 +5,8 @@
#include <QVBoxLayout>
#include <QLabel>
#include "WidgetExplorer.h"
#include "rendering/camera.h"
#include "rendering/renderer.h"
#include "camera.h"
#include "renderer.h"
DialogExplorer::DialogExplorer(QWidget* parent, CameraDefinition* camera, bool camera_validable, Renderer* renderer) : QDialog(parent)
{

View file

@ -2,17 +2,12 @@
#define _PAYSAGES_QT_DIALOGEXPLORER_H_
#include "editing_global.h"
#include <QDialog>
class CameraDefinition;
class Renderer;
namespace paysages {
namespace opengl {
class WidgetExplorer;
}
}
class DialogExplorer : public QDialog
{
Q_OBJECT

View file

@ -9,8 +9,8 @@
#include <QSlider>
#include <QScrollArea>
#include <QPushButton>
#include <math.h>
#include "rendering/tools/color.h"
#include <cmath>
#include "tools/color.h"
/**************** Previews ****************/
class PreviewLevel:public BasePreview

View file

@ -1,6 +1,6 @@
#include "dialogrender.h"
#include <math.h>
#include <cmath>
#include <QVBoxLayout>
#include <QImage>
#include <QColor>
@ -10,6 +10,12 @@
#include <QMessageBox>
#include <QListWidget>
#include <QPushButton>
#include <QMutex>
#include <QThread>
#include <QScrollArea>
#include <QLabel>
#include <QProgressBar>
#include <QComboBox>
#include "tools.h"
#include "Scenery.h"

View file

@ -1,17 +1,18 @@
#ifndef _PAYSAGES_QT_DIALOGRENDER_H_
#define _PAYSAGES_QT_DIALOGRENDER_H_
#include <time.h>
#include <ctime>
#include <QDialog>
#include <QThread>
#include <QProgressBar>
#include <QScrollArea>
#include <QSlider>
#include <QComboBox>
#include <QLabel>
#include <QMutex>
#include "rendering/renderer.h"
#include "rendering/tools/color.h"
#include "renderer.h"
#include "tools/color.h"
class QThread;
class QProgressBar;
class QSlider;
class QComboBox;
class QLabel;
class QScrollArea;
class QMutex;
class DialogRender : public QDialog
{

View file

@ -9,8 +9,6 @@ unix:LIBS += -lGLU
include(../common.pri)
INCLUDEPATH += $$PWD/..
HEADERS += \
terrain/widgetheightmap.h \
widgetcurveeditor.h \
@ -167,6 +165,12 @@ else:unix: LIBS += -L$$OUT_PWD/../render/software/ -lpaysages_render_software
INCLUDEPATH += $$PWD/../render/software
DEPENDPATH += $$PWD/../render/software
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../render/preview/release/ -lpaysages_render_preview
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../render/preview/debug/ -lpaysages_render_preview
else:unix: LIBS += -L$$OUT_PWD/../render/preview/ -lpaysages_render_preview
INCLUDEPATH += $$PWD/../render/preview
DEPENDPATH += $$PWD/../render/preview
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../render/opengl/release/ -lpaysages_render_opengl
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../render/opengl/debug/ -lpaysages_render_opengl
else:unix: LIBS += -L$$OUT_PWD/../render/opengl/ -lpaysages_render_opengl

View file

@ -1,18 +1,8 @@
#ifndef EDITING_GLOBAL_H
#define EDITING_GLOBAL_H
namespace paysages
{
namespace system {}
namespace basics {}
namespace definition {}
namespace software {}
namespace opengl {}
}
using namespace paysages::system;
using namespace paysages::basics;
using namespace paysages::definition;
using namespace paysages::software;
using namespace paysages::opengl;
#include "definition_global.h"
#include "software_global.h"
#include "opengl_global.h"
#endif // EDITING_GLOBAL_H

View file

@ -4,61 +4,44 @@
#include <QColor>
#include <QSlider>
#include <math.h>
#include <cmath>
#include "rendering/atmosphere/public.h"
#include "atmosphere/public.h"
#include "AtmosphereColorPreviewRenderer.h"
#include "Scenery.h"
#include "rendering/renderer.h"
#include "renderer.h"
static AtmosphereDefinition* _definition;
/**************** Previews ****************/
class PreviewSkyEast:public BasePreview
class PreviewSkyEast:public PreviewRenderer, public AtmosphereColorPreviewRenderer
{
public:
PreviewSkyEast(QWidget* parent):
BasePreview(parent)
void bindEvent(BasePreview* preview) override
{
_renderer = atmosphereCreatePreviewRenderer();
configHdrToneMapping(true);
configScaling(0.5, 5.0, 0.5, 2.5);
}
protected:
Color getColor(double x, double y)
{
return atmosphereGetPreview(_renderer, x, -y, -M_PI_2);
preview->configHdrToneMapping(true);
preview->configScaling(0.5, 5.0, 0.5, 2.5);
}
void updateData()
{
AtmosphereRendererClass.bind(_renderer, _definition);
/*AtmosphereRendererClass.bind(_renderer, _definition);
_renderer->prepare();*/
}
private:
Renderer* _renderer;
};
class PreviewSkyWest:public BasePreview
class PreviewSkyWest:public PreviewRenderer, public AtmosphereColorPreviewRenderer
{
public:
PreviewSkyWest(QWidget* parent):
BasePreview(parent)
void bindEvent(BasePreview* preview) override
{
_renderer = atmosphereCreatePreviewRenderer();
configHdrToneMapping(true);
configScaling(0.5, 5.0, 0.5, 2.5);
}
protected:
Color getColor(double x, double y)
{
return atmosphereGetPreview(_renderer, x, -y, M_PI_2);
preview->configHdrToneMapping(true);
preview->configScaling(0.5, 5.0, 0.5, 2.5);
}
void updateData()
{
AtmosphereRendererClass.bind(_renderer, _definition);
/*AtmosphereRendererClass.bind(_renderer, _definition);
_renderer->prepare();*/
}
private:
Renderer* _renderer;
};
/**************** Form ****************/
@ -73,9 +56,9 @@ FormAtmosphere::FormAtmosphere(QWidget *parent):
_definition = (AtmosphereDefinition*)AtmosphereDefinitionClass.create();
previewWest = new PreviewSkyWest(this);
previewWest = new BasePreview(this);
addPreview(previewWest, QString(tr("West preview")));
previewEast = new PreviewSkyEast(this);
previewEast = new BasePreview(this);
addPreview(previewEast, QString(tr("East preview")));
//addInputEnum(tr("Color model"), (int*)&_definition->model, QStringList(tr("Simplified model (with weather)")) << tr("Complex model"));

View file

@ -1,8 +1,8 @@
#include "formclouds.h"
#include "rendering/clouds/clo_preview.h"
#include "rendering/tools/color.h"
#include "rendering/tools/euclid.h"
#include "clouds/clo_preview.h"
#include "tools/color.h"
#include "tools/euclid.h"
#include "Scenery.h"
#include "tools.h"

View file

@ -4,7 +4,7 @@
#include <QWidget>
#include "basepreview.h"
#include "baseformlayer.h"
#include "rendering/clouds/public.h"
#include "clouds/public.h"
class FormClouds : public BaseFormLayer
{

View file

@ -5,11 +5,11 @@
#include "dialogrender.h"
#include "inputcamera.h"
#include "tools.h"
#include "rendering/render.h"
#include "rendering/atmosphere/public.h"
#include "rendering/clouds/public.h"
#include "rendering/terrain/public.h"
#include "rendering/water/public.h"
#include "render.h"
#include "atmosphere/public.h"
#include "clouds/public.h"
#include "terrain/public.h"
#include "water/public.h"
#include "Scenery.h"
#include "PackStream.h"
#include "SoftwareRenderer.h"
@ -21,7 +21,7 @@ public:
PreviewRenderLandscape(QWidget* parent) : BasePreview(parent)
{
_renderer = sceneryCreateStandardRenderer();
_renderer = new SoftwareRenderer();
_renderer->getCameraLocation = _getCameraLocation;
lightingManagerDisableSpecularity(_renderer->lighting);
@ -35,6 +35,12 @@ public:
configScaling(0.5, 200.0, 3.0, 50.0);
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
}
~PreviewRenderLandscape()
{
delete _renderer;
CloudsDefinitionClass.destroy(_no_clouds);
}
protected:
Color getColor(double x, double y)
@ -58,12 +64,14 @@ protected:
void updateData()
{
sceneryBindRenderer(_renderer);
_renderer->atmosphere->applyAerialPerspective = _applyAerialPerspective;
if (!_clouds_enabled)
{
CloudsRendererClass.bind(_renderer, _no_clouds);
}
_renderer->prepare();
_renderer->atmosphere->applyAerialPerspective = _applyAerialPerspective;
}
void toggleChangeEvent(QString key, bool value)

View file

@ -2,9 +2,9 @@
#define _PAYSAGES_QT_FORMRENDER_H_
#include "baseform.h"
#include "rendering/camera.h"
#include "rendering/renderer.h"
#include "rendering/render.h"
#include "camera.h"
#include "renderer.h"
#include "render.h"
class FormRender : public BaseForm
{

View file

@ -4,7 +4,7 @@
#include <QWidget>
#include "basepreview.h"
#include "baseformlayer.h"
#include "rendering/textures/public.h"
#include "textures/public.h"
class FormTextures : public BaseFormLayer
{

View file

@ -3,14 +3,14 @@
#include <QColor>
#include <QSlider>
#include <math.h>
#include <cmath>
#include "rendering/tools/euclid.h"
#include "rendering/tools/lighting.h"
#include "rendering/renderer.h"
#include "rendering/water/public.h"
#include "rendering/terrain/public.h"
#include "rendering/atmosphere/public.h"
#include "tools/euclid.h"
#include "tools/lighting.h"
#include "renderer.h"
#include "water/public.h"
#include "terrain/public.h"
#include "atmosphere/public.h"
#include "tools.h"
#include "Scenery.h"
@ -23,7 +23,8 @@ public:
PreviewWaterCoverage(QWidget* parent) : BasePreview(parent)
{
_renderer = waterCreatePreviewCoverageRenderer();
_renderer = rendererCreate();
waterAlterPreviewCoverageRenderer(_renderer);
_highlight_enabled = true;
addOsd(QString("geolocation"));

View file

@ -4,7 +4,7 @@
#include <QWidget>
#include "baseinput.h"
#include "rendering/camera.h"
#include "camera.h"
class InputCamera:public BaseInput
{

View file

@ -5,8 +5,8 @@
#include <QPainter>
#include <QColorDialog>
#include "editing/lighting/SmallPreviewColor.h"
#include "editing/tools.h"
#include "lighting/SmallPreviewColor.h"
#include "tools.h"
InputColor::InputColor(QWidget* form, QString label, Color* value):
BaseInput(form, label),

View file

@ -4,7 +4,7 @@
#include <QWidget>
#include "baseinput.h"
#include "rendering/shared/types.h"
#include "shared/types.h"
class InputColor:public BaseInput
{

View file

@ -4,7 +4,7 @@
#include <QWidget>
#include "baseinput.h"
#include "rendering/tools/color.h"
#include "tools/color.h"
class InputColorGradation:public BaseInput
{

View file

@ -4,7 +4,7 @@
#include <QWidget>
#include "baseinput.h"
#include "rendering/tools/curve.h"
#include "tools/curve.h"
class InputCurve:public BaseInput
{

View file

@ -5,8 +5,8 @@
#include <QPainter>
#include <QColorDialog>
#include "editing/lighting/DialogMaterialEditor.h"
#include "editing/previewmaterial.h"
#include "lighting/DialogMaterialEditor.h"
#include "previewmaterial.h"
InputMaterial::InputMaterial(QWidget* form, QString label, SurfaceMaterial* value) : BaseInput(form, label)
{

View file

@ -4,8 +4,7 @@
#include <QWidget>
#include "baseinput.h"
#include "rendering/shared/types.h"
#include "rendering/tools/lighting.h"
#include "tools/lighting.h"
class InputMaterial:public BaseInput
{

View file

@ -1,7 +1,7 @@
#include "DialogMaterialEditor.h"
#include "ui_DialogMaterialEditor.h"
#include "editing/common/freeformhelper.h"
#include "common/freeformhelper.h"
DialogMaterialEditor::DialogMaterialEditor(QWidget *parent, SurfaceMaterial* material) :
QDialog(parent),

View file

@ -3,10 +3,10 @@
#include <QDialog>
#include "editing/previewmaterial.h"
#include "previewmaterial.h"
#include "rendering/tools/lighting.h"
#include "rendering/renderer.h"
#include "tools/lighting.h"
#include "renderer.h"
namespace Ui {
class DialogMaterialEditor;

View file

@ -2,7 +2,7 @@
#include <QPainter>
#include "editing/tools.h"
#include "tools.h"
SmallPreviewColor::SmallPreviewColor(QWidget* parent, Color* color) : DrawingWidget(parent)
{

View file

@ -1,9 +1,9 @@
#ifndef SMALLPREVIEWCOLOR_H
#define SMALLPREVIEWCOLOR_H
#include "editing/common/DrawingWidget.h"
#include "common/DrawingWidget.h"
#include "rendering/tools/color.h"
#include "tools/color.h"
class SmallPreviewColor: public DrawingWidget
{

View file

@ -2,7 +2,7 @@
#include <QPainter>
#include "editing/tools.h"
#include "tools.h"
SmallPreviewHues::SmallPreviewHues(QWidget* parent) : DrawingWidget(parent)
{

View file

@ -1,9 +1,7 @@
#ifndef SMALLPREVIEWHUES_H
#define SMALLPREVIEWHUES_H
#include "editing/common/DrawingWidget.h"
#include "rendering/tools/color.h"
#include "common/DrawingWidget.h"
class SmallPreviewHues: public DrawingWidget
{

View file

@ -3,7 +3,7 @@
#include <QWidget>
#include "rendering/tools/color.h"
#include "tools/color.h"
typedef enum
{

View file

@ -1,11 +1,12 @@
#include "previewmaterial.h"
#include <math.h>
#include <cmath>
#include <QPainter>
#include "tools.h"
#include "SoftwareRenderer.h"
#include "rendering/tools/lighting.h"
#include "rendering/tools/color.h"
#include "tools/lighting.h"
#include "tools/color.h"
/***** Shared renderer *****/
MaterialPreviewRenderer::MaterialPreviewRenderer(SurfaceMaterial* material)

View file

@ -2,13 +2,12 @@
#define _PAYSAGES_QT_PREVIEWMATERIAL_H_
#include "basepreview.h"
#include "editing/common/previewrenderer.h"
#include "common/previewrenderer.h"
#include "rendering/tools/lighting.h"
#include "rendering/renderer.h"
#include "tools/lighting.h"
#include "renderer.h"
class MaterialPreviewRenderer:public PreviewRenderer {
Q_OBJECT
public:
MaterialPreviewRenderer(SurfaceMaterial* material);
~MaterialPreviewRenderer();

View file

@ -2,7 +2,7 @@
#define _PAYSAGES_QT_PREVIEWOSD_H_
#include <QImage>
#include "rendering/camera.h"
#include "camera.h"
class PreviewOsdItem:public QImage
{

View file

@ -3,7 +3,7 @@
#include <QDialog>
#include "paintingbrush.h"
#include "rendering/terrain/public.h"
#include "terrain/public.h"
namespace Ui {
class DialogTerrainPainting;

View file

@ -7,7 +7,7 @@
#include "previewterrainshape.h"
#include "tools.h"
#include "Scenery.h"
#include "rendering/textures/public.h"
#include "textures/public.h"
MainTerrainForm::MainTerrainForm(QWidget *parent) :
QWidget(parent),

View file

@ -3,7 +3,7 @@
#include <QWidget>
#include "common/freeformhelper.h"
#include "rendering/terrain/public.h"
#include "terrain/public.h"
namespace Ui {
class MainTerrainForm;

View file

@ -1,6 +1,7 @@
#include "paintingbrush.h"
#include <cmath>
#include <QAbstractSlider>
#include "NoiseGenerator.h"
PaintingBrush::PaintingBrush()

View file

@ -1,14 +1,15 @@
#ifndef PAINTINGBRUSH_H
#define PAINTINGBRUSH_H
#include <QAbstractSlider>
#include "rendering/terrain/public.h"
#include "terrain/public.h"
namespace paysages {
namespace basics {
class NoiseGenerator;
}
}
class QAbstractSlider;
class QWidget;
typedef enum
{

View file

@ -1,16 +1,15 @@
#include "previewterrainshape.h"
#include "SoftwareRenderer.h"
#include "basepreview.h"
#include "rendering/water/public.h"
#include "water/public.h"
PreviewTerrainShape::PreviewTerrainShape(TerrainDefinition* terrain)
{
_terrain = terrain;
_highlight_enabled = true;
// TODO Don't delete the base renderer, just alter it
rendererDelete(renderer);
renderer = terrainCreatePreviewRenderer();
terrainAlterPreviewRenderer(renderer);
}
void PreviewTerrainShape::bindEvent(BasePreview* preview)
@ -27,7 +26,7 @@ void PreviewTerrainShape::updateEvent()
TerrainRendererClass.bind(renderer, _terrain);
}
Color PreviewTerrainShape::getColor2D(double x, double y, double scaling)
Color PreviewTerrainShape::getColor2D(double x, double y, double scaling) const
{
return waterGetPreviewCoverage(renderer, x, y, scaling, _highlight_enabled ? 1 : 0);
}

View file

@ -2,19 +2,18 @@
#define PREVIEWTERRAINSHAPE_H
#include "common/previewrenderer.h"
#include "rendering/renderer.h"
#include "rendering/terrain/public.h"
#include "renderer.h"
#include "terrain/public.h"
class PreviewTerrainShape : public PreviewRenderer
{
Q_OBJECT
public:
explicit PreviewTerrainShape(TerrainDefinition* terrain);
protected:
virtual void bindEvent(BasePreview* preview);
virtual void updateEvent();
virtual Color getColor2D(double x, double y, double scaling);
virtual Color getColor2D(double x, double y, double scaling) const override;
virtual void toggleChangeEvent(QString key, bool value);
private:

View file

@ -7,7 +7,7 @@
#include <GL/glu.h>
#include "tools.h"
#include "Scenery.h"
#include "rendering/water/public.h"
#include "water/public.h"
#define HEIGHTMAP_RESOLUTION 256

View file

@ -4,10 +4,10 @@
#include <QGLWidget>
#include <QDateTime>
#include "terrain/paintingbrush.h"
#include "rendering/camera.h"
#include "rendering/tools/euclid.h"
#include "rendering/renderer.h"
#include "rendering/terrain/public.h"
#include "camera.h"
#include "tools/euclid.h"
#include "renderer.h"
#include "terrain/public.h"
typedef struct
{

View file

@ -2,16 +2,10 @@
#define _PAYSAGES_EDITING_TERRAIN_WIDGETTERRAINBASENOISEPREVIEW_H_
#include "editing_global.h"
#include "editing/common/DrawingWidget.h"
#include "common/DrawingWidget.h"
class QPainter;
namespace paysages {
namespace basics {
class NoiseGenerator;
}
}
class WidgetTerrainBaseNoisePreview : public DrawingWidget
{
Q_OBJECT

View file

@ -2,7 +2,7 @@
#define DIALOGTEXTURESLAYER_H
#include <QDialog>
#include "rendering/textures/public.h"
#include "textures/public.h"
namespace Ui {
class DialogTexturesLayer;

View file

@ -1,7 +1,8 @@
#include "PreviewCumul.h"
#include "editing/basepreview.h"
#include "rendering/textures/tex_preview.h"
#include "SoftwareRenderer.h"
#include "basepreview.h"
#include "textures/tex_preview.h"
void PreviewCumul::setTextures(TexturesDefinition* textures)
{

View file

@ -1,7 +1,7 @@
#ifndef EDITING_TEXTURES_PREVIEWCUMUL_H
#define EDITING_TEXTURES_PREVIEWCUMUL_H
#include "editing/common/previewrenderer.h"
#include "common/previewrenderer.h"
class BasePreview;
class TexturesDefinition;
@ -9,8 +9,8 @@ class TexturesDefinition;
class PreviewCumul : public PreviewRenderer
{
public:
explicit PreviewCumul(QObject *parent = 0):
PreviewRenderer(parent),textures(0){}
explicit PreviewCumul():
PreviewRenderer(),textures(0){}
void setTextures(TexturesDefinition* textures);
void setLayer(int layer);

View file

@ -1,7 +1,8 @@
#include "PreviewLayerCoverage.h"
#include "editing/basepreview.h"
#include "rendering/textures/tex_preview.h"
#include "SoftwareRenderer.h"
#include "basepreview.h"
#include "textures/tex_preview.h"
void PreviewLayerCoverage::setTextures(TexturesDefinition* textures)
{

View file

@ -1,7 +1,7 @@
#ifndef EDITING_TEXTURES_PREVIEWLAYERCOVERAGE_H
#define EDITING_TEXTURES_PREVIEWLAYERCOVERAGE_H
#include "editing/common/previewrenderer.h"
#include "common/previewrenderer.h"
class BasePreview;
class TexturesDefinition;
@ -9,8 +9,8 @@ class TexturesDefinition;
class PreviewLayerCoverage : public PreviewRenderer
{
public:
explicit PreviewLayerCoverage(QObject *parent = 0):
PreviewRenderer(parent),textures(0){}
explicit PreviewLayerCoverage():
PreviewRenderer(),textures(0){}
void setTextures(TexturesDefinition* textures);
void setLayer(int layer);

View file

@ -1,7 +1,8 @@
#include "PreviewLayerLook.h"
#include "editing/basepreview.h"
#include "rendering/textures/tex_preview.h"
#include "SoftwareRenderer.h"
#include "basepreview.h"
#include "textures/tex_preview.h"
void PreviewLayerLook::setTextures(TexturesDefinition* textures)
{

View file

@ -1,7 +1,7 @@
#ifndef EDITING_TEXTURES_PREVIEWLAYERLOOK_H
#define EDITING_TEXTURES_PREVIEWLAYERLOOK_H
#include "editing/common/previewrenderer.h"
#include "common/previewrenderer.h"
class BasePreview;
class TexturesDefinition;
@ -9,8 +9,8 @@ class TexturesDefinition;
class PreviewLayerLook : public PreviewRenderer
{
public:
explicit PreviewLayerLook(QObject *parent = 0):
PreviewRenderer(parent),textures(0){}
explicit PreviewLayerLook():
PreviewRenderer(),textures(0){}
void setTextures(TexturesDefinition* textures);
void setLayer(int layer);

View file

@ -5,10 +5,10 @@
#include "../common/freelayerhelper.h"
#include "Scenery.h"
#include "previewmaterial.h"
#include "editing/textures/PreviewLayerCoverage.h"
#include "editing/textures/PreviewLayerLook.h"
#include "editing/textures/PreviewCumul.h"
#include "editing/textures/DialogTexturesLayer.h"
#include "textures/PreviewLayerCoverage.h"
#include "textures/PreviewLayerLook.h"
#include "textures/PreviewCumul.h"
#include "textures/DialogTexturesLayer.h"
MainTexturesForm::MainTexturesForm(QWidget *parent) : QWidget(parent), ui(new Ui::MainTexturesForm)
{

View file

@ -2,7 +2,7 @@
#define MAINTEXTURESFORM_H
#include <QWidget>
#include "rendering/textures/public.h"
#include "textures/public.h"
namespace Ui {
class MainTexturesForm;

View file

@ -5,8 +5,8 @@
#include <QDialog>
#include <QDir>
#include "rendering/shared/types.h"
#include "rendering/tools/color.h"
#include "shared/types.h"
#include "tools/color.h"
static inline QColor colorToQColor(Color color)
{

View file

@ -3,7 +3,7 @@
#include <QPainter>
#include <QPaintEngine>
#include <QMouseEvent>
#include "rendering/tools.h"
#include "tools.h"
WidgetCurveEditor::WidgetCurveEditor(QWidget *parent, double xmin, double xmax, double ymin, double ymax) : QWidget(parent)
{

View file

@ -3,7 +3,7 @@
#include <QWidget>
#include <QColor>
#include "rendering/tools/curve.h"
#include "tools/curve.h"
class WidgetCurveEditor : public QWidget
{

View file

@ -7,6 +7,7 @@ SUBDIRS = \
definition \
rendering \
render/software \
render/preview \
render/opengl \
editing \
controlling \

View file

@ -4,21 +4,15 @@
#include <GL/gl.h>
#include <GL/glu.h>
#include "Scenery.h"
#include "SoftwareRenderer.h"
#include "renderer.h"
#include "rendering/camera.h"
OpenGLRenderer::OpenGLRenderer(Scenery* scenery):
scenery(scenery)
{
if (scenery)
{
renderer = rendererCreate();
// TODO Bind scenery to renderer
}
else
{
renderer = sceneryCreateStandardRenderer();
}
renderer = new SoftwareRenderer(scenery);
renderer->prepare();
}
OpenGLRenderer::~OpenGLRenderer()

View file

@ -7,6 +7,7 @@
#include <GL/glu.h>
#include <QThread>
#include "Scenery.h"
#include "SoftwareRenderer.h"
#include "OpenGLRenderer.h"
#include "rendering/tools/euclid.h"
#include "rendering/renderer.h"
@ -87,10 +88,11 @@ QGLWidget(parent)
}
else
{
_renderer = sceneryCreateStandardRenderer();
_renderer = new SoftwareRenderer();
_renderer_created = true;
}
_opengl_renderer = new OpenGLRenderer(NULL);
_renderer->prepare();
_renderer->render_quality = 3;
_renderer->customData[2] = _base_camera;
_renderer->getCameraLocation = _getCameraLocation;

View file

@ -63,3 +63,9 @@ else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../rendering/deb
else:unix: LIBS += -L$$OUT_PWD/../../rendering/ -lpaysages_rendering
INCLUDEPATH += $$PWD/../../rendering
DEPENDPATH += $$PWD/../../rendering
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

View file

@ -9,8 +9,12 @@
# define OPENGLSHARED_EXPORT Q_DECL_IMPORT
#endif
#include "software_global.h"
namespace paysages {
namespace opengl {}
namespace opengl {
class WidgetExplorer;
}
}
using namespace paysages::opengl;

View file

@ -1,7 +1,9 @@
#include "public.h"
#include "AtmosphereColorPreviewRenderer.h"
#include "../renderer.h"
#include "rendering/camera.h"
#include "SoftwareRenderer.h"
#include "AtmosphereRenderer.h"
#include "camera.h"
#include "tools/lighting.h"
/*
* Atmosphere previews.
@ -142,7 +144,13 @@ static inline int _checkHit(Vector3 eye, Vector3 direction, Vector3* hit, Vector
return _checkHitGround(eye, direction, hit);
}
Color atmosphereGetPreview(Renderer* renderer, double x, double y, double heading)
AtmosphereColorPreviewRenderer::AtmosphereColorPreviewRenderer():
heading(0.0)
{
cameraSetLocation(renderer->render_camera, Vector3(0.0, 7.0, 0.0));
}
Color AtmosphereColorPreviewRenderer::getColor2D(double x, double y, double) const
{
Vector3 eye = {0.0, 7.0, 0.0};
Vector3 direction = {x, y, -1.0};
@ -168,13 +176,3 @@ Color atmosphereGetPreview(Renderer* renderer, double x, double y, double headin
return renderer->atmosphere->getSkyColor(renderer, direction).final;
}
}
Renderer* atmosphereCreatePreviewRenderer()
{
Renderer* result = rendererCreate();
Vector3 location = {0.0, 7.0, 0.0};
cameraSetLocation(result->render_camera, location);
return result;
}

View file

@ -0,0 +1,23 @@
#ifndef ATMOSPHERECOLORPREVIEWRENDERER_H
#define ATMOSPHERECOLORPREVIEWRENDERER_H
#include "Base2dPreviewRenderer.h"
namespace paysages {
namespace preview {
class AtmosphereColorPreviewRenderer:public Base2dPreviewRenderer
{
public:
AtmosphereColorPreviewRenderer();
virtual Color getColor2D(double x, double y, double scaling) const override;
protected:
double heading;
};
}
}
#endif // ATMOSPHERECOLORPREVIEWRENDERER_H

View file

@ -0,0 +1,18 @@
#include "Base2dPreviewRenderer.h"
#include "SoftwareRenderer.h"
Base2dPreviewRenderer::Base2dPreviewRenderer()
{
renderer = new SoftwareRenderer();
}
void Base2dPreviewRenderer::updateEvent()
{
delete renderer;
}
Color Base2dPreviewRenderer::getColor2D(double, double, double) const
{
return COLOR_BLACK;
}

View file

@ -0,0 +1,27 @@
#ifndef BASE2DPREVIEWRENDERER_H
#define BASE2DPREVIEWRENDERER_H
#include "preview_global.h"
#include "tools/color.h"
namespace paysages {
namespace preview {
class PREVIEWSHARED_EXPORT Base2dPreviewRenderer
{
public:
Base2dPreviewRenderer();
virtual void updateEvent();
virtual Color getColor2D(double x, double y, double scaling) const;
protected:
SoftwareRenderer* renderer;
};
}
}
#endif // BASE2DPREVIEWRENDERER_H

View file

@ -0,0 +1,58 @@
#-------------------------------------------------
#
# Project created by QtCreator 2013-11-11T17:56:07
#
#-------------------------------------------------
TARGET = paysages_render_preview
TEMPLATE = lib
DEFINES += PREVIEW_LIBRARY
include(../../common.pri)
SOURCES += Base2dPreviewRenderer.cpp \
AtmosphereColorPreviewRenderer.cpp
HEADERS += Base2dPreviewRenderer.h\
preview_global.h \
AtmosphereColorPreviewRenderer.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/../../rendering/release/ -lpaysages_rendering
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../rendering/debug/ -lpaysages_rendering
else:unix: LIBS += -L$$OUT_PWD/../../rendering/ -lpaysages_rendering
INCLUDEPATH += $$PWD/../../rendering
DEPENDPATH += $$PWD/../../rendering
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

View file

@ -0,0 +1,22 @@
#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 Base2dPreviewRenderer;
class AtmosphereColorPreviewRenderer;
}
}
using namespace paysages::preview;
#endif // PREVIEW_GLOBAL_H

View file

@ -0,0 +1,203 @@
#include "AtmosphereRenderer.h"
#include <cmath>
#include "SoftwareRenderer.h"
#include "Scenery.h"
// TEMP
#include "atmosphere/private.h"
static inline double _getDayFactor(double daytime)
{
daytime = 1.0 - fabs(0.5 - daytime) / 0.5;
return daytime < 0.45 ? 0.0 : sqrt((daytime - 0.45) / 0.55);
}
static inline void _applyWeatherEffects(AtmosphereDefinition* definition, AtmosphereResult* result)
{
double distance = result->distance;
double max_distance = 100.0 - 90.0 * definition->humidity;
double distancefactor, dayfactor;
if (distance > max_distance)
{
distance = max_distance;
}
distancefactor = (distance > max_distance ? max_distance : distance) / max_distance;
/* TODO Get day lighting from model */
dayfactor = _getDayFactor(definition->_daytime);
/* Fog masking */
if (definition->humidity > 0.3)
{
result->mask.r = result->mask.g = result->mask.b = (10.0 - 8.0 * definition->humidity) * dayfactor;
result->mask.a = distancefactor * (definition->humidity - 0.3) / 0.7;
}
/* Scattering tweaking */
if (definition->humidity < 0.15)
{
/* Limit scattering on ultra clear day */
double force = (0.15 - definition->humidity) / 0.15;
colorLimitPower(&result->inscattering, 100.0 - 90.0 * pow(force, 0.1));
}
else
{
/* Scattering boost */
double force = 1.2 * (definition->humidity < 0.5 ? sqrt((definition->humidity - 0.15) / 0.35) : 1.0 - (definition->humidity - 0.5) / 0.5);
result->inscattering.r *= 1.0 + force * distancefactor * (definition->humidity - 0.15) / 0.85;
result->inscattering.g *= 1.0 + force * distancefactor * (definition->humidity - 0.15) / 0.85;
result->inscattering.b *= 1.0 + force * distancefactor * (definition->humidity - 0.15) / 0.85;
}
/* Attenuation */
result->attenuation.r *= 1.0 - 0.4 * distancefactor * definition->humidity;
result->attenuation.g *= 1.0 - 0.4 * distancefactor * definition->humidity;
result->attenuation.b *= 1.0 - 0.4 * distancefactor * definition->humidity;
atmosphereUpdateResult(result);
}
BaseAtmosphereRenderer::BaseAtmosphereRenderer(SoftwareRenderer* renderer):
renderer(renderer)
{
}
void BaseAtmosphereRenderer::getLightingStatus(LightStatus* status, Vector3, int)
{
LightDefinition light;
light.color.r = 1.0;
light.color.g = 1.0;
light.color.b = 1.0;
light.direction.x = -0.7;
light.direction.y = -0.7;
light.direction.z = 0.7;
light.altered = 0;
light.reflection = 0.0;
lightingPushLight(status, &light);
light.color.r = 0.3;
light.color.g = 0.31;
light.color.b = 0.34;
light.direction.x = 0.7;
light.direction.y = -0.7;
light.direction.z = -0.7;
light.altered = 0;
light.reflection = 0.0;
lightingPushLight(status, &light);
}
AtmosphereResult BaseAtmosphereRenderer::applyAerialPerspective(Vector3, Color base)
{
AtmosphereResult result;
result.base = result.final = base;
result.inscattering = result.attenuation = COLOR_BLACK;
return result;
}
AtmosphereResult BaseAtmosphereRenderer::getSkyColor(Vector3)
{
AtmosphereResult result;
result.base = result.final = COLOR_WHITE;
result.inscattering = result.attenuation = COLOR_BLACK;
return result;
}
Vector3 BaseAtmosphereRenderer::getSunDirection()
{
AtmosphereDefinition* atmosphere = getDefinition();
double sun_angle = (atmosphere->_daytime + 0.75) * M_PI * 2.0;
return Vector3(cos(sun_angle), sin(sun_angle), 0.0);
}
AtmosphereDefinition* BaseAtmosphereRenderer::getDefinition()
{
return renderer->getScenery()->getAtmosphere();
}
void SoftwareBrunetonAtmosphereRenderer::getLightingStatus(LightStatus* status, Vector3 normal, int opaque)
{
return brunetonGetLightingStatus(renderer, status, normal, opaque);
}
AtmosphereResult SoftwareBrunetonAtmosphereRenderer::applyAerialPerspective(Vector3 location, Color base)
{
AtmosphereDefinition* definition = getDefinition();
AtmosphereResult result;
/* Get base perspective */
switch (definition->model)
{
case ATMOSPHERE_MODEL_BRUNETON:
result = brunetonApplyAerialPerspective(renderer, location, base);
break;
default:
;
}
/* Apply weather effects */
_applyWeatherEffects(definition, &result);
return result;
}
AtmosphereResult SoftwareBrunetonAtmosphereRenderer::getSkyColor(Vector3 direction)
{
AtmosphereDefinition* definition;
Vector3 sun_direction, sun_position, camera_location;
Color base;
definition = getDefinition();
camera_location = renderer->getCameraLocation(renderer, VECTOR_ZERO);
sun_direction = getSunDirection();
direction = v3Normalize(direction);
sun_position = v3Scale(sun_direction, SUN_DISTANCE_SCALED);
/* Get sun shape */
base = COLOR_BLACK;
/*if (v3Dot(sun_direction, direction) >= 0)
{
double sun_radius = definition->sun_radius * SUN_RADIUS_SCALED * 5.0; // FIXME Why should we multiply by 5 ?
Vector3 hit1, hit2;
int hits = euclidRayIntersectSphere(camera_location, direction, sun_position, sun_radius, &hit1, &hit2);
if (hits > 1)
{
double dist = v3Norm(v3Sub(hit2, hit1)) / sun_radius; // distance between intersection points (relative to radius)
Color sun_color = definition->sun_color;
sun_color.r *= 100.0;
sun_color.g *= 100.0;
sun_color.b *= 100.0;
if (dist <= 0.05)
{
sun_color.r *= 1.0 - dist / 0.05;
sun_color.g *= 1.0 - dist / 0.05;
sun_color.b *= 1.0 - dist / 0.05;
}
base = sun_color;
}
}*/
/* TODO Get stars */
/* Get scattering */
AtmosphereResult result;
Vector3 location = v3Add(camera_location, v3Scale(direction, 6421.0));
switch (definition->model)
{
case ATMOSPHERE_MODEL_BRUNETON:
result = brunetonGetSkyColor(renderer, camera_location, direction, sun_position, base);
break;
default:
result = BaseAtmosphereRenderer::applyAerialPerspective(location, result.base);
}
/* Apply weather effects */
_applyWeatherEffects(definition, &result);
return result;
}

View file

@ -0,0 +1,41 @@
#ifndef ATMOSPHERERENDERER_H
#define ATMOSPHERERENDERER_H
#include "software_global.h"
// TEMP
#include "atmosphere/public.h"
namespace paysages {
namespace software {
class BaseAtmosphereRenderer
{
public:
BaseAtmosphereRenderer(SoftwareRenderer* renderer);
virtual ~BaseAtmosphereRenderer() {}
virtual void getLightingStatus(LightStatus* status, Vector3 normal, int opaque);
virtual AtmosphereResult applyAerialPerspective(Vector3 location, Color base);
virtual AtmosphereResult getSkyColor(Vector3 direction);
virtual Vector3 getSunDirection();
protected:
virtual AtmosphereDefinition* getDefinition();
SoftwareRenderer* renderer;
};
class SoftwareBrunetonAtmosphereRenderer: public BaseAtmosphereRenderer
{
public:
SoftwareBrunetonAtmosphereRenderer(SoftwareRenderer* renderer):BaseAtmosphereRenderer(renderer) {}
virtual void getLightingStatus(LightStatus* status, Vector3 normal, int opaque) override;
virtual AtmosphereResult applyAerialPerspective(Vector3 location, Color base) override;
virtual AtmosphereResult getSkyColor(Vector3 direction) override;
};
}
}
#endif // ATMOSPHERERENDERER_H

View file

@ -3,9 +3,32 @@
#include "camera.h"
#include "Scenery.h"
#include "FluidMediumManager.h"
#include "AtmosphereRenderer.h"
// Legacy compatibility
static AtmosphereResult _legacyApplyAerialPerspective(Renderer* renderer, Vector3 location, Color base)
{
return ((SoftwareRenderer*)renderer)->getAtmosphereRenderer()->applyAerialPerspective(location, base);
}
static AtmosphereResult _legacyGetSkyColor(Renderer* renderer, Vector3 direction)
{
return ((SoftwareRenderer*)renderer)->getAtmosphereRenderer()->getSkyColor(direction);
}
static void _legacyGetLightingStatus(Renderer* renderer, LightStatus* status, Vector3 normal, int opaque)
{
return ((SoftwareRenderer*)renderer)->getAtmosphereRenderer()->getLightingStatus(status, normal, opaque);
}
static Vector3 _legacyGetSunDirection(Renderer* renderer)
{
return ((SoftwareRenderer*)renderer)->getAtmosphereRenderer()->getSunDirection();
}
SoftwareRenderer::SoftwareRenderer(Scenery* scenery)
{
atmosphere_renderer = new BaseAtmosphereRenderer(this);
fluid_medium = new FluidMediumManager(this);
if (scenery)
@ -21,11 +44,25 @@ SoftwareRenderer::SoftwareRenderer(Scenery* scenery)
SoftwareRenderer::~SoftwareRenderer()
{
delete atmosphere_renderer;
delete fluid_medium;
}
void SoftwareRenderer::initialize()
void SoftwareRenderer::prepare()
{
// Prepare sub renderers
delete atmosphere_renderer;
atmosphere_renderer = new SoftwareBrunetonAtmosphereRenderer(this);
// Setup transitional renderers (for C-legacy subsystems)
atmosphere->applyAerialPerspective = _legacyApplyAerialPerspective;
atmosphere->getSkyColor = _legacyGetSkyColor;
atmosphere->getLightingStatus = _legacyGetLightingStatus;
atmosphere->getSunDirection = _legacyGetSunDirection;
// Prepare global tools
fluid_medium->clearMedia();
//fluid_medium->registerMedium(water_renderer);
}

View file

@ -20,9 +20,16 @@ public:
SoftwareRenderer(Scenery* scenery=0);
virtual ~SoftwareRenderer();
virtual void initialize();
/*!
* \brief Prepare the renderer sub-systems.
*
* This will clear the caches and connect elements together.
* After this call, don't update the scenery when renderer is in use.
*/
virtual void prepare();
inline Scenery* getScenery() const {return scenery;}
inline BaseAtmosphereRenderer* getAtmosphereRenderer() const {return atmosphere_renderer;}
inline FluidMediumManager* getFluidMediumManager() const {return fluid_medium;}
//virtual Color applyMediumTraversal(Vector3 location, Color color) override;
@ -30,6 +37,7 @@ public:
private:
Scenery* scenery;
FluidMediumManager* fluid_medium;
BaseAtmosphereRenderer* atmosphere_renderer;
};
}

View file

@ -15,12 +15,14 @@ include(../../common.pri)
SOURCES += SoftwareRenderer.cpp \
FluidMediumInterface.cpp \
FluidMediumManager.cpp
FluidMediumManager.cpp \
AtmosphereRenderer.cpp
HEADERS += SoftwareRenderer.h\
software_global.h \
FluidMediumInterface.h \
FluidMediumManager.h
FluidMediumManager.h \
AtmosphereRenderer.h
unix:!symbian {
maemo5 {

View file

@ -14,9 +14,13 @@
namespace paysages {
namespace software {
class SoftwareRenderer;
class FluidMediumManager;
class FluidMediumInterface;
class FluidMediumCollector;
class BaseAtmosphereRenderer;
class SoftwareBrunetonAtmosphereRenderer;
}
}

View file

@ -4,14 +4,14 @@
#include "NoiseGenerator.h"
#include "PackStream.h"
#include "rendering/atmosphere/public.h"
#include "rendering/camera.h"
#include "rendering/clouds/public.h"
#include "rendering/terrain/public.h"
#include "rendering/textures/public.h"
#include "rendering/water/public.h"
#include "rendering/renderer.h"
#include "rendering/terrain/ter_raster.h"
#include "atmosphere/public.h"
#include "camera.h"
#include "clouds/public.h"
#include "terrain/public.h"
#include "textures/public.h"
#include "water/public.h"
#include "renderer.h"
#include "terrain/ter_raster.h"
static Scenery* _main_scenery;
static SceneryCustomDataCallback _custom_save = NULL;

View file

@ -11,12 +11,12 @@
#include <cstdlib>
#include "System.h"
#include "PackStream.h"
#include "rendering/tools.h"
#include "rendering/tools/cache.h"
#include "rendering/tools/texture.h"
#include "rendering/tools/parallel.h"
#include "rendering/renderer.h"
#include "rendering/water/public.h"
#include "tools.h"
#include "tools/cache.h"
#include "tools/texture.h"
#include "tools/parallel.h"
#include "renderer.h"
#include "water/public.h"
/*********************** Constants ***********************/

View file

@ -5,7 +5,7 @@
#include <stdlib.h>
#include "../tools.h"
#include "../renderer.h"
#include "rendering/clouds/public.h"
#include "clouds/public.h"
static Color _postProcessFragment(Renderer* renderer, Vector3 location, void* data)
{

View file

@ -55,138 +55,6 @@ static void _fakeGetLightingStatus(Renderer* renderer, LightStatus* status, Vect
lightingPushLight(status, &light);
}
/******************** Real ********************/
static inline double _getDayFactor(double daytime)
{
daytime = 1.0 - fabs(0.5 - daytime) / 0.5;
return daytime < 0.45 ? 0.0 : sqrt((daytime - 0.45) / 0.55);
}
static inline void _applyWeatherEffects(AtmosphereDefinition* definition, AtmosphereResult* result)
{
double distance = result->distance;
double max_distance = 100.0 - 90.0 * definition->humidity;
double distancefactor, dayfactor;
if (distance > max_distance)
{
distance = max_distance;
}
distancefactor = (distance > max_distance ? max_distance : distance) / max_distance;
/* TODO Get day lighting from model */
dayfactor = _getDayFactor(definition->_daytime);
/* Fog masking */
if (definition->humidity > 0.3)
{
result->mask.r = result->mask.g = result->mask.b = (10.0 - 8.0 * definition->humidity) * dayfactor;
result->mask.a = distancefactor * (definition->humidity - 0.3) / 0.7;
}
/* Scattering tweaking */
if (definition->humidity < 0.15)
{
/* Limit scattering on ultra clear day */
double force = (0.15 - definition->humidity) / 0.15;
colorLimitPower(&result->inscattering, 100.0 - 90.0 * pow(force, 0.1));
}
else
{
/* Scattering boost */
double force = 1.2 * (definition->humidity < 0.5 ? sqrt((definition->humidity - 0.15) / 0.35) : 1.0 - (definition->humidity - 0.5) / 0.5);
result->inscattering.r *= 1.0 + force * distancefactor * (definition->humidity - 0.15) / 0.85;
result->inscattering.g *= 1.0 + force * distancefactor * (definition->humidity - 0.15) / 0.85;
result->inscattering.b *= 1.0 + force * distancefactor * (definition->humidity - 0.15) / 0.85;
}
/* Attenuation */
result->attenuation.r *= 1.0 - 0.4 * distancefactor * definition->humidity;
result->attenuation.g *= 1.0 - 0.4 * distancefactor * definition->humidity;
result->attenuation.b *= 1.0 - 0.4 * distancefactor * definition->humidity;
atmosphereUpdateResult(result);
}
static AtmosphereResult _realApplyAerialPerspective(Renderer* renderer, Vector3 location, Color base)
{
AtmosphereDefinition* definition = renderer->atmosphere->definition;
AtmosphereResult result;
/* Get base perspective */
switch (definition->model)
{
case ATMOSPHERE_MODEL_BRUNETON:
result = brunetonApplyAerialPerspective(renderer, location, base);
break;
default:
;
}
/* Apply weather effects */
_applyWeatherEffects(definition, &result);
return result;
}
static AtmosphereResult _realGetSkyColor(Renderer* renderer, Vector3 direction)
{
AtmosphereDefinition* definition;
Vector3 sun_direction, sun_position, camera_location;
Color base;
definition = renderer->atmosphere->definition;
camera_location = renderer->getCameraLocation(renderer, VECTOR_ZERO);
sun_direction = renderer->atmosphere->getSunDirection(renderer);
direction = v3Normalize(direction);
sun_position = v3Scale(sun_direction, SUN_DISTANCE_SCALED);
/* Get sun shape */
base = COLOR_BLACK;
/*if (v3Dot(sun_direction, direction) >= 0)
{
double sun_radius = definition->sun_radius * SUN_RADIUS_SCALED * 5.0; // FIXME Why should we multiply by 5 ?
Vector3 hit1, hit2;
int hits = euclidRayIntersectSphere(camera_location, direction, sun_position, sun_radius, &hit1, &hit2);
if (hits > 1)
{
double dist = v3Norm(v3Sub(hit2, hit1)) / sun_radius; // distance between intersection points (relative to radius)
Color sun_color = definition->sun_color;
sun_color.r *= 100.0;
sun_color.g *= 100.0;
sun_color.b *= 100.0;
if (dist <= 0.05)
{
sun_color.r *= 1.0 - dist / 0.05;
sun_color.g *= 1.0 - dist / 0.05;
sun_color.b *= 1.0 - dist / 0.05;
}
base = sun_color;
}
}*/
/* TODO Get stars */
/* Get scattering */
AtmosphereResult result;
Vector3 location = v3Add(camera_location, v3Scale(direction, 6421.0));
switch (definition->model)
{
case ATMOSPHERE_MODEL_BRUNETON:
result = brunetonGetSkyColor(renderer, camera_location, direction, sun_position, base);
break;
default:
result = _fakeApplyAerialPerspective(renderer, location, result.base);
}
/* Apply weather effects */
_applyWeatherEffects(definition, &result);
return result;
}
static Vector3 _realGetSunDirection(Renderer* renderer)
{
Vector3 result;
@ -242,18 +110,6 @@ static void _deleteRenderer(AtmosphereRenderer* renderer)
static void _bindRenderer(Renderer* renderer, AtmosphereDefinition* definition)
{
AtmosphereDefinitionClass.copy(definition, renderer->atmosphere->definition);
renderer->atmosphere->getSkyColor = _realGetSkyColor;
renderer->atmosphere->applyAerialPerspective = _realApplyAerialPerspective;
switch (definition->model)
{
case ATMOSPHERE_MODEL_BRUNETON:
renderer->atmosphere->getLightingStatus = brunetonGetLightingStatus;
break;
default:
renderer->atmosphere->getLightingStatus = _fakeGetLightingStatus;
}
}
StandardRenderer AtmosphereRendererClass = {

View file

@ -77,7 +77,4 @@ RENDERINGSHARED_EXPORT void atmosphereRenderSkydome(Renderer* renderer);
RENDERINGSHARED_EXPORT void atmosphereInitResult(AtmosphereResult* result);
RENDERINGSHARED_EXPORT void atmosphereUpdateResult(AtmosphereResult* result);
RENDERINGSHARED_EXPORT Renderer* atmosphereCreatePreviewRenderer();
RENDERINGSHARED_EXPORT Color atmosphereGetPreview(Renderer* renderer, double x, double y, double heading);
#endif

View file

@ -7,9 +7,9 @@
#include "PackStream.h"
#include "tools.h"
#include "tools/boundingbox.h"
#include "rendering/renderer.h"
#include "rendering/terrain/public.h"
#include "rendering/water/public.h"
#include "renderer.h"
#include "terrain/public.h"
#include "water/public.h"
class CameraDefinition
{

View file

@ -4,7 +4,7 @@
#include "../tools/euclid.h"
#include "../renderer.h"
#include "../tools.h"
#include "rendering/atmosphere/public.h"
#include "atmosphere/public.h"
/*
* Clouds previews.

View file

@ -6,7 +6,7 @@
#include "../renderer.h"
#include "clo_density.h"
#include "clo_walking.h"
#include "rendering/atmosphere/public.h"
#include "atmosphere/public.h"
/******************** Fake ********************/
static int _fakeAlterLight(Renderer* renderer, LightDefinition* light, Vector3 location)

View file

@ -6,12 +6,12 @@
#include "render.h"
#include "Scenery.h"
#include "tools.h"
#include "rendering/camera.h"
#include "rendering/atmosphere/public.h"
#include "rendering/clouds/public.h"
#include "rendering/terrain/public.h"
#include "rendering/textures/public.h"
#include "rendering/water/public.h"
#include "camera.h"
#include "atmosphere/public.h"
#include "clouds/public.h"
#include "terrain/public.h"
#include "textures/public.h"
#include "water/public.h"
static RayCastingResult _RAYCASTING_NULL = {0, {0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}};
@ -229,6 +229,8 @@ void rendererStart(Renderer* renderer, RenderParams params)
renderSetParams(renderer->render_area, params);
renderClear(renderer->render_area);
renderer->prepare();
renderer->is_rendering = 1;
thread.start(renderer);
loops = 0;

View file

@ -20,6 +20,8 @@ public:
Renderer();
virtual ~Renderer();
virtual void prepare() {}
/* Render base configuration */
int render_quality;
int render_width;

View file

@ -8,8 +8,6 @@ DEFINES += RENDERING_LIBRARY
include(../common.pri)
INCLUDEPATH += $$PWD/..
SOURCES += main.cpp \
tools.cpp \
renderer.cpp \
@ -19,7 +17,6 @@ SOURCES += main.cpp \
camera.cpp \
atmosphere/atm_render.cpp \
atmosphere/atm_raster.cpp \
atmosphere/atm_preview.cpp \
atmosphere/atm_presets.cpp \
atmosphere/atm_definition.cpp \
atmosphere/atm_bruneton.cpp \

View file

@ -70,7 +70,7 @@ RENDERINGSHARED_EXPORT double terrainGetGridHeight(TerrainDefinition* definition
RENDERINGSHARED_EXPORT double terrainGetInterpolatedHeight(TerrainDefinition* definition, double x, double z, int scaled, int with_painting);
RENDERINGSHARED_EXPORT size_t terrainGetMemoryStats(TerrainDefinition* definition);
RENDERINGSHARED_EXPORT Renderer* terrainCreatePreviewRenderer();
RENDERINGSHARED_EXPORT void terrainAlterPreviewRenderer(Renderer* renderer);
RENDERINGSHARED_EXPORT Color terrainGetPreviewColor(Renderer* renderer, double x, double z, double detail);
RENDERINGSHARED_EXPORT HeightInfo terrainGetHeightInfo(TerrainDefinition* definition);

View file

@ -4,8 +4,8 @@
#include "../tools/lighting.h"
#include "../renderer.h"
#include "NoiseGenerator.h"
#include "rendering/atmosphere/public.h"
#include "rendering/textures/public.h"
#include "atmosphere/public.h"
#include "textures/public.h"
/*
* Terrain previews.
@ -51,13 +51,11 @@ static Vector3 _getCameraLocation(Renderer* renderer, Vector3 location)
return location;
}
Renderer* terrainCreatePreviewRenderer()
void terrainAlterPreviewRenderer(Renderer* renderer)
{
Renderer* result = rendererCreate();
result->render_quality = 3;
result->getCameraLocation = _getCameraLocation;
result->atmosphere->getLightingStatus = _getLightingStatus;
renderer->render_quality = 3;
renderer->getCameraLocation = _getCameraLocation;
renderer->atmosphere->getLightingStatus = _getLightingStatus;
TexturesDefinition* textures;
textures = (TexturesDefinition*)TexturesDefinitionClass.create();
@ -71,11 +69,9 @@ Renderer* terrainCreatePreviewRenderer()
TexturesDefinitionClass.validate(textures);
layer->_detail_noise->clearLevels();
TexturesRendererClass.bind(result, textures);
TexturesRendererClass.bind(renderer, textures);
TexturesDefinitionClass.destroy(textures);
return result;
}
Color terrainGetPreviewColor(Renderer* renderer, double x, double z, double detail)

View file

@ -8,9 +8,9 @@
#include "../tools/boundingbox.h"
#include "../tools/parallel.h"
#include "../renderer.h"
#include "rendering/water/public.h"
#include "rendering/textures/public.h"
#include "rendering/camera.h"
#include "water/public.h"
#include "textures/public.h"
#include "camera.h"
/*
* Terrain rasterization.

View file

@ -4,7 +4,7 @@
#include <math.h>
#include "../tools.h"
#include "../renderer.h"
#include "rendering/textures/public.h"
#include "textures/public.h"
/******************** Binding ********************/
static double _fakeGetHeight(Renderer* renderer, double x, double z, int with_painting)

View file

@ -3,9 +3,9 @@
#include "../rendering_global.h"
#include "Layers.h"
#include "rendering/tools/zone.h"
#include "rendering/tools/lighting.h"
#include "rendering/terrain/public.h"
#include "tools/zone.h"
#include "tools/lighting.h"
#include "terrain/public.h"
#define TEXTURES_MAX_LAYERS 50

View file

@ -2,7 +2,7 @@
#include "private.h"
#include "Scenery.h"
#include "rendering/tools.h"
#include "tools.h"
void TexturesPreviewLayerCoverage_bind(Renderer* renderer, TexturesDefinition* definition)
{

View file

@ -1,8 +1,8 @@
#ifndef TEX_PREVIEW_H
#define TEX_PREVIEW_H
#include "rendering/renderer.h"
#include "rendering/textures/public.h"
#include "renderer.h"
#include "textures/public.h"
/* Single layer coverage */
RENDERINGSHARED_EXPORT void TexturesPreviewLayerCoverage_bind(Renderer* renderer, TexturesDefinition* definition);

View file

@ -71,7 +71,7 @@ RENDERINGSHARED_EXPORT extern StandardRenderer WaterRendererClass;
RENDERINGSHARED_EXPORT void waterRenderSurface(Renderer* renderer);
RENDERINGSHARED_EXPORT void waterAutoPreset(WaterDefinition* definition, WaterPreset preset);
RENDERINGSHARED_EXPORT Renderer* waterCreatePreviewCoverageRenderer();
RENDERINGSHARED_EXPORT void waterAlterPreviewCoverageRenderer(Renderer* renderer);
RENDERINGSHARED_EXPORT Color waterGetPreviewCoverage(Renderer* renderer, double x, double y, double scaling, int highlight_enabled);
RENDERINGSHARED_EXPORT Renderer* waterCreatePreviewColorRenderer();

View file

@ -4,9 +4,9 @@
#include "../renderer.h"
#include "../tools.h"
Renderer* waterCreatePreviewCoverageRenderer()
void waterAlterPreviewCoverageRenderer(Renderer* renderer)
{
return terrainCreatePreviewRenderer();
terrainAlterPreviewRenderer(renderer);
}
Color waterGetPreviewCoverage(Renderer* renderer, double x, double y, double scaling, int highlight_enabled)

Some files were not shown because too many files have changed in this diff Show more