New Scenery class, with transitional C-api
This commit is contained in:
parent
ea25cdaa55
commit
ce56f0a985
31 changed files with 606 additions and 337 deletions
26
src/basics/basics.pro
Normal file
26
src/basics/basics.pro
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#-------------------------------------------------
|
||||||
|
#
|
||||||
|
# Project created by QtCreator 2013-10-29T17:15:02
|
||||||
|
#
|
||||||
|
#-------------------------------------------------
|
||||||
|
|
||||||
|
QT -= gui
|
||||||
|
|
||||||
|
TARGET = basics
|
||||||
|
TEMPLATE = lib
|
||||||
|
|
||||||
|
DEFINES += BASICS_LIBRARY
|
||||||
|
|
||||||
|
SOURCES +=
|
||||||
|
|
||||||
|
HEADERS +=\
|
||||||
|
basics_global.h
|
||||||
|
|
||||||
|
unix:!symbian {
|
||||||
|
maemo5 {
|
||||||
|
target.path = /opt/usr/lib
|
||||||
|
} else {
|
||||||
|
target.path = /usr/lib
|
||||||
|
}
|
||||||
|
INSTALLS += target
|
||||||
|
}
|
33
src/basics/basics_global.h
Normal file
33
src/basics/basics_global.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#ifndef BASICS_GLOBAL_H
|
||||||
|
#define BASICS_GLOBAL_H
|
||||||
|
|
||||||
|
/* Shared object helpers */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
# include <QtCore/qglobal.h>
|
||||||
|
#else
|
||||||
|
# if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
|
||||||
|
# define Q_DECL_EXPORT __declspec(dllexport)
|
||||||
|
# define Q_DECL_IMPORT __declspec(dllimport)
|
||||||
|
# else
|
||||||
|
# define Q_DECL_EXPORT
|
||||||
|
# define Q_DECL_IMPORT
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#if defined(DEFINITION_LIBRARY)
|
||||||
|
# define BASICSSHARED_EXPORT Q_DECL_EXPORT
|
||||||
|
#else
|
||||||
|
# define BASICSSHARED_EXPORT Q_DECL_IMPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Namespace using */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
namespace paysages
|
||||||
|
{
|
||||||
|
namespace basics {}
|
||||||
|
}
|
||||||
|
using namespace paysages::system;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Global imports */
|
||||||
|
|
||||||
|
#endif // BASICS_GLOBAL_H
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "rendering/main.h"
|
#include "rendering/main.h"
|
||||||
#include "rendering/render.h"
|
#include "rendering/render.h"
|
||||||
#include "rendering/scenery.h"
|
#include "rendering/Scenery.h"
|
||||||
|
|
||||||
void startRender(Renderer* renderer, char* outputpath, RenderParams params)
|
void startRender(Renderer* renderer, char* outputpath, RenderParams params)
|
||||||
{
|
{
|
||||||
|
|
38
src/definition/definition.pro
Normal file
38
src/definition/definition.pro
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#-------------------------------------------------
|
||||||
|
#
|
||||||
|
# Project created by QtCreator 2013-10-29T14:38:43
|
||||||
|
#
|
||||||
|
#-------------------------------------------------
|
||||||
|
|
||||||
|
QT -= gui
|
||||||
|
|
||||||
|
TARGET = paysages_definition
|
||||||
|
TEMPLATE = lib
|
||||||
|
|
||||||
|
DEFINES += DEFINITION_LIBRARY
|
||||||
|
|
||||||
|
SOURCES +=
|
||||||
|
|
||||||
|
HEADERS +=\
|
||||||
|
definition_global.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/../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/../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
|
33
src/definition/definition_global.h
Normal file
33
src/definition/definition_global.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#ifndef DEFINITION_GLOBAL_H
|
||||||
|
#define DEFINITION_GLOBAL_H
|
||||||
|
|
||||||
|
/* Shared object helpers */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
# include <QtCore/qglobal.h>
|
||||||
|
#else
|
||||||
|
# if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
|
||||||
|
# define Q_DECL_EXPORT __declspec(dllexport)
|
||||||
|
# define Q_DECL_IMPORT __declspec(dllimport)
|
||||||
|
# else
|
||||||
|
# define Q_DECL_EXPORT
|
||||||
|
# define Q_DECL_IMPORT
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#if defined(DEFINITION_LIBRARY)
|
||||||
|
# define DEFINITIONSHARED_EXPORT Q_DECL_EXPORT
|
||||||
|
#else
|
||||||
|
# define DEFINITIONSHARED_EXPORT Q_DECL_IMPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Namespace using */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
namespace paysages
|
||||||
|
{
|
||||||
|
namespace definition {}
|
||||||
|
}
|
||||||
|
using namespace paysages::system;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Global imports */
|
||||||
|
|
||||||
|
#endif // DEFINITION_GLOBAL_H
|
|
@ -11,7 +11,7 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "dialogrender.h"
|
#include "dialogrender.h"
|
||||||
#include "dialogexplorer.h"
|
#include "dialogexplorer.h"
|
||||||
#include "rendering/scenery.h"
|
#include "Scenery.h"
|
||||||
#include "rendering/renderer.h"
|
#include "rendering/renderer.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "dialogexplorer.h"
|
#include "dialogexplorer.h"
|
||||||
|
|
||||||
#include "rendering/main.h"
|
#include "rendering/main.h"
|
||||||
#include "rendering/scenery.h"
|
#include "Scenery.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
MainWindow* MainWindow::_instance = NULL;
|
MainWindow* MainWindow::_instance = NULL;
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
#include "rendering/scenery.h"
|
#include "Scenery.h"
|
||||||
|
|
||||||
static DialogRender* _current_dialog;
|
static DialogRender* _current_dialog;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "rendering/atmosphere/public.h"
|
#include "rendering/atmosphere/public.h"
|
||||||
#include "rendering/scenery.h"
|
#include "Scenery.h"
|
||||||
#include "rendering/renderer.h"
|
#include "rendering/renderer.h"
|
||||||
|
|
||||||
static AtmosphereDefinition* _definition;
|
static AtmosphereDefinition* _definition;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include "rendering/clouds/clo_preview.h"
|
#include "rendering/clouds/clo_preview.h"
|
||||||
#include "rendering/tools/color.h"
|
#include "rendering/tools/color.h"
|
||||||
#include "rendering/tools/euclid.h"
|
#include "rendering/tools/euclid.h"
|
||||||
#include "rendering/scenery.h"
|
#include "Scenery.h"
|
||||||
|
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "inputcamera.h"
|
#include "inputcamera.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "rendering/render.h"
|
#include "rendering/render.h"
|
||||||
#include "rendering/scenery.h"
|
#include "Scenery.h"
|
||||||
|
|
||||||
/**************** Previews ****************/
|
/**************** Previews ****************/
|
||||||
class PreviewRenderLandscape : public BasePreview
|
class PreviewRenderLandscape : public BasePreview
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "formtextures.h"
|
#include "formtextures.h"
|
||||||
|
|
||||||
#include "rendering/scenery.h"
|
#include "Scenery.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
/**************** Previews ****************/
|
/**************** Previews ****************/
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include "rendering/tools/euclid.h"
|
#include "rendering/tools/euclid.h"
|
||||||
#include "rendering/tools/lighting.h"
|
#include "rendering/tools/lighting.h"
|
||||||
#include "rendering/renderer.h"
|
#include "rendering/renderer.h"
|
||||||
#include "rendering/scenery.h"
|
#include "Scenery.h"
|
||||||
#include "rendering/water/public.h"
|
#include "rendering/water/public.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "dialogterrainpainting.h"
|
#include "dialogterrainpainting.h"
|
||||||
#include "previewterrainshape.h"
|
#include "previewterrainshape.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "rendering/scenery.h"
|
#include "Scenery.h"
|
||||||
#include "rendering/textures/public.h"
|
#include "rendering/textures/public.h"
|
||||||
|
|
||||||
MainTerrainForm::MainTerrainForm(QWidget *parent) :
|
MainTerrainForm::MainTerrainForm(QWidget *parent) :
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "rendering/scenery.h"
|
#include "Scenery.h"
|
||||||
|
|
||||||
#define HEIGHTMAP_RESOLUTION 256
|
#define HEIGHTMAP_RESOLUTION 256
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "../common/freeformhelper.h"
|
#include "../common/freeformhelper.h"
|
||||||
#include "../common/freelayerhelper.h"
|
#include "../common/freelayerhelper.h"
|
||||||
#include "rendering/scenery.h"
|
#include "Scenery.h"
|
||||||
#include "previewmaterial.h"
|
#include "previewmaterial.h"
|
||||||
#include "editing/textures/PreviewLayerCoverage.h"
|
#include "editing/textures/PreviewLayerCoverage.h"
|
||||||
#include "editing/textures/PreviewLayerLook.h"
|
#include "editing/textures/PreviewLayerLook.h"
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
#include <QGLWidget>
|
#include <QGLWidget>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <math.h>
|
#include <cmath>
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include "rendering/scenery.h"
|
#include "Scenery.h"
|
||||||
#include "rendering/tools/euclid.h"
|
#include "rendering/tools/euclid.h"
|
||||||
#include "../exploring/main.h"
|
#include "../exploring/main.h"
|
||||||
#include "explorerchunkterrain.h"
|
#include "explorerchunkterrain.h"
|
||||||
|
|
|
@ -6,12 +6,15 @@ SUBDIRS = \
|
||||||
rendering \
|
rendering \
|
||||||
exploring \
|
exploring \
|
||||||
editing \
|
editing \
|
||||||
controlling
|
controlling \
|
||||||
|
definition \
|
||||||
|
basics
|
||||||
|
|
||||||
unix:SUBDIRS += testing
|
unix:SUBDIRS += testing
|
||||||
|
|
||||||
rendering.depends = system
|
rendering.depends = system
|
||||||
exploring.depends = rendering
|
exploring.depends = rendering
|
||||||
|
definition.depends = rendering system
|
||||||
editing.depends = exploring rendering
|
editing.depends = exploring rendering
|
||||||
controlling.depends = rendering
|
controlling.depends = rendering
|
||||||
unix:testing.depends = rendering
|
unix:testing.depends = rendering
|
||||||
|
|
312
src/rendering/Scenery.cpp
Normal file
312
src/rendering/Scenery.cpp
Normal file
|
@ -0,0 +1,312 @@
|
||||||
|
#include "Scenery.h"
|
||||||
|
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
#include "rendering/noise.h"
|
||||||
|
#include "rendering/terrain/ter_raster.h"
|
||||||
|
|
||||||
|
static Scenery* _main_scenery;
|
||||||
|
static SceneryCustomDataCallback _custom_save = NULL;
|
||||||
|
static SceneryCustomDataCallback _custom_load = NULL;
|
||||||
|
static void* _custom_data = NULL;
|
||||||
|
|
||||||
|
Scenery::Scenery()
|
||||||
|
{
|
||||||
|
atmosphere = (AtmosphereDefinition*)AtmosphereDefinitionClass.create();
|
||||||
|
camera = cameraCreateDefinition();
|
||||||
|
clouds = (CloudsDefinition*)CloudsDefinitionClass.create();
|
||||||
|
terrain = (TerrainDefinition*)TerrainDefinitionClass.create();
|
||||||
|
textures = (TexturesDefinition*)TexturesDefinitionClass.create();
|
||||||
|
water = (WaterDefinition*)WaterDefinitionClass.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
Scenery::~Scenery()
|
||||||
|
{
|
||||||
|
AtmosphereDefinitionClass.destroy(atmosphere);
|
||||||
|
cameraDeleteDefinition(camera);
|
||||||
|
CloudsDefinitionClass.destroy(clouds);
|
||||||
|
TerrainDefinitionClass.destroy(terrain);
|
||||||
|
TexturesDefinitionClass.destroy(textures);
|
||||||
|
WaterDefinitionClass.destroy(water);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scenery::save(PackStream* stream)
|
||||||
|
{
|
||||||
|
AtmosphereDefinitionClass.save(stream, atmosphere);
|
||||||
|
cameraSave(stream, camera);
|
||||||
|
CloudsDefinitionClass.save(stream, clouds);
|
||||||
|
TerrainDefinitionClass.save(stream, terrain);
|
||||||
|
TexturesDefinitionClass.save(stream, textures);
|
||||||
|
WaterDefinitionClass.save(stream, water);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scenery::load(PackStream* stream)
|
||||||
|
{
|
||||||
|
AtmosphereDefinitionClass.load(stream, atmosphere);
|
||||||
|
cameraLoad(stream, camera);
|
||||||
|
CloudsDefinitionClass.load(stream, clouds);
|
||||||
|
TerrainDefinitionClass.load(stream, terrain);
|
||||||
|
TexturesDefinitionClass.load(stream, textures);
|
||||||
|
WaterDefinitionClass.load(stream, water);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scenery::autoPreset(int seed)
|
||||||
|
{
|
||||||
|
if (!seed)
|
||||||
|
{
|
||||||
|
seed = time(NULL);
|
||||||
|
}
|
||||||
|
srand(seed);
|
||||||
|
|
||||||
|
terrainAutoPreset(terrain, TERRAIN_PRESET_STANDARD);
|
||||||
|
texturesAutoPreset(textures, TEXTURES_PRESET_FULL);
|
||||||
|
atmosphereAutoPreset(atmosphere, ATMOSPHERE_PRESET_CLEAR_DAY);
|
||||||
|
waterAutoPreset(water, WATER_PRESET_LAKE);
|
||||||
|
cloudsAutoPreset(clouds, CLOUDS_PRESET_PARTLY_CLOUDY);
|
||||||
|
|
||||||
|
cameraSetLocation(camera, VECTOR_ZERO);
|
||||||
|
cameraSetTarget(camera, VECTOR_NORTH);
|
||||||
|
cameraValidateDefinition(camera, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scenery::setAtmosphere(AtmosphereDefinition* atmosphere)
|
||||||
|
{
|
||||||
|
AtmosphereDefinitionClass.copy(atmosphere, this->atmosphere);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scenery::getAtmosphere(AtmosphereDefinition* atmosphere)
|
||||||
|
{
|
||||||
|
AtmosphereDefinitionClass.copy(this->atmosphere, atmosphere);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scenery::setCamera(CameraDefinition* camera)
|
||||||
|
{
|
||||||
|
cameraCopyDefinition(camera, this->camera);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scenery::getCamera(CameraDefinition* camera)
|
||||||
|
{
|
||||||
|
cameraCopyDefinition(this->camera, camera);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scenery::setClouds(CloudsDefinition* clouds)
|
||||||
|
{
|
||||||
|
CloudsDefinitionClass.copy(clouds, this->clouds);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scenery::getClouds(CloudsDefinition* clouds)
|
||||||
|
{
|
||||||
|
CloudsDefinitionClass.copy(this->clouds, clouds);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scenery::setTerrain(TerrainDefinition* terrain)
|
||||||
|
{
|
||||||
|
TerrainDefinitionClass.copy(terrain, this->terrain);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scenery::getTerrain(TerrainDefinition* terrain)
|
||||||
|
{
|
||||||
|
TerrainDefinitionClass.copy(this->terrain, terrain);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scenery::setTextures(TexturesDefinition* textures)
|
||||||
|
{
|
||||||
|
TexturesDefinitionClass.copy(textures, this->textures);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scenery::getTextures(TexturesDefinition* textures)
|
||||||
|
{
|
||||||
|
TexturesDefinitionClass.copy(this->textures, textures);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scenery::setWater(WaterDefinition* water)
|
||||||
|
{
|
||||||
|
WaterDefinitionClass.copy(water, this->water);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scenery::getWater(WaterDefinition* water)
|
||||||
|
{
|
||||||
|
WaterDefinitionClass.copy(this->water, water);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scenery::bindToRenderer(Renderer* renderer)
|
||||||
|
{
|
||||||
|
cameraCopyDefinition(camera, renderer->render_camera);
|
||||||
|
AtmosphereRendererClass.bind(renderer, atmosphere);
|
||||||
|
TerrainRendererClass.bind(renderer, terrain);
|
||||||
|
TexturesRendererClass.bind(renderer, textures);
|
||||||
|
CloudsRendererClass.bind(renderer, clouds);
|
||||||
|
WaterRendererClass.bind(renderer, water);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transitional C-API
|
||||||
|
|
||||||
|
void sceneryInit()
|
||||||
|
{
|
||||||
|
noiseInit();
|
||||||
|
_main_scenery = new Scenery();
|
||||||
|
}
|
||||||
|
|
||||||
|
void sceneryQuit()
|
||||||
|
{
|
||||||
|
delete _main_scenery;
|
||||||
|
noiseQuit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void sceneryAutoPreset(int seed)
|
||||||
|
{
|
||||||
|
_main_scenery->autoPreset(seed);
|
||||||
|
}
|
||||||
|
|
||||||
|
void scenerySetCustomDataCallback(SceneryCustomDataCallback callback_save, SceneryCustomDataCallback callback_load, void* data)
|
||||||
|
{
|
||||||
|
_custom_save = callback_save;
|
||||||
|
_custom_load = callback_load;
|
||||||
|
_custom_data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void scenerySave(PackStream* stream)
|
||||||
|
{
|
||||||
|
noiseSave(stream);
|
||||||
|
|
||||||
|
_main_scenery->save(stream);
|
||||||
|
|
||||||
|
if (_custom_save)
|
||||||
|
{
|
||||||
|
_custom_save(stream, _custom_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void sceneryLoad(PackStream* stream)
|
||||||
|
{
|
||||||
|
/* TODO Use intermediary definitions ? */
|
||||||
|
|
||||||
|
noiseLoad(stream);
|
||||||
|
|
||||||
|
_main_scenery->load(stream);
|
||||||
|
|
||||||
|
if (_custom_load)
|
||||||
|
{
|
||||||
|
_custom_load(stream, _custom_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void scenerySetAtmosphere(AtmosphereDefinition* atmosphere)
|
||||||
|
{
|
||||||
|
_main_scenery->setAtmosphere(atmosphere);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sceneryGetAtmosphere(AtmosphereDefinition* atmosphere)
|
||||||
|
{
|
||||||
|
_main_scenery->getAtmosphere(atmosphere);
|
||||||
|
}
|
||||||
|
|
||||||
|
void scenerySetCamera(CameraDefinition* camera)
|
||||||
|
{
|
||||||
|
_main_scenery->setCamera(camera);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sceneryGetCamera(CameraDefinition* camera)
|
||||||
|
{
|
||||||
|
_main_scenery->getCamera(camera);
|
||||||
|
}
|
||||||
|
|
||||||
|
void scenerySetClouds(CloudsDefinition* clouds)
|
||||||
|
{
|
||||||
|
_main_scenery->setClouds(clouds);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sceneryGetClouds(CloudsDefinition* clouds)
|
||||||
|
{
|
||||||
|
_main_scenery->getClouds(clouds);
|
||||||
|
}
|
||||||
|
|
||||||
|
void scenerySetTerrain(TerrainDefinition* terrain)
|
||||||
|
{
|
||||||
|
_main_scenery->setTerrain(terrain);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sceneryGetTerrain(TerrainDefinition* terrain)
|
||||||
|
{
|
||||||
|
_main_scenery->getTerrain(terrain);
|
||||||
|
}
|
||||||
|
|
||||||
|
TerrainDefinition* sceneryGetTerrainDirect()
|
||||||
|
{
|
||||||
|
return _main_scenery->getTerrain();
|
||||||
|
}
|
||||||
|
|
||||||
|
void scenerySetTextures(TexturesDefinition* textures)
|
||||||
|
{
|
||||||
|
_main_scenery->setTextures(textures);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sceneryGetTextures(TexturesDefinition* textures)
|
||||||
|
{
|
||||||
|
_main_scenery->getTextures(textures);
|
||||||
|
}
|
||||||
|
|
||||||
|
void scenerySetWater(WaterDefinition* water)
|
||||||
|
{
|
||||||
|
_main_scenery->setWater(water);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sceneryGetWater(WaterDefinition* water)
|
||||||
|
{
|
||||||
|
_main_scenery->getWater(water);
|
||||||
|
}
|
||||||
|
|
||||||
|
static RayCastingResult _rayWalking(Renderer* renderer, Vector3 location, Vector3 direction, int, int, int, int)
|
||||||
|
{
|
||||||
|
RayCastingResult result;
|
||||||
|
Color sky_color;
|
||||||
|
|
||||||
|
result = renderer->terrain->castRay(renderer, location, direction);
|
||||||
|
if (!result.hit)
|
||||||
|
{
|
||||||
|
sky_color = renderer->atmosphere->getSkyColor(renderer, direction).final;
|
||||||
|
|
||||||
|
result.hit = 1;
|
||||||
|
result.hit_location = v3Add(location, v3Scale(direction, 1000.0));
|
||||||
|
result.hit_color = renderer->clouds->getColor(renderer, sky_color, location, result.hit_location);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static double _getPrecision(Renderer* renderer, Vector3 location)
|
||||||
|
{
|
||||||
|
Vector3 projected;
|
||||||
|
|
||||||
|
projected = cameraProject(renderer->render_camera, location);
|
||||||
|
projected.x += 1.0;
|
||||||
|
//projected.y += 1.0;
|
||||||
|
|
||||||
|
return v3Norm(v3Sub(cameraUnproject(renderer->render_camera, projected), location)); // / (double)render_quality;
|
||||||
|
}
|
||||||
|
|
||||||
|
Renderer* sceneryCreateStandardRenderer()
|
||||||
|
{
|
||||||
|
Renderer* result;
|
||||||
|
|
||||||
|
result = rendererCreate();
|
||||||
|
|
||||||
|
result->rayWalking = _rayWalking;
|
||||||
|
result->getPrecision = _getPrecision;
|
||||||
|
|
||||||
|
sceneryBindRenderer(result);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sceneryBindRenderer(Renderer* renderer)
|
||||||
|
{
|
||||||
|
_main_scenery->bindToRenderer(renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sceneryRenderFirstPass(Renderer* renderer)
|
||||||
|
{
|
||||||
|
terrainRenderSurface(renderer);
|
||||||
|
waterRenderSurface(renderer);
|
||||||
|
atmosphereRenderSkydome(renderer);
|
||||||
|
}
|
125
src/rendering/Scenery.h
Normal file
125
src/rendering/Scenery.h
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
#ifndef SCENERY_H
|
||||||
|
#define SCENERY_H
|
||||||
|
|
||||||
|
#include "rendering_global.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/tools/pack.h"
|
||||||
|
#include "rendering/renderer.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
//class AtmosphereDefinition;
|
||||||
|
//class CameraDefinition;
|
||||||
|
//class CloudsDefinition;
|
||||||
|
//class TerrainDefinition;
|
||||||
|
//class TexturesDefinition;
|
||||||
|
//class WaterDefinition;
|
||||||
|
//class PackStream;
|
||||||
|
//class Renderer;
|
||||||
|
|
||||||
|
namespace paysages {
|
||||||
|
namespace rendering {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Global scenery management
|
||||||
|
*
|
||||||
|
* This class contains the whole scenery definition.
|
||||||
|
*/
|
||||||
|
class RENDERINGSHARED_EXPORT Scenery
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Scenery();
|
||||||
|
~Scenery();
|
||||||
|
|
||||||
|
void autoPreset(int seed);
|
||||||
|
|
||||||
|
void save(PackStream* stream);
|
||||||
|
void load(PackStream* stream);
|
||||||
|
|
||||||
|
void setAtmosphere(AtmosphereDefinition* atmosphere);
|
||||||
|
inline AtmosphereDefinition* getAtmosphere() {return atmosphere;}
|
||||||
|
void getAtmosphere(AtmosphereDefinition* atmosphere);
|
||||||
|
|
||||||
|
void setCamera(CameraDefinition* camera);
|
||||||
|
inline CameraDefinition* getCamera() {return camera;}
|
||||||
|
void getCamera(CameraDefinition* camera);
|
||||||
|
|
||||||
|
void setClouds(CloudsDefinition* clouds);
|
||||||
|
inline CloudsDefinition* getClouds() {return clouds;}
|
||||||
|
void getClouds(CloudsDefinition* clouds);
|
||||||
|
|
||||||
|
void setTerrain(TerrainDefinition* terrain);
|
||||||
|
inline TerrainDefinition* getTerrain() {return terrain;}
|
||||||
|
void getTerrain(TerrainDefinition* terrain);
|
||||||
|
|
||||||
|
void setTextures(TexturesDefinition* textures);
|
||||||
|
inline TexturesDefinition* getTextures() {return textures;}
|
||||||
|
void getTextures(TexturesDefinition* textures);
|
||||||
|
|
||||||
|
void setWater(WaterDefinition* water);
|
||||||
|
inline WaterDefinition* getWater() {return water;}
|
||||||
|
void getWater(WaterDefinition* water);
|
||||||
|
|
||||||
|
void bindToRenderer(Renderer* renderer);
|
||||||
|
|
||||||
|
private:
|
||||||
|
AtmosphereDefinition* atmosphere;
|
||||||
|
CameraDefinition* camera;
|
||||||
|
CloudsDefinition* clouds;
|
||||||
|
TerrainDefinition* terrain;
|
||||||
|
TexturesDefinition* textures;
|
||||||
|
WaterDefinition* water;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Transitional C-API
|
||||||
|
RENDERINGSHARED_EXPORT void sceneryInit();
|
||||||
|
RENDERINGSHARED_EXPORT void sceneryQuit();
|
||||||
|
|
||||||
|
RENDERINGSHARED_EXPORT void sceneryAutoPreset(int seed);
|
||||||
|
|
||||||
|
typedef void (*SceneryCustomDataCallback)(PackStream* stream, void* data);
|
||||||
|
RENDERINGSHARED_EXPORT void scenerySetCustomDataCallback(SceneryCustomDataCallback callback_save, SceneryCustomDataCallback callback_load, void* data);
|
||||||
|
|
||||||
|
RENDERINGSHARED_EXPORT void scenerySave(PackStream* stream);
|
||||||
|
RENDERINGSHARED_EXPORT void sceneryLoad(PackStream* stream);
|
||||||
|
|
||||||
|
RENDERINGSHARED_EXPORT void scenerySetAtmosphere(AtmosphereDefinition* atmosphere);
|
||||||
|
RENDERINGSHARED_EXPORT void sceneryGetAtmosphere(AtmosphereDefinition* atmosphere);
|
||||||
|
|
||||||
|
RENDERINGSHARED_EXPORT void scenerySetCamera(CameraDefinition* camera);
|
||||||
|
RENDERINGSHARED_EXPORT void sceneryGetCamera(CameraDefinition* camera);
|
||||||
|
|
||||||
|
RENDERINGSHARED_EXPORT void scenerySetClouds(CloudsDefinition* clouds);
|
||||||
|
RENDERINGSHARED_EXPORT void sceneryGetClouds(CloudsDefinition* clouds);
|
||||||
|
|
||||||
|
RENDERINGSHARED_EXPORT void scenerySetTerrain(TerrainDefinition* terrain);
|
||||||
|
RENDERINGSHARED_EXPORT void sceneryGetTerrain(TerrainDefinition* terrain);
|
||||||
|
RENDERINGSHARED_EXPORT TerrainDefinition* sceneryGetTerrainDirect();
|
||||||
|
|
||||||
|
RENDERINGSHARED_EXPORT void scenerySetTextures(TexturesDefinition* textures);
|
||||||
|
RENDERINGSHARED_EXPORT void sceneryGetTextures(TexturesDefinition* textures);
|
||||||
|
|
||||||
|
RENDERINGSHARED_EXPORT void scenerySetWater(WaterDefinition* water);
|
||||||
|
RENDERINGSHARED_EXPORT void sceneryGetWater(WaterDefinition* water);
|
||||||
|
|
||||||
|
RENDERINGSHARED_EXPORT Renderer* sceneryCreateStandardRenderer();
|
||||||
|
RENDERINGSHARED_EXPORT void sceneryBindRenderer(Renderer* renderer);
|
||||||
|
RENDERINGSHARED_EXPORT void sceneryRenderFirstPass(Renderer* renderer);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // SCENERY_H
|
|
@ -3,7 +3,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "scenery.h"
|
#include "Scenery.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "tools/boundingbox.h"
|
#include "tools/boundingbox.h"
|
||||||
|
|
||||||
|
@ -95,6 +95,7 @@ void cameraValidateDefinition(CameraDefinition* definition, int check_above)
|
||||||
|
|
||||||
if (check_above)
|
if (check_above)
|
||||||
{
|
{
|
||||||
|
/* TODO Don't create a renderer for this ! */
|
||||||
renderer = sceneryCreateStandardRenderer();
|
renderer = sceneryCreateStandardRenderer();
|
||||||
terrain_height = renderer->terrain->getHeight(renderer, definition->location.x, definition->location.z, 1) + 0.5;
|
terrain_height = renderer->terrain->getHeight(renderer, definition->location.x, definition->location.z, 1) + 0.5;
|
||||||
water_height = renderer->water->getHeightInfo(renderer).max_height + 0.5;
|
water_height = renderer->water->getHeightInfo(renderer).max_height + 0.5;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "tools/data.h"
|
#include "tools/data.h"
|
||||||
#include "scenery.h"
|
#include "Scenery.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "opencl.h"
|
#include "opencl.h"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "System.h"
|
#include "System.h"
|
||||||
#include "Thread.h"
|
#include "Thread.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "scenery.h"
|
#include "Scenery.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
static RayCastingResult _RAYCASTING_NULL = {0};
|
static RayCastingResult _RAYCASTING_NULL = {0};
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
CONFIG += console
|
CONFIG += console
|
||||||
CONFIG -= app_bundle
|
CONFIG -= app_bundle
|
||||||
CONFIG -= qt
|
|
||||||
|
|
||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
TARGET = paysages_rendering
|
TARGET = paysages_rendering
|
||||||
|
@ -12,7 +11,6 @@ INCLUDEPATH += $$PWD/..
|
||||||
|
|
||||||
SOURCES += main.c \
|
SOURCES += main.c \
|
||||||
tools.c \
|
tools.c \
|
||||||
scenery.c \
|
|
||||||
renderer.c \
|
renderer.c \
|
||||||
render.c \
|
render.c \
|
||||||
opencl.c \
|
opencl.c \
|
||||||
|
@ -64,11 +62,11 @@ SOURCES += main.c \
|
||||||
water/wat_raster.c \
|
water/wat_raster.c \
|
||||||
water/wat_preview.c \
|
water/wat_preview.c \
|
||||||
water/wat_presets.c \
|
water/wat_presets.c \
|
||||||
water/wat_definition.c
|
water/wat_definition.c \
|
||||||
|
Scenery.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
tools.h \
|
tools.h \
|
||||||
scenery.h \
|
|
||||||
renderer.h \
|
renderer.h \
|
||||||
render.h \
|
render.h \
|
||||||
opencl.h \
|
opencl.h \
|
||||||
|
@ -110,7 +108,8 @@ HEADERS += \
|
||||||
tools/array.h \
|
tools/array.h \
|
||||||
water/public.h \
|
water/public.h \
|
||||||
water/private.h \
|
water/private.h \
|
||||||
rendering_global.h
|
rendering_global.h \
|
||||||
|
Scenery.h
|
||||||
|
|
||||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../system/release/ -lpaysages_system
|
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:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../system/debug/ -lpaysages_system
|
||||||
|
|
|
@ -20,6 +20,15 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Namespace using */
|
/* Namespace using */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
namespace paysages
|
||||||
|
{
|
||||||
|
namespace system {}
|
||||||
|
namespace rendering {}
|
||||||
|
}
|
||||||
|
using namespace paysages::system;
|
||||||
|
using namespace paysages::rendering;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Global import */
|
/* Global import */
|
||||||
|
|
||||||
|
|
|
@ -1,246 +0,0 @@
|
||||||
#include "scenery.h"
|
|
||||||
|
|
||||||
#include <time.h>
|
|
||||||
#include "rendering/terrain/ter_raster.h"
|
|
||||||
#include "rendering/tools.h"
|
|
||||||
#include "rendering/tools/color.h"
|
|
||||||
#include "rendering/tools/euclid.h"
|
|
||||||
#include "rendering/render.h"
|
|
||||||
|
|
||||||
static AtmosphereDefinition* _atmosphere;
|
|
||||||
static CameraDefinition* _camera;
|
|
||||||
static CloudsDefinition* _clouds;
|
|
||||||
static TerrainDefinition* _terrain;
|
|
||||||
static TexturesDefinition* _textures;
|
|
||||||
static WaterDefinition* _water;
|
|
||||||
|
|
||||||
static SceneryCustomDataCallback _custom_save = NULL;
|
|
||||||
static SceneryCustomDataCallback _custom_load = NULL;
|
|
||||||
static void* _custom_data = NULL;
|
|
||||||
|
|
||||||
void sceneryInit()
|
|
||||||
{
|
|
||||||
noiseInit();
|
|
||||||
|
|
||||||
_atmosphere = AtmosphereDefinitionClass.create();
|
|
||||||
_camera = cameraCreateDefinition();
|
|
||||||
_clouds = CloudsDefinitionClass.create();
|
|
||||||
_terrain = TerrainDefinitionClass.create();
|
|
||||||
_textures = TexturesDefinitionClass.create();
|
|
||||||
_water = WaterDefinitionClass.create();
|
|
||||||
|
|
||||||
_custom_save = NULL;
|
|
||||||
_custom_load = NULL;
|
|
||||||
|
|
||||||
sceneryAutoPreset(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void sceneryQuit()
|
|
||||||
{
|
|
||||||
AtmosphereDefinitionClass.destroy(_atmosphere);
|
|
||||||
cameraDeleteDefinition(_camera);
|
|
||||||
CloudsDefinitionClass.destroy(_clouds);
|
|
||||||
TerrainDefinitionClass.destroy(_terrain);
|
|
||||||
TexturesDefinitionClass.destroy(_textures);
|
|
||||||
AtmosphereDefinitionClass.destroy(_water);
|
|
||||||
|
|
||||||
noiseQuit();
|
|
||||||
}
|
|
||||||
|
|
||||||
void sceneryAutoPreset(int seed)
|
|
||||||
{
|
|
||||||
if (!seed)
|
|
||||||
{
|
|
||||||
seed = time(NULL);
|
|
||||||
}
|
|
||||||
srand(seed);
|
|
||||||
|
|
||||||
terrainAutoPreset(_terrain, TERRAIN_PRESET_STANDARD);
|
|
||||||
texturesAutoPreset(_textures, TEXTURES_PRESET_FULL);
|
|
||||||
atmosphereAutoPreset(_atmosphere, ATMOSPHERE_PRESET_CLEAR_DAY);
|
|
||||||
waterAutoPreset(_water, WATER_PRESET_LAKE);
|
|
||||||
cloudsAutoPreset(_clouds, CLOUDS_PRESET_PARTLY_CLOUDY);
|
|
||||||
|
|
||||||
cameraSetLocation(_camera, VECTOR_ZERO);
|
|
||||||
cameraSetTarget(_camera, VECTOR_NORTH);
|
|
||||||
cameraValidateDefinition(_camera, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void scenerySetCustomDataCallback(SceneryCustomDataCallback callback_save, SceneryCustomDataCallback callback_load, void* data)
|
|
||||||
{
|
|
||||||
_custom_save = callback_save;
|
|
||||||
_custom_load = callback_load;
|
|
||||||
_custom_data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
void scenerySave(PackStream* stream)
|
|
||||||
{
|
|
||||||
noiseSave(stream);
|
|
||||||
AtmosphereDefinitionClass.save(stream, _atmosphere);
|
|
||||||
cameraSave(stream, _camera);
|
|
||||||
CloudsDefinitionClass.save(stream, _clouds);
|
|
||||||
TerrainDefinitionClass.save(stream, _terrain);
|
|
||||||
TexturesDefinitionClass.save(stream, _textures);
|
|
||||||
WaterDefinitionClass.save(stream, _water);
|
|
||||||
|
|
||||||
if (_custom_save)
|
|
||||||
{
|
|
||||||
_custom_save(stream, _custom_data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void sceneryLoad(PackStream* stream)
|
|
||||||
{
|
|
||||||
/* TODO Use intermediary definitions ? */
|
|
||||||
|
|
||||||
noiseLoad(stream);
|
|
||||||
AtmosphereDefinitionClass.load(stream, _atmosphere);
|
|
||||||
cameraLoad(stream, _camera);
|
|
||||||
CloudsDefinitionClass.load(stream, _clouds);
|
|
||||||
TerrainDefinitionClass.load(stream, _terrain);
|
|
||||||
TexturesDefinitionClass.load(stream, _textures);
|
|
||||||
WaterDefinitionClass.load(stream, _water);
|
|
||||||
|
|
||||||
if (_custom_load)
|
|
||||||
{
|
|
||||||
_custom_load(stream, _custom_data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void scenerySetAtmosphere(AtmosphereDefinition* atmosphere)
|
|
||||||
{
|
|
||||||
AtmosphereDefinitionClass.copy(atmosphere, _atmosphere);
|
|
||||||
}
|
|
||||||
|
|
||||||
void sceneryGetAtmosphere(AtmosphereDefinition* atmosphere)
|
|
||||||
{
|
|
||||||
AtmosphereDefinitionClass.copy(_atmosphere, atmosphere);
|
|
||||||
}
|
|
||||||
|
|
||||||
void scenerySetCamera(CameraDefinition* camera)
|
|
||||||
{
|
|
||||||
cameraCopyDefinition(camera, _camera);
|
|
||||||
cameraValidateDefinition(_camera, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void sceneryGetCamera(CameraDefinition* camera)
|
|
||||||
{
|
|
||||||
cameraCopyDefinition(_camera, camera);
|
|
||||||
}
|
|
||||||
|
|
||||||
void scenerySetClouds(CloudsDefinition* clouds)
|
|
||||||
{
|
|
||||||
CloudsDefinitionClass.copy(clouds, _clouds);
|
|
||||||
}
|
|
||||||
|
|
||||||
void sceneryGetClouds(CloudsDefinition* clouds)
|
|
||||||
{
|
|
||||||
CloudsDefinitionClass.copy(_clouds, clouds);
|
|
||||||
}
|
|
||||||
|
|
||||||
void scenerySetTerrain(TerrainDefinition* terrain)
|
|
||||||
{
|
|
||||||
TerrainDefinitionClass.copy(terrain, _terrain);
|
|
||||||
|
|
||||||
cameraValidateDefinition(_camera, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void sceneryGetTerrain(TerrainDefinition* terrain)
|
|
||||||
{
|
|
||||||
TerrainDefinitionClass.copy(_terrain, terrain);
|
|
||||||
}
|
|
||||||
|
|
||||||
TerrainDefinition* sceneryGetTerrainDirect()
|
|
||||||
{
|
|
||||||
return _terrain;
|
|
||||||
}
|
|
||||||
|
|
||||||
void scenerySetTextures(TexturesDefinition* textures)
|
|
||||||
{
|
|
||||||
TexturesDefinitionClass.copy(textures, _textures);
|
|
||||||
|
|
||||||
cameraValidateDefinition(_camera, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void sceneryGetTextures(TexturesDefinition* textures)
|
|
||||||
{
|
|
||||||
TexturesDefinitionClass.copy(_textures, textures);
|
|
||||||
}
|
|
||||||
|
|
||||||
void scenerySetWater(WaterDefinition* water)
|
|
||||||
{
|
|
||||||
WaterDefinitionClass.copy(water, _water);
|
|
||||||
|
|
||||||
cameraValidateDefinition(_camera, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void sceneryGetWater(WaterDefinition* water)
|
|
||||||
{
|
|
||||||
WaterDefinitionClass.copy(_water, water);
|
|
||||||
}
|
|
||||||
|
|
||||||
void sceneryRenderFirstPass(Renderer* renderer)
|
|
||||||
{
|
|
||||||
terrainRenderSurface(renderer);
|
|
||||||
waterRenderSurface(renderer);
|
|
||||||
atmosphereRenderSkydome(renderer);
|
|
||||||
}
|
|
||||||
|
|
||||||
/******* Standard renderer *********/
|
|
||||||
static RayCastingResult _rayWalking(Renderer* renderer, Vector3 location, Vector3 direction, int terrain, int water, int sky, int clouds)
|
|
||||||
{
|
|
||||||
RayCastingResult result;
|
|
||||||
Color sky_color;
|
|
||||||
|
|
||||||
UNUSED(terrain);
|
|
||||||
UNUSED(water);
|
|
||||||
UNUSED(sky);
|
|
||||||
UNUSED(clouds);
|
|
||||||
|
|
||||||
result = renderer->terrain->castRay(renderer, location, direction);
|
|
||||||
if (!result.hit)
|
|
||||||
{
|
|
||||||
sky_color = renderer->atmosphere->getSkyColor(renderer, direction).final;
|
|
||||||
|
|
||||||
result.hit = 1;
|
|
||||||
result.hit_location = v3Add(location, v3Scale(direction, 1000.0));
|
|
||||||
result.hit_color = renderer->clouds->getColor(renderer, sky_color, location, result.hit_location);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static double _getPrecision(Renderer* renderer, Vector3 location)
|
|
||||||
{
|
|
||||||
Vector3 projected;
|
|
||||||
|
|
||||||
projected = cameraProject(renderer->render_camera, location);
|
|
||||||
projected.x += 1.0;
|
|
||||||
//projected.y += 1.0;
|
|
||||||
|
|
||||||
return v3Norm(v3Sub(cameraUnproject(renderer->render_camera, projected), location)); // / (double)render_quality;
|
|
||||||
}
|
|
||||||
|
|
||||||
Renderer* sceneryCreateStandardRenderer()
|
|
||||||
{
|
|
||||||
Renderer* result;
|
|
||||||
|
|
||||||
result = rendererCreate();
|
|
||||||
|
|
||||||
result->rayWalking = _rayWalking;
|
|
||||||
result->getPrecision = _getPrecision;
|
|
||||||
|
|
||||||
sceneryBindRenderer(result);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void sceneryBindRenderer(Renderer* renderer)
|
|
||||||
{
|
|
||||||
cameraCopyDefinition(_camera, renderer->render_camera);
|
|
||||||
AtmosphereRendererClass.bind(renderer, _atmosphere);
|
|
||||||
TerrainRendererClass.bind(renderer, _terrain);
|
|
||||||
TexturesRendererClass.bind(renderer, _textures);
|
|
||||||
CloudsRendererClass.bind(renderer, _clouds);
|
|
||||||
WaterRendererClass.bind(renderer, _water);
|
|
||||||
}
|
|
|
@ -1,64 +0,0 @@
|
||||||
#ifndef _PAYSAGES_SCENERY_H_
|
|
||||||
#define _PAYSAGES_SCENERY_H_
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Scenery management.
|
|
||||||
*
|
|
||||||
* This module handles all scenery components (terrain, water...) definitions and maintains
|
|
||||||
* a standard renderer.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "rendering_global.h"
|
|
||||||
#include "tools/pack.h"
|
|
||||||
#include "atmosphere/public.h"
|
|
||||||
#include "clouds/public.h"
|
|
||||||
#include "terrain/public.h"
|
|
||||||
#include "textures/public.h"
|
|
||||||
#include "water/public.h"
|
|
||||||
#include "camera.h"
|
|
||||||
#include "renderer.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef void (*SceneryCustomDataCallback)(PackStream* stream, void* data);
|
|
||||||
|
|
||||||
RENDERINGSHARED_EXPORT void sceneryInit();
|
|
||||||
RENDERINGSHARED_EXPORT void sceneryQuit();
|
|
||||||
|
|
||||||
RENDERINGSHARED_EXPORT void sceneryAutoPreset(int seed);
|
|
||||||
|
|
||||||
RENDERINGSHARED_EXPORT void scenerySetCustomDataCallback(SceneryCustomDataCallback callback_save, SceneryCustomDataCallback callback_load, void* data);
|
|
||||||
|
|
||||||
RENDERINGSHARED_EXPORT void scenerySave(PackStream* stream);
|
|
||||||
RENDERINGSHARED_EXPORT void sceneryLoad(PackStream* stream);
|
|
||||||
|
|
||||||
RENDERINGSHARED_EXPORT void scenerySetAtmosphere(AtmosphereDefinition* atmosphere);
|
|
||||||
RENDERINGSHARED_EXPORT void sceneryGetAtmosphere(AtmosphereDefinition* atmosphere);
|
|
||||||
|
|
||||||
RENDERINGSHARED_EXPORT void scenerySetCamera(CameraDefinition* camera);
|
|
||||||
RENDERINGSHARED_EXPORT void sceneryGetCamera(CameraDefinition* camera);
|
|
||||||
|
|
||||||
RENDERINGSHARED_EXPORT void scenerySetClouds(CloudsDefinition* clouds);
|
|
||||||
RENDERINGSHARED_EXPORT void sceneryGetClouds(CloudsDefinition* clouds);
|
|
||||||
|
|
||||||
RENDERINGSHARED_EXPORT void scenerySetTerrain(TerrainDefinition* terrain);
|
|
||||||
RENDERINGSHARED_EXPORT void sceneryGetTerrain(TerrainDefinition* terrain);
|
|
||||||
RENDERINGSHARED_EXPORT TerrainDefinition* sceneryGetTerrainDirect();
|
|
||||||
|
|
||||||
RENDERINGSHARED_EXPORT void scenerySetTextures(TexturesDefinition* textures);
|
|
||||||
RENDERINGSHARED_EXPORT void sceneryGetTextures(TexturesDefinition* textures);
|
|
||||||
|
|
||||||
RENDERINGSHARED_EXPORT void scenerySetWater(WaterDefinition* water);
|
|
||||||
RENDERINGSHARED_EXPORT void sceneryGetWater(WaterDefinition* water);
|
|
||||||
|
|
||||||
RENDERINGSHARED_EXPORT Renderer* sceneryCreateStandardRenderer();
|
|
||||||
RENDERINGSHARED_EXPORT void sceneryBindRenderer(Renderer* renderer);
|
|
||||||
RENDERINGSHARED_EXPORT void sceneryRenderFirstPass(Renderer* renderer);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "private.h"
|
#include "private.h"
|
||||||
#include "scenery.h"
|
#include "Scenery.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "tex_preview.h"
|
#include "tex_preview.h"
|
||||||
#include "private.h"
|
#include "private.h"
|
||||||
|
|
||||||
#include "rendering/scenery.h"
|
#include "Scenery.h"
|
||||||
#include "rendering/tools.h"
|
#include "rendering/tools.h"
|
||||||
|
|
||||||
void TexturesPreviewLayerCoverage_bind(Renderer* renderer, TexturesDefinition* definition)
|
void TexturesPreviewLayerCoverage_bind(Renderer* renderer, TexturesDefinition* definition)
|
||||||
|
|
|
@ -28,6 +28,6 @@ namespace paysages
|
||||||
using namespace paysages::system;
|
using namespace paysages::system;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Global import */
|
/* Global imports */
|
||||||
|
|
||||||
#endif // SYSTEM_GLOBAL_H
|
#endif // SYSTEM_GLOBAL_H
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "testing/common.h"
|
#include "testing/common.h"
|
||||||
#include "System.h"
|
#include "System.h"
|
||||||
#include "rendering/scenery.h"
|
#include "rendering/Scenery.h"
|
||||||
|
|
||||||
#define OUTPUT_WIDTH 400
|
#define OUTPUT_WIDTH 400
|
||||||
#define OUTPUT_HEIGHT 300
|
#define OUTPUT_HEIGHT 300
|
||||||
|
|
Loading…
Reference in a new issue