Removed Scenery C-API and fixed some problems
This commit is contained in:
parent
5be3231ab9
commit
cdd9ef26a2
32 changed files with 253 additions and 493 deletions
|
@ -1,5 +1,10 @@
|
||||||
#define COLOR_INLINE_CPP
|
#define COLOR_INLINE_CPP
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
#include <cmath>
|
||||||
|
#include <cassert>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef COLOR_H
|
#ifdef COLOR_H
|
||||||
# define METHSPEC inline
|
# define METHSPEC inline
|
||||||
#else
|
#else
|
||||||
|
@ -99,21 +104,21 @@ METHSPEC void Color::mask(const Color& mask)
|
||||||
METHSPEC double Color::normalize()
|
METHSPEC double Color::normalize()
|
||||||
{
|
{
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
assert(col->r >= 0.0);
|
assert(r >= 0.0);
|
||||||
assert(col->g >= 0.0);
|
assert(g >= 0.0);
|
||||||
assert(col->b >= 0.0);
|
assert(b >= 0.0);
|
||||||
assert(col->a >= 0.0);
|
assert(a >= 0.0);
|
||||||
#ifdef isnan
|
#ifdef isnan
|
||||||
assert(!isnan(col->r));
|
assert(!isnan(r));
|
||||||
assert(!isnan(col->g));
|
assert(!isnan(g));
|
||||||
assert(!isnan(col->b));
|
assert(!isnan(b));
|
||||||
assert(!isnan(col->a));
|
assert(!isnan(a));
|
||||||
#endif
|
#endif
|
||||||
#ifdef isfinite
|
#ifdef isfinite
|
||||||
assert(isfinite(col->r));
|
assert(isfinite(r));
|
||||||
assert(isfinite(col->g));
|
assert(isfinite(g));
|
||||||
assert(isfinite(col->b));
|
assert(isfinite(b));
|
||||||
assert(isfinite(col->a));
|
assert(isfinite(a));
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,18 @@
|
||||||
#include "PackStream.h"
|
#include "PackStream.h"
|
||||||
#include "RandomGenerator.h"
|
#include "RandomGenerator.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
#define MAX_LEVEL_COUNT 30
|
#define MAX_LEVEL_COUNT 30
|
||||||
|
|
||||||
void noiseInit()
|
/* Global noise state */
|
||||||
|
|
||||||
|
void noiseQuit()
|
||||||
|
{
|
||||||
|
noiseNaiveQuit();
|
||||||
|
}
|
||||||
|
|
||||||
|
int noiseInit()
|
||||||
{
|
{
|
||||||
noiseSimplexInit();
|
noiseSimplexInit();
|
||||||
noisePerlinInit();
|
noisePerlinInit();
|
||||||
|
@ -34,12 +42,13 @@ void noiseInit()
|
||||||
}
|
}
|
||||||
printf("%f %f\n", min, max);
|
printf("%f %f\n", min, max);
|
||||||
noiseDeleteGenerator(noise);*/
|
noiseDeleteGenerator(noise);*/
|
||||||
|
|
||||||
|
atexit(noiseQuit);
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void noiseQuit()
|
static int inited = noiseInit();
|
||||||
{
|
|
||||||
noiseNaiveQuit();
|
|
||||||
}
|
|
||||||
|
|
||||||
void noiseSave(PackStream* stream)
|
void noiseSave(PackStream* stream)
|
||||||
{
|
{
|
||||||
|
@ -51,6 +60,8 @@ void noiseLoad(PackStream* stream)
|
||||||
noiseNaiveLoad(stream);
|
noiseNaiveLoad(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* NoiseGenerator class */
|
||||||
|
|
||||||
NoiseGenerator::NoiseGenerator()
|
NoiseGenerator::NoiseGenerator()
|
||||||
{
|
{
|
||||||
function.algorithm = NOISE_FUNCTION_SIMPLEX;
|
function.algorithm = NOISE_FUNCTION_SIMPLEX;
|
||||||
|
|
|
@ -92,8 +92,6 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BASICSSHARED_EXPORT void noiseInit();
|
|
||||||
BASICSSHARED_EXPORT void noiseQuit();
|
|
||||||
BASICSSHARED_EXPORT void noiseSave(PackStream* stream);
|
BASICSSHARED_EXPORT void noiseSave(PackStream* stream);
|
||||||
BASICSSHARED_EXPORT void noiseLoad(PackStream* stream);
|
BASICSSHARED_EXPORT void noiseLoad(PackStream* stream);
|
||||||
|
|
||||||
|
|
|
@ -34,3 +34,9 @@ else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../definition/debug
|
||||||
else:unix: LIBS += -L$$OUT_PWD/../definition/ -lpaysages_definition
|
else:unix: LIBS += -L$$OUT_PWD/../definition/ -lpaysages_definition
|
||||||
INCLUDEPATH += $$PWD/../definition
|
INCLUDEPATH += $$PWD/../definition
|
||||||
DEPENDPATH += $$PWD/../definition
|
DEPENDPATH += $$PWD/../definition
|
||||||
|
|
||||||
|
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../render/software/release/ -lpaysages_render_software
|
||||||
|
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../render/software/debug/ -lpaysages_render_software
|
||||||
|
else:unix: LIBS += -L$$OUT_PWD/../render/software/ -lpaysages_render_software
|
||||||
|
INCLUDEPATH += $$PWD/../render/software
|
||||||
|
DEPENDPATH += $$PWD/../render/software
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "rendering/renderer.h"
|
#include "rendering/renderer.h"
|
||||||
#include "rendering/atmosphere/public.h"
|
#include "rendering/atmosphere/public.h"
|
||||||
#include "rendering/camera.h"
|
#include "rendering/camera.h"
|
||||||
|
#include "SoftwareRenderer.h"
|
||||||
#include "Scenery.h"
|
#include "Scenery.h"
|
||||||
|
|
||||||
void startRender(Renderer* renderer, char* outputpath, RenderParams params)
|
void startRender(Renderer* renderer, char* outputpath, RenderParams params)
|
||||||
|
@ -45,7 +46,7 @@ void _previewUpdate(double progress)
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
Renderer* renderer;
|
SoftwareRenderer* renderer;
|
||||||
char* conf_file_path = NULL;
|
char* conf_file_path = NULL;
|
||||||
RenderParams conf_render_params = {800, 600, 1, 5};
|
RenderParams conf_render_params = {800, 600, 1, 5};
|
||||||
int conf_first_picture = 0;
|
int conf_first_picture = 0;
|
||||||
|
@ -166,24 +167,16 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
for (outputcount = 0; outputcount < conf_first_picture + conf_nb_pictures; outputcount++)
|
for (outputcount = 0; outputcount < conf_first_picture + conf_nb_pictures; outputcount++)
|
||||||
{
|
{
|
||||||
AtmosphereDefinition* atmo;
|
AtmosphereDefinition* atmo = Scenery::getCurrent()->getAtmosphere();
|
||||||
atmo = (AtmosphereDefinition*)AtmosphereDefinitionClass.create();
|
|
||||||
sceneryGetAtmosphere(atmo);
|
|
||||||
atmo->hour = (int)floor(conf_daytime_start * 24.0);
|
atmo->hour = (int)floor(conf_daytime_start * 24.0);
|
||||||
atmo->minute = (int)floor(fmod(conf_daytime_start, 1.0 / 24.0) * 24.0 * 60.0);
|
atmo->minute = (int)floor(fmod(conf_daytime_start, 1.0 / 24.0) * 24.0 * 60.0);
|
||||||
AtmosphereDefinitionClass.validate(atmo);
|
AtmosphereDefinitionClass.validate(atmo);
|
||||||
scenerySetAtmosphere(atmo);
|
|
||||||
AtmosphereDefinitionClass.destroy(atmo);
|
|
||||||
|
|
||||||
CameraDefinition* camera;
|
CameraDefinition* camera = Scenery::getCurrent()->getCamera();
|
||||||
Vector3 step = {conf_camera_step_x, conf_camera_step_y, conf_camera_step_z};
|
Vector3 step = {conf_camera_step_x, conf_camera_step_y, conf_camera_step_z};
|
||||||
camera = cameraCreateDefinition();
|
|
||||||
sceneryGetCamera(camera);
|
|
||||||
cameraSetLocation(camera, v3Add(cameraGetLocation(camera), step));
|
cameraSetLocation(camera, v3Add(cameraGetLocation(camera), step));
|
||||||
scenerySetCamera(camera);
|
|
||||||
cameraDeleteDefinition(camera);
|
|
||||||
|
|
||||||
renderer = sceneryCreateStandardRenderer();
|
renderer = new SoftwareRenderer(Scenery::getCurrent());
|
||||||
rendererSetPreviewCallbacks(renderer, NULL, NULL, _previewUpdate);
|
rendererSetPreviewCallbacks(renderer, NULL, NULL, _previewUpdate);
|
||||||
|
|
||||||
if (outputcount >= conf_first_picture)
|
if (outputcount >= conf_first_picture)
|
||||||
|
@ -192,7 +185,7 @@ int main(int argc, char** argv)
|
||||||
startRender(renderer, outputpath, conf_render_params);
|
startRender(renderer, outputpath, conf_render_params);
|
||||||
}
|
}
|
||||||
|
|
||||||
rendererDelete(renderer);
|
delete renderer;
|
||||||
|
|
||||||
conf_daytime_start += conf_daytime_step;
|
conf_daytime_start += conf_daytime_step;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,15 @@ WaterDefinition::WaterDefinition(BaseDefinition* parent):
|
||||||
foam_material = new SurfaceMaterial;
|
foam_material = new SurfaceMaterial;
|
||||||
_waves_noise = new NoiseGenerator;
|
_waves_noise = new NoiseGenerator;
|
||||||
|
|
||||||
//waterAutoPreset(this, WATER_PRESET_LAKE);
|
transparency_depth = 0.0;
|
||||||
|
transparency = 0.0;
|
||||||
|
reflection = 0.0;
|
||||||
|
lighting_depth = 0.0;
|
||||||
|
scaling = 1.0;
|
||||||
|
waves_height = 0.0;
|
||||||
|
detail_height = 0.0;
|
||||||
|
turbulence = 0.0;
|
||||||
|
foam_coverage = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WaterDefinition::~WaterDefinition()
|
WaterDefinition::~WaterDefinition()
|
||||||
|
@ -111,3 +119,51 @@ void WaterDefinition::validate()
|
||||||
materialValidate(material);
|
materialValidate(material);
|
||||||
materialValidate(foam_material);
|
materialValidate(foam_material);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WaterDefinition::applyPreset(WaterPreset preset)
|
||||||
|
{
|
||||||
|
_waves_noise->randomizeOffsets();
|
||||||
|
|
||||||
|
if (preset == WATER_PRESET_LAKE)
|
||||||
|
{
|
||||||
|
transparency = 0.5;
|
||||||
|
reflection = 0.4;
|
||||||
|
transparency_depth = 4.0;
|
||||||
|
material->base = colorToHSL(colorFromValues(0.08, 0.15, 0.2, 1.0));
|
||||||
|
depth_color->r = 0.0;
|
||||||
|
depth_color->g = 0.1;
|
||||||
|
depth_color->b = 0.1;
|
||||||
|
lighting_depth = 6.0;
|
||||||
|
scaling = 1.0;
|
||||||
|
waves_height = 0.8;
|
||||||
|
detail_height = 0.05;
|
||||||
|
turbulence = 0.1;
|
||||||
|
foam_coverage = 0.15;
|
||||||
|
}
|
||||||
|
else if (preset == WATER_PRESET_SEA)
|
||||||
|
{
|
||||||
|
transparency = 0.4;
|
||||||
|
reflection = 0.35;
|
||||||
|
transparency_depth = 3.0;
|
||||||
|
material->base = colorToHSL(colorFromValues(0.05, 0.18, 0.2, 1.0));
|
||||||
|
depth_color->r = 0.0;
|
||||||
|
depth_color->g = 0.18;
|
||||||
|
depth_color->b = 0.15;
|
||||||
|
lighting_depth = 4.0;
|
||||||
|
scaling = 1.5;
|
||||||
|
waves_height = 1.0;
|
||||||
|
detail_height = 0.06;
|
||||||
|
turbulence = 0.3;
|
||||||
|
foam_coverage = 0.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
depth_color->a = 1.0;
|
||||||
|
material->base.a = 1.0;
|
||||||
|
material->reflection = 1.0;
|
||||||
|
material->shininess = 16.0;
|
||||||
|
foam_material->base = colorToHSL(colorFromValues(0.8, 0.8, 0.8, 1.0));
|
||||||
|
foam_material->reflection = 0.1;
|
||||||
|
foam_material->shininess = 1.5;
|
||||||
|
|
||||||
|
validate();
|
||||||
|
}
|
||||||
|
|
|
@ -8,6 +8,12 @@
|
||||||
namespace paysages {
|
namespace paysages {
|
||||||
namespace definition {
|
namespace definition {
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
WATER_PRESET_LAKE,
|
||||||
|
WATER_PRESET_SEA
|
||||||
|
} WaterPreset;
|
||||||
|
|
||||||
class WaterDefinition: public BaseDefinition
|
class WaterDefinition: public BaseDefinition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -20,6 +26,8 @@ public:
|
||||||
virtual void copy(BaseDefinition* destination) const override;
|
virtual void copy(BaseDefinition* destination) const override;
|
||||||
virtual void validate() override;
|
virtual void validate() override;
|
||||||
|
|
||||||
|
void applyPreset(WaterPreset preset);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
double transparency;
|
double transparency;
|
||||||
double reflection;
|
double reflection;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include "dialogexplorer.h"
|
#include "dialogexplorer.h"
|
||||||
#include "Scenery.h"
|
#include "Scenery.h"
|
||||||
#include "BasePreview.h"
|
#include "BasePreview.h"
|
||||||
#include "renderer.h"
|
#include "SoftwareRenderer.h"
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
|
@ -232,38 +232,33 @@ void FreeFormHelper::processApplyClicked()
|
||||||
|
|
||||||
void FreeFormHelper::processExploreClicked()
|
void FreeFormHelper::processExploreClicked()
|
||||||
{
|
{
|
||||||
Renderer* renderer;
|
SoftwareRenderer renderer;
|
||||||
|
|
||||||
renderer = sceneryCreateStandardRenderer();
|
Scenery::getCurrent()->bindToRenderer(&renderer);
|
||||||
|
emit needAlterRenderer(&renderer);
|
||||||
emit needAlterRenderer(renderer);
|
|
||||||
|
|
||||||
CameraDefinition* camera = cameraCreateDefinition();
|
CameraDefinition* camera = cameraCreateDefinition();
|
||||||
sceneryGetCamera(camera);
|
Scenery::getCurrent()->getCamera(camera);
|
||||||
|
|
||||||
DialogExplorer* dialog = new DialogExplorer(_form_widget, camera, false, renderer);
|
DialogExplorer* dialog = new DialogExplorer(_form_widget, camera, false, &renderer);
|
||||||
dialog->exec();
|
dialog->exec();
|
||||||
delete dialog;
|
delete dialog;
|
||||||
|
|
||||||
rendererDelete(renderer);
|
|
||||||
cameraDeleteDefinition(camera);
|
cameraDeleteDefinition(camera);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeFormHelper::processRenderClicked()
|
void FreeFormHelper::processRenderClicked()
|
||||||
{
|
{
|
||||||
Renderer* renderer;
|
SoftwareRenderer renderer;
|
||||||
|
|
||||||
renderer = sceneryCreateStandardRenderer();
|
Scenery::getCurrent()->bindToRenderer(&renderer);
|
||||||
|
emit needAlterRenderer(&renderer);
|
||||||
|
|
||||||
emit needAlterRenderer(renderer);
|
DialogRender* dialog = new DialogRender(_form_widget, &renderer);
|
||||||
|
|
||||||
DialogRender* dialog = new DialogRender(_form_widget, renderer);
|
|
||||||
RenderParams params = {400, 300, 1, 3};
|
RenderParams params = {400, 300, 1, 3};
|
||||||
dialog->startRender(params);
|
dialog->startRender(params);
|
||||||
|
|
||||||
delete dialog;
|
delete dialog;
|
||||||
|
|
||||||
rendererDelete(renderer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeFormHelper::processDecimalChange(double value)
|
void FreeFormHelper::processDecimalChange(double value)
|
||||||
|
|
|
@ -126,11 +126,11 @@ MainWindow::MainWindow() :
|
||||||
ui->tool_panel->hide();
|
ui->tool_panel->hide();
|
||||||
//ui->menuBar->hide();
|
//ui->menuBar->hide();
|
||||||
|
|
||||||
scenerySetCustomDataCallback(MainWindow::guiSaveCallback, MainWindow::guiLoadCallback, this);
|
Scenery::getCurrent()->setCustomSaveCallbacks(MainWindow::guiSaveCallback, MainWindow::guiLoadCallback, this);
|
||||||
|
|
||||||
// FIXME AutoPreset has already been called by paysagesInit but we need to redo it here because
|
// FIXME AutoPreset has already been called by paysagesInit but we need to redo it here because
|
||||||
// the auto apply on FormRender overwrites the camera. Delete this when the render form is no longer a BaseForm.
|
// the auto apply on FormRender overwrites the camera. Delete this when the render form is no longer a BaseForm.
|
||||||
sceneryAutoPreset(0);
|
Scenery::getCurrent()->autoPreset(0);
|
||||||
refreshAll();
|
refreshAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,14 +160,11 @@ void MainWindow::refreshAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh preview OSD
|
// Refresh preview OSD
|
||||||
CameraDefinition* camera = cameraCreateDefinition();
|
|
||||||
PreviewOsd* osd = PreviewOsd::getInstance(QString("geolocation"));
|
PreviewOsd* osd = PreviewOsd::getInstance(QString("geolocation"));
|
||||||
osd->clearItems();
|
osd->clearItems();
|
||||||
sceneryGetCamera(camera);
|
|
||||||
PreviewOsdItem* item = osd->newItem(50, 50);
|
PreviewOsdItem* item = osd->newItem(50, 50);
|
||||||
item->drawCamera(camera);
|
item->drawCamera(Scenery::getCurrent()->getCamera());
|
||||||
item->setToolTip(QString(tr("Camera")));
|
item->setToolTip(QString(tr("Camera")));
|
||||||
cameraDeleteDefinition(camera);
|
|
||||||
|
|
||||||
emit refreshed();
|
emit refreshed();
|
||||||
}
|
}
|
||||||
|
@ -181,7 +178,7 @@ void MainWindow::fileNew()
|
||||||
{
|
{
|
||||||
if (QMessageBox::question(this, tr("Paysages 3D - New scenery"), tr("Do you want to start a new scenery ? Any unsaved changes will be lost."), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)
|
if (QMessageBox::question(this, tr("Paysages 3D - New scenery"), tr("Do you want to start a new scenery ? Any unsaved changes will be lost."), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)
|
||||||
{
|
{
|
||||||
sceneryAutoPreset(0);
|
Scenery::getCurrent()->autoPreset(0);
|
||||||
refreshAll();
|
refreshAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,7 +262,7 @@ void MainWindow::explore3D()
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
camera = cameraCreateDefinition();
|
camera = cameraCreateDefinition();
|
||||||
sceneryGetCamera(camera);
|
Scenery::getCurrent()->getCamera(camera);
|
||||||
|
|
||||||
DialogExplorer* dialog = new DialogExplorer(this, camera, true);
|
DialogExplorer* dialog = new DialogExplorer(this, camera, true);
|
||||||
result = dialog->exec();
|
result = dialog->exec();
|
||||||
|
@ -274,7 +271,7 @@ void MainWindow::explore3D()
|
||||||
|
|
||||||
if (result == QDialog::Accepted)
|
if (result == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
scenerySetCamera(camera);
|
Scenery::getCurrent()->setCamera(camera);
|
||||||
refreshAll();
|
refreshAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,13 +75,13 @@ FormAtmosphere::FormAtmosphere(QWidget *parent):
|
||||||
|
|
||||||
void FormAtmosphere::revertConfig()
|
void FormAtmosphere::revertConfig()
|
||||||
{
|
{
|
||||||
sceneryGetAtmosphere(_definition);
|
Scenery::getCurrent()->getAtmosphere(_definition);
|
||||||
BaseForm::revertConfig();
|
BaseForm::revertConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormAtmosphere::applyConfig()
|
void FormAtmosphere::applyConfig()
|
||||||
{
|
{
|
||||||
scenerySetAtmosphere(_definition);
|
Scenery::getCurrent()->setAtmosphere(_definition);
|
||||||
BaseForm::applyConfig();
|
BaseForm::applyConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,14 +125,14 @@ FormClouds::~FormClouds()
|
||||||
|
|
||||||
void FormClouds::revertConfig()
|
void FormClouds::revertConfig()
|
||||||
{
|
{
|
||||||
sceneryGetClouds(_definition);
|
Scenery::getCurrent()->getClouds(_definition);
|
||||||
BaseFormLayer::revertConfig();
|
BaseFormLayer::revertConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormClouds::applyConfig()
|
void FormClouds::applyConfig()
|
||||||
{
|
{
|
||||||
BaseFormLayer::applyConfig();
|
BaseFormLayer::applyConfig();
|
||||||
scenerySetClouds(_definition);
|
Scenery::getCurrent()->setClouds(_definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormClouds::layerReadCurrentFrom(void* layer_definition)
|
void FormClouds::layerReadCurrentFrom(void* layer_definition)
|
||||||
|
|
|
@ -64,7 +64,7 @@ protected:
|
||||||
|
|
||||||
void updateData()
|
void updateData()
|
||||||
{
|
{
|
||||||
sceneryBindRenderer(_renderer);
|
Scenery::getCurrent()->bindToRenderer(_renderer);
|
||||||
if (!_clouds_enabled)
|
if (!_clouds_enabled)
|
||||||
{
|
{
|
||||||
CloudsRendererClass.bind(_renderer, _no_clouds);
|
CloudsRendererClass.bind(_renderer, _no_clouds);
|
||||||
|
@ -170,13 +170,13 @@ void FormRender::loadPack(PackStream* stream)
|
||||||
|
|
||||||
void FormRender::revertConfig()
|
void FormRender::revertConfig()
|
||||||
{
|
{
|
||||||
sceneryGetCamera(_camera);
|
Scenery::getCurrent()->getCamera(_camera);
|
||||||
BaseForm::revertConfig();
|
BaseForm::revertConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormRender::applyConfig()
|
void FormRender::applyConfig()
|
||||||
{
|
{
|
||||||
scenerySetCamera(_camera);
|
Scenery::getCurrent()->setCamera(_camera);
|
||||||
BaseForm::applyConfig();
|
BaseForm::applyConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,6 @@ public:
|
||||||
|
|
||||||
PreviewTexturesCoverage(QWidget* parent, TexturesLayerDefinition* layer) : BasePreview(parent)
|
PreviewTexturesCoverage(QWidget* parent, TexturesLayerDefinition* layer) : BasePreview(parent)
|
||||||
{
|
{
|
||||||
_terrain = (TerrainDefinition*) TerrainDefinitionClass.create();
|
|
||||||
|
|
||||||
_renderer = rendererCreate();
|
_renderer = rendererCreate();
|
||||||
_renderer->render_quality = 3;
|
_renderer->render_quality = 3;
|
||||||
|
|
||||||
|
@ -46,8 +44,7 @@ protected:
|
||||||
|
|
||||||
void updateData()
|
void updateData()
|
||||||
{
|
{
|
||||||
sceneryGetTerrain(_terrain);
|
TerrainRendererClass.bind(_renderer, Scenery::getCurrent()->getTerrain());
|
||||||
TerrainRendererClass.bind(_renderer, _terrain);
|
|
||||||
|
|
||||||
//TexturesDefinitionClass.copy(_original_layer, _preview_layer);
|
//TexturesDefinitionClass.copy(_original_layer, _preview_layer);
|
||||||
}
|
}
|
||||||
|
@ -56,7 +53,6 @@ private:
|
||||||
Renderer* _renderer;
|
Renderer* _renderer;
|
||||||
TexturesLayerDefinition* _original_layer;
|
TexturesLayerDefinition* _original_layer;
|
||||||
TexturesDefinition* _preview_definition;
|
TexturesDefinition* _preview_definition;
|
||||||
TerrainDefinition* _terrain;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PreviewTexturesColor : public BasePreview
|
class PreviewTexturesColor : public BasePreview
|
||||||
|
@ -142,14 +138,14 @@ FormTextures::~FormTextures()
|
||||||
|
|
||||||
void FormTextures::revertConfig()
|
void FormTextures::revertConfig()
|
||||||
{
|
{
|
||||||
sceneryGetTextures(_definition);
|
Scenery::getCurrent()->getTextures(_definition);
|
||||||
BaseFormLayer::revertConfig();
|
BaseFormLayer::revertConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormTextures::applyConfig()
|
void FormTextures::applyConfig()
|
||||||
{
|
{
|
||||||
BaseFormLayer::applyConfig();
|
BaseFormLayer::applyConfig();
|
||||||
scenerySetTextures(_definition);
|
Scenery::getCurrent()->setTextures(_definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormTextures::layerReadCurrentFrom(void* layer_definition)
|
void FormTextures::layerReadCurrentFrom(void* layer_definition)
|
||||||
|
|
|
@ -45,12 +45,7 @@ protected:
|
||||||
void updateData()
|
void updateData()
|
||||||
{
|
{
|
||||||
WaterRendererClass.bind(_renderer, _definition);
|
WaterRendererClass.bind(_renderer, _definition);
|
||||||
|
TerrainRendererClass.bind(_renderer, Scenery::getCurrent()->getTerrain());
|
||||||
// TODO Do this only on full refresh
|
|
||||||
TerrainDefinition* terrain = (TerrainDefinition*) TerrainDefinitionClass.create();
|
|
||||||
sceneryGetTerrain(terrain);
|
|
||||||
TerrainRendererClass.bind(_renderer, terrain);
|
|
||||||
TerrainDefinitionClass.destroy(terrain);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleChangeEvent(QString key, bool value)
|
void toggleChangeEvent(QString key, bool value)
|
||||||
|
@ -263,13 +258,13 @@ BaseForm(parent)
|
||||||
|
|
||||||
void FormWater::revertConfig()
|
void FormWater::revertConfig()
|
||||||
{
|
{
|
||||||
sceneryGetWater(_definition);
|
Scenery::getCurrent()->getWater(_definition);
|
||||||
BaseForm::revertConfig();
|
BaseForm::revertConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormWater::applyConfig()
|
void FormWater::applyConfig()
|
||||||
{
|
{
|
||||||
scenerySetWater(_definition);
|
Scenery::getCurrent()->setWater(_definition);
|
||||||
BaseForm::applyConfig();
|
BaseForm::applyConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +276,7 @@ void FormWater::configChangeEvent()
|
||||||
|
|
||||||
void FormWater::autoPresetSelected(int preset)
|
void FormWater::autoPresetSelected(int preset)
|
||||||
{
|
{
|
||||||
waterAutoPreset(_definition, (WaterPreset) preset);
|
_definition->applyPreset((WaterPreset)preset);
|
||||||
BaseForm::autoPresetSelected(preset);
|
BaseForm::autoPresetSelected(preset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,10 +69,7 @@ void MainTerrainForm::refreshFromLocalData()
|
||||||
|
|
||||||
void MainTerrainForm::refreshFromFellowData()
|
void MainTerrainForm::refreshFromFellowData()
|
||||||
{
|
{
|
||||||
TexturesDefinition* textures = (TexturesDefinition*)TexturesDefinitionClass.create();
|
double disp = texturesGetMaximalDisplacement(Scenery::getCurrent()->getTextures());
|
||||||
sceneryGetTextures(textures);
|
|
||||||
double disp = texturesGetMaximalDisplacement(textures);
|
|
||||||
TexturesDefinitionClass.destroy(textures);
|
|
||||||
|
|
||||||
if (disp == 0.0)
|
if (disp == 0.0)
|
||||||
{
|
{
|
||||||
|
@ -86,12 +83,12 @@ void MainTerrainForm::refreshFromFellowData()
|
||||||
|
|
||||||
void MainTerrainForm::updateLocalDataFromScenery()
|
void MainTerrainForm::updateLocalDataFromScenery()
|
||||||
{
|
{
|
||||||
sceneryGetTerrain(_terrain);
|
Scenery::getCurrent()->getTerrain(_terrain);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainTerrainForm::commitLocalDataToScenery()
|
void MainTerrainForm::commitLocalDataToScenery()
|
||||||
{
|
{
|
||||||
scenerySetTerrain(_terrain);
|
Scenery::getCurrent()->setTerrain(_terrain);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainTerrainForm::alterRenderer(Renderer* renderer)
|
void MainTerrainForm::alterRenderer(Renderer* renderer)
|
||||||
|
|
|
@ -130,12 +130,12 @@ void MainTexturesForm::selectPreset(int preset)
|
||||||
|
|
||||||
void MainTexturesForm::updateLocalDataFromScenery()
|
void MainTexturesForm::updateLocalDataFromScenery()
|
||||||
{
|
{
|
||||||
sceneryGetTextures(textures);
|
Scenery::getCurrent()->getTextures(textures);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainTexturesForm::commitLocalDataToScenery()
|
void MainTexturesForm::commitLocalDataToScenery()
|
||||||
{
|
{
|
||||||
scenerySetTextures(textures);
|
Scenery::getCurrent()->setTextures(textures);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainTexturesForm::refreshFromLocalData()
|
void MainTexturesForm::refreshFromLocalData()
|
||||||
|
|
|
@ -14,10 +14,7 @@
|
||||||
#include "terrain/ter_raster.h"
|
#include "terrain/ter_raster.h"
|
||||||
#include "WaterDefinition.h"
|
#include "WaterDefinition.h"
|
||||||
|
|
||||||
static Scenery* _main_scenery;
|
static Scenery _main_scenery;
|
||||||
static SceneryCustomDataCallback _custom_save = NULL;
|
|
||||||
static SceneryCustomDataCallback _custom_load = NULL;
|
|
||||||
static void* _custom_data = NULL;
|
|
||||||
|
|
||||||
Scenery::Scenery():
|
Scenery::Scenery():
|
||||||
BaseDefinition(NULL)
|
BaseDefinition(NULL)
|
||||||
|
@ -30,6 +27,10 @@ Scenery::Scenery():
|
||||||
water = new WaterDefinition(this);
|
water = new WaterDefinition(this);
|
||||||
|
|
||||||
addChild(water);
|
addChild(water);
|
||||||
|
|
||||||
|
_custom_load = NULL;
|
||||||
|
_custom_save = NULL;
|
||||||
|
_custom_data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Scenery::~Scenery()
|
Scenery::~Scenery()
|
||||||
|
@ -46,29 +47,50 @@ Scenery::~Scenery()
|
||||||
|
|
||||||
Scenery* Scenery::getCurrent()
|
Scenery* Scenery::getCurrent()
|
||||||
{
|
{
|
||||||
return _main_scenery;
|
return &_main_scenery;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scenery::setCustomSaveCallbacks(SceneryCustomDataCallback callback_save, SceneryCustomDataCallback callback_load, void* data)
|
||||||
|
{
|
||||||
|
_custom_save = callback_save;
|
||||||
|
_custom_load = callback_load;
|
||||||
|
_custom_data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scenery::save(PackStream* stream) const
|
void Scenery::save(PackStream* stream) const
|
||||||
{
|
{
|
||||||
BaseDefinition::save(stream);
|
BaseDefinition::save(stream);
|
||||||
|
|
||||||
|
noiseSave(stream);
|
||||||
|
|
||||||
AtmosphereDefinitionClass.save(stream, atmosphere);
|
AtmosphereDefinitionClass.save(stream, atmosphere);
|
||||||
cameraSave(stream, camera);
|
cameraSave(stream, camera);
|
||||||
CloudsDefinitionClass.save(stream, clouds);
|
CloudsDefinitionClass.save(stream, clouds);
|
||||||
TerrainDefinitionClass.save(stream, terrain);
|
TerrainDefinitionClass.save(stream, terrain);
|
||||||
TexturesDefinitionClass.save(stream, textures);
|
TexturesDefinitionClass.save(stream, textures);
|
||||||
|
|
||||||
|
if (_custom_save)
|
||||||
|
{
|
||||||
|
_custom_save(stream, _custom_data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scenery::load(PackStream* stream)
|
void Scenery::load(PackStream* stream)
|
||||||
{
|
{
|
||||||
BaseDefinition::load(stream);
|
BaseDefinition::load(stream);
|
||||||
|
|
||||||
|
noiseLoad(stream);
|
||||||
|
|
||||||
AtmosphereDefinitionClass.load(stream, atmosphere);
|
AtmosphereDefinitionClass.load(stream, atmosphere);
|
||||||
cameraLoad(stream, camera);
|
cameraLoad(stream, camera);
|
||||||
CloudsDefinitionClass.load(stream, clouds);
|
CloudsDefinitionClass.load(stream, clouds);
|
||||||
TerrainDefinitionClass.load(stream, terrain);
|
TerrainDefinitionClass.load(stream, terrain);
|
||||||
TexturesDefinitionClass.load(stream, textures);
|
TexturesDefinitionClass.load(stream, textures);
|
||||||
|
|
||||||
|
if (_custom_load)
|
||||||
|
{
|
||||||
|
_custom_load(stream, _custom_data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scenery::autoPreset(int seed)
|
void Scenery::autoPreset(int seed)
|
||||||
|
@ -82,7 +104,7 @@ void Scenery::autoPreset(int seed)
|
||||||
terrainAutoPreset(terrain, TERRAIN_PRESET_STANDARD);
|
terrainAutoPreset(terrain, TERRAIN_PRESET_STANDARD);
|
||||||
texturesAutoPreset(textures, TEXTURES_PRESET_FULL);
|
texturesAutoPreset(textures, TEXTURES_PRESET_FULL);
|
||||||
atmosphereAutoPreset(atmosphere, ATMOSPHERE_PRESET_CLEAR_DAY);
|
atmosphereAutoPreset(atmosphere, ATMOSPHERE_PRESET_CLEAR_DAY);
|
||||||
waterAutoPreset(water, WATER_PRESET_LAKE);
|
water->applyPreset(WATER_PRESET_LAKE);
|
||||||
cloudsAutoPreset(clouds, CLOUDS_PRESET_PARTLY_CLOUDY);
|
cloudsAutoPreset(clouds, CLOUDS_PRESET_PARTLY_CLOUDY);
|
||||||
|
|
||||||
cameraSetLocation(camera, VECTOR_ZERO);
|
cameraSetLocation(camera, VECTOR_ZERO);
|
||||||
|
@ -150,140 +172,6 @@ void Scenery::getWater(WaterDefinition* water)
|
||||||
this->water->copy(water);
|
this->water->copy(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()
|
|
||||||
{
|
|
||||||
if (_main_scenery)
|
|
||||||
{
|
|
||||||
return _main_scenery->getTerrain();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
static RayCastingResult _rayWalking(Renderer* renderer, Vector3 location, Vector3 direction, int, int, int, int)
|
||||||
{
|
{
|
||||||
RayCastingResult result;
|
RayCastingResult result;
|
||||||
|
@ -313,24 +201,21 @@ static double _getPrecision(Renderer* renderer, Vector3 location)
|
||||||
return v3Norm(v3Sub(cameraUnproject(renderer->render_camera, projected), location)); // / (double)render_quality;
|
return v3Norm(v3Sub(cameraUnproject(renderer->render_camera, projected), location)); // / (double)render_quality;
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderer* sceneryCreateStandardRenderer()
|
void Scenery::bindToRenderer(Renderer* renderer)
|
||||||
{
|
{
|
||||||
Renderer* result;
|
// TODO Get rid of this !
|
||||||
|
renderer->rayWalking = _rayWalking;
|
||||||
|
renderer->getPrecision = _getPrecision;
|
||||||
|
|
||||||
result = rendererCreate();
|
cameraCopyDefinition(camera, renderer->render_camera);
|
||||||
|
AtmosphereRendererClass.bind(renderer, atmosphere);
|
||||||
result->rayWalking = _rayWalking;
|
TerrainRendererClass.bind(renderer, terrain);
|
||||||
result->getPrecision = _getPrecision;
|
TexturesRendererClass.bind(renderer, textures);
|
||||||
|
CloudsRendererClass.bind(renderer, clouds);
|
||||||
sceneryBindRenderer(result);
|
WaterRendererClass.bind(renderer, water);
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void sceneryBindRenderer(Renderer* renderer)
|
// Transitional C-API
|
||||||
{
|
|
||||||
_main_scenery->bindToRenderer(renderer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void sceneryRenderFirstPass(Renderer* renderer)
|
void sceneryRenderFirstPass(Renderer* renderer)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,11 +12,7 @@ class TerrainDefinition;
|
||||||
class TexturesDefinition;
|
class TexturesDefinition;
|
||||||
class Renderer;
|
class Renderer;
|
||||||
|
|
||||||
namespace paysages {
|
typedef void (*SceneryCustomDataCallback)(PackStream* stream, void* data);
|
||||||
namespace system {
|
|
||||||
class PackStream;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Global scenery management
|
* @brief Global scenery management
|
||||||
|
@ -31,6 +27,8 @@ public:
|
||||||
|
|
||||||
static Scenery* getCurrent();
|
static Scenery* getCurrent();
|
||||||
|
|
||||||
|
void setCustomSaveCallbacks(SceneryCustomDataCallback callback_save, SceneryCustomDataCallback callback_load, void* data);
|
||||||
|
|
||||||
virtual void save(PackStream* stream) const override;
|
virtual void save(PackStream* stream) const override;
|
||||||
virtual void load(PackStream* stream) override;
|
virtual void load(PackStream* stream) override;
|
||||||
|
|
||||||
|
@ -69,41 +67,14 @@ private:
|
||||||
TerrainDefinition* terrain;
|
TerrainDefinition* terrain;
|
||||||
TexturesDefinition* textures;
|
TexturesDefinition* textures;
|
||||||
WaterDefinition* water;
|
WaterDefinition* water;
|
||||||
|
|
||||||
|
SceneryCustomDataCallback _custom_save;
|
||||||
|
SceneryCustomDataCallback _custom_load;
|
||||||
|
void* _custom_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Transitional C-API
|
// 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);
|
RENDERINGSHARED_EXPORT void sceneryRenderFirstPass(Renderer* renderer);
|
||||||
|
|
||||||
#endif // SCENERY_H
|
#endif // SCENERY_H
|
||||||
|
|
|
@ -93,18 +93,15 @@ void cameraCopyDefinition(CameraDefinition* source, CameraDefinition* destinatio
|
||||||
|
|
||||||
void cameraValidateDefinition(CameraDefinition* definition, int check_above)
|
void cameraValidateDefinition(CameraDefinition* definition, int check_above)
|
||||||
{
|
{
|
||||||
Renderer* renderer;
|
|
||||||
double water_height, terrain_height, diff;
|
double water_height, terrain_height, diff;
|
||||||
Vector3 move;
|
Vector3 move;
|
||||||
Matrix4 rotation;
|
Matrix4 rotation;
|
||||||
|
|
||||||
if (check_above)
|
if (check_above)
|
||||||
{
|
{
|
||||||
/* TODO Don't create a renderer for this ! */
|
TerrainDefinition* terrain = Scenery::getCurrent()->getTerrain();
|
||||||
renderer = sceneryCreateStandardRenderer();
|
terrain_height = terrainGetInterpolatedHeight(terrain, definition->location.x, definition->location.z, 1, 1) + 0.5;
|
||||||
terrain_height = renderer->terrain->getHeight(renderer, definition->location.x, definition->location.z, 1) + 0.5;
|
water_height = terrainGetWaterHeight(terrain) + 0.5;
|
||||||
water_height = renderer->water->getHeightInfo(renderer).max_height + 0.5;
|
|
||||||
rendererDelete(renderer);
|
|
||||||
|
|
||||||
if (definition->location.y < water_height || definition->location.y < terrain_height)
|
if (definition->location.y < water_height || definition->location.y < terrain_height)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,13 +20,11 @@ void paysagesInit()
|
||||||
}
|
}
|
||||||
openclInit();
|
openclInit();
|
||||||
|
|
||||||
sceneryInit();
|
|
||||||
renderInit();
|
renderInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void paysagesQuit()
|
void paysagesQuit()
|
||||||
{
|
{
|
||||||
sceneryQuit();
|
|
||||||
renderQuit();
|
renderQuit();
|
||||||
|
|
||||||
openclQuit();
|
openclQuit();
|
||||||
|
@ -47,7 +45,7 @@ FileOperationResult paysagesSave(char* filepath)
|
||||||
version_header = (double)PAYSAGES_CURRENT_DATA_VERSION;
|
version_header = (double)PAYSAGES_CURRENT_DATA_VERSION;
|
||||||
stream.write(&version_header);
|
stream.write(&version_header);
|
||||||
|
|
||||||
scenerySave(&stream);
|
Scenery::getCurrent()->save(&stream);
|
||||||
|
|
||||||
return FILE_OPERATION_OK;
|
return FILE_OPERATION_OK;
|
||||||
}
|
}
|
||||||
|
@ -74,7 +72,7 @@ FileOperationResult paysagesLoad(char* filepath)
|
||||||
return FILE_OPERATION_VERSION_MISMATCH;
|
return FILE_OPERATION_VERSION_MISMATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
sceneryLoad(&stream);
|
Scenery::getCurrent()->load(&stream);
|
||||||
|
|
||||||
return FILE_OPERATION_OK;
|
return FILE_OPERATION_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -759,9 +759,16 @@ void renderPostProcess(RenderArea* area, int nbchunks)
|
||||||
area->callback_update(1.0);
|
area->callback_update(1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned int _getPicturePixel(void* data, int x, int y)
|
||||||
|
{
|
||||||
|
Color result = _getFinalPixel((RenderArea*)data, x, y);
|
||||||
|
result.normalize();
|
||||||
|
return result.to32BitBGRA();
|
||||||
|
}
|
||||||
|
|
||||||
int renderSaveToFile(RenderArea* area, const char* path)
|
int renderSaveToFile(RenderArea* area, const char* path)
|
||||||
{
|
{
|
||||||
return systemSavePictureFile(path, (PictureCallbackSavePixel)_getFinalPixel, area, area->params.width, area->params.height);
|
return systemSavePictureFile(path, _getPicturePixel, area, area->params.width, area->params.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderSetPreviewCallbacks(RenderArea* area, RenderCallbackStart start, RenderCallbackDraw draw, RenderCallbackUpdate update)
|
void renderSetPreviewCallbacks(RenderArea* area, RenderCallbackStart start, RenderCallbackDraw draw, RenderCallbackUpdate update)
|
||||||
|
|
|
@ -26,7 +26,6 @@ SOURCES += main.cpp \
|
||||||
clouds/clo_presets.cpp \
|
clouds/clo_presets.cpp \
|
||||||
clouds/clo_density.cpp \
|
clouds/clo_density.cpp \
|
||||||
clouds/clo_definition.cpp \
|
clouds/clo_definition.cpp \
|
||||||
shared/preview.cpp \
|
|
||||||
terrain/ter_render.cpp \
|
terrain/ter_render.cpp \
|
||||||
terrain/ter_raster.cpp \
|
terrain/ter_raster.cpp \
|
||||||
terrain/ter_preview.cpp \
|
terrain/ter_preview.cpp \
|
||||||
|
@ -53,7 +52,6 @@ SOURCES += main.cpp \
|
||||||
water/wat_render.cpp \
|
water/wat_render.cpp \
|
||||||
water/wat_raster.cpp \
|
water/wat_raster.cpp \
|
||||||
water/wat_preview.cpp \
|
water/wat_preview.cpp \
|
||||||
water/wat_presets.cpp \
|
|
||||||
water/wat_definition.cpp \
|
water/wat_definition.cpp \
|
||||||
Scenery.cpp
|
Scenery.cpp
|
||||||
|
|
||||||
|
@ -73,7 +71,6 @@ HEADERS += \
|
||||||
clouds/clo_preview.h \
|
clouds/clo_preview.h \
|
||||||
clouds/clo_density.h \
|
clouds/clo_density.h \
|
||||||
shared/types.h \
|
shared/types.h \
|
||||||
shared/preview.h \
|
|
||||||
terrain/ter_raster.h \
|
terrain/ter_raster.h \
|
||||||
terrain/public.h \
|
terrain/public.h \
|
||||||
terrain/private.h \
|
terrain/private.h \
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
#include "preview.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "../renderer.h"
|
|
||||||
#include "../camera.h"
|
|
||||||
|
|
||||||
struct PreviewRenderer
|
|
||||||
{
|
|
||||||
Renderer* renderer;
|
|
||||||
};
|
|
||||||
|
|
||||||
static PreviewRenderer* _createRenderer()
|
|
||||||
{
|
|
||||||
PreviewRenderer* renderer;
|
|
||||||
|
|
||||||
renderer = (PreviewRenderer*)malloc(sizeof (PreviewRenderer));
|
|
||||||
renderer->renderer = rendererCreate();
|
|
||||||
|
|
||||||
return renderer;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _deleteRenderer(PreviewRenderer* renderer)
|
|
||||||
{
|
|
||||||
rendererDelete(renderer->renderer);
|
|
||||||
free(renderer);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _setCamera(PreviewRenderer* renderer, Vector3 location, Vector3 target)
|
|
||||||
{
|
|
||||||
cameraSetLocation(renderer->renderer->render_camera, location);
|
|
||||||
cameraSetTarget(renderer->renderer->render_camera, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
PreviewClass previewCreateClass(FuncPreviewCustomizeRenderer customizeRenderer, FuncPreviewBindDefinition bindDefinition, FuncPreviewGetPixelColor getPixelColor)
|
|
||||||
{
|
|
||||||
PreviewClass result;
|
|
||||||
|
|
||||||
result.createRenderer = _createRenderer;
|
|
||||||
result.deleteRenderer = _deleteRenderer;
|
|
||||||
|
|
||||||
result.setCamera = _setCamera;
|
|
||||||
|
|
||||||
result.customizeRenderer = customizeRenderer;
|
|
||||||
result.bindDefinition = bindDefinition;
|
|
||||||
result.getPixelColor = getPixelColor;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
#ifndef _PAYSAGES_SHARED_PREVIEW_H_
|
|
||||||
#define _PAYSAGES_SHARED_PREVIEW_H_
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Preview management.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "../rendering_global.h"
|
|
||||||
#include "types.h"
|
|
||||||
|
|
||||||
typedef struct PreviewRenderer PreviewRenderer;
|
|
||||||
|
|
||||||
typedef void (*FuncPreviewCustomizeRenderer)(PreviewRenderer* preview_renderer, Renderer* renderer);
|
|
||||||
typedef void (*FuncPreviewBindDefinition)(PreviewRenderer* renderer, void* definition);
|
|
||||||
typedef Color (*FuncPreviewGetPixelColor)(PreviewRenderer* renderer, double x, double y, double scaling);
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
PreviewRenderer* (*createRenderer)();
|
|
||||||
void (*deleteRenderer)(PreviewRenderer* renderer);
|
|
||||||
|
|
||||||
void (*setCamera)(PreviewRenderer* renderer, Vector3 location, Vector3 target);
|
|
||||||
|
|
||||||
FuncPreviewCustomizeRenderer customizeRenderer;
|
|
||||||
FuncPreviewBindDefinition bindDefinition;
|
|
||||||
FuncPreviewGetPixelColor getPixelColor;
|
|
||||||
} PreviewClass;
|
|
||||||
|
|
||||||
RENDERINGSHARED_EXPORT PreviewClass previewCreateClass(FuncPreviewCustomizeRenderer customizeRenderer, FuncPreviewBindDefinition bindDefinition, FuncPreviewGetPixelColor getPixelColor);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -74,6 +74,7 @@ RENDERINGSHARED_EXPORT void terrainAlterPreviewRenderer(Renderer* renderer);
|
||||||
RENDERINGSHARED_EXPORT Color terrainGetPreviewColor(Renderer* renderer, double x, double z, double detail);
|
RENDERINGSHARED_EXPORT Color terrainGetPreviewColor(Renderer* renderer, double x, double z, double detail);
|
||||||
|
|
||||||
RENDERINGSHARED_EXPORT HeightInfo terrainGetHeightInfo(TerrainDefinition* definition);
|
RENDERINGSHARED_EXPORT HeightInfo terrainGetHeightInfo(TerrainDefinition* definition);
|
||||||
|
RENDERINGSHARED_EXPORT double terrainGetWaterHeight(TerrainDefinition* definition);
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|
|
@ -140,3 +140,8 @@ HeightInfo terrainGetHeightInfo(TerrainDefinition* definition)
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double terrainGetWaterHeight(TerrainDefinition* definition)
|
||||||
|
{
|
||||||
|
return definition->water_height * definition->height * definition->scaling;
|
||||||
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ static void _layerValidateDefinition(TexturesLayerDefinition* definition)
|
||||||
materialValidate(&definition->material);
|
materialValidate(&definition->material);
|
||||||
|
|
||||||
/* Update zone height range */
|
/* Update zone height range */
|
||||||
TerrainDefinition* terrain = sceneryGetTerrainDirect();
|
TerrainDefinition* terrain = Scenery::getCurrent()->getTerrain();
|
||||||
if (terrain)
|
if (terrain)
|
||||||
{
|
{
|
||||||
HeightInfo height_info = terrainGetHeightInfo(terrain);
|
HeightInfo height_info = terrainGetHeightInfo(terrain);
|
||||||
|
|
|
@ -6,11 +6,7 @@
|
||||||
|
|
||||||
void TexturesPreviewLayerCoverage_bind(Renderer* renderer, TexturesDefinition* definition)
|
void TexturesPreviewLayerCoverage_bind(Renderer* renderer, TexturesDefinition* definition)
|
||||||
{
|
{
|
||||||
TerrainDefinition* terrain = (TerrainDefinition*)TerrainDefinitionClass.create();
|
TerrainRendererClass.bind(renderer, Scenery::getCurrent()->getTerrain());
|
||||||
sceneryGetTerrain(terrain);
|
|
||||||
TerrainRendererClass.bind(renderer, terrain);
|
|
||||||
TerrainDefinitionClass.destroy(terrain);
|
|
||||||
|
|
||||||
TexturesRendererClass.bind(renderer, definition);
|
TexturesRendererClass.bind(renderer, definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,11 +70,7 @@ Color TexturesPreviewLayerLook_getColor(Renderer* renderer, double x, double y,
|
||||||
|
|
||||||
void TexturesPreviewCumul_bind(Renderer* renderer, TexturesDefinition* definition)
|
void TexturesPreviewCumul_bind(Renderer* renderer, TexturesDefinition* definition)
|
||||||
{
|
{
|
||||||
TerrainDefinition* terrain = (TerrainDefinition*)TerrainDefinitionClass.create();
|
TerrainRendererClass.bind(renderer, Scenery::getCurrent()->getTerrain());
|
||||||
sceneryGetTerrain(terrain);
|
|
||||||
TerrainRendererClass.bind(renderer, terrain);
|
|
||||||
TerrainDefinitionClass.destroy(terrain);
|
|
||||||
|
|
||||||
TexturesRendererClass.bind(renderer, definition);
|
TexturesRendererClass.bind(renderer, definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,18 +7,6 @@
|
||||||
#include "../tools/curve.h"
|
#include "../tools/curve.h"
|
||||||
#include "../tools/euclid.h"
|
#include "../tools/euclid.h"
|
||||||
|
|
||||||
namespace paysages {
|
|
||||||
namespace basics {
|
|
||||||
class NoiseGenerator;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
WATER_PRESET_LAKE,
|
|
||||||
WATER_PRESET_SEA
|
|
||||||
} WaterPreset;
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
Vector3 location;
|
Vector3 location;
|
||||||
|
@ -47,7 +35,6 @@ public:
|
||||||
RENDERINGSHARED_EXPORT extern StandardRenderer WaterRendererClass;
|
RENDERINGSHARED_EXPORT extern StandardRenderer WaterRendererClass;
|
||||||
|
|
||||||
RENDERINGSHARED_EXPORT void waterRenderSurface(Renderer* renderer);
|
RENDERINGSHARED_EXPORT void waterRenderSurface(Renderer* renderer);
|
||||||
RENDERINGSHARED_EXPORT void waterAutoPreset(WaterDefinition* definition, WaterPreset preset);
|
|
||||||
|
|
||||||
RENDERINGSHARED_EXPORT void waterAlterPreviewCoverageRenderer(Renderer* renderer);
|
RENDERINGSHARED_EXPORT void waterAlterPreviewCoverageRenderer(Renderer* renderer);
|
||||||
RENDERINGSHARED_EXPORT Color waterGetPreviewCoverage(Renderer* renderer, double x, double y, double scaling, int highlight_enabled);
|
RENDERINGSHARED_EXPORT Color waterGetPreviewCoverage(Renderer* renderer, double x, double y, double scaling, int highlight_enabled);
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
#include "private.h"
|
|
||||||
|
|
||||||
#include "WaterDefinition.h"
|
|
||||||
#include "SurfaceMaterial.h"
|
|
||||||
#include "NoiseGenerator.h"
|
|
||||||
|
|
||||||
void waterAutoPreset(WaterDefinition* definition, WaterPreset preset)
|
|
||||||
{
|
|
||||||
definition->_waves_noise->randomizeOffsets();
|
|
||||||
|
|
||||||
if (preset == WATER_PRESET_LAKE)
|
|
||||||
{
|
|
||||||
definition->transparency = 0.5;
|
|
||||||
definition->reflection = 0.4;
|
|
||||||
definition->transparency_depth = 4.0;
|
|
||||||
definition->material->base = colorToHSL(colorFromValues(0.08, 0.15, 0.2, 1.0));
|
|
||||||
definition->depth_color->r = 0.0;
|
|
||||||
definition->depth_color->g = 0.1;
|
|
||||||
definition->depth_color->b = 0.1;
|
|
||||||
definition->lighting_depth = 6.0;
|
|
||||||
definition->scaling = 1.0;
|
|
||||||
definition->waves_height = 0.8;
|
|
||||||
definition->detail_height = 0.05;
|
|
||||||
definition->turbulence = 0.1;
|
|
||||||
definition->foam_coverage = 0.15;
|
|
||||||
}
|
|
||||||
else if (preset == WATER_PRESET_SEA)
|
|
||||||
{
|
|
||||||
definition->transparency = 0.4;
|
|
||||||
definition->reflection = 0.35;
|
|
||||||
definition->transparency_depth = 3.0;
|
|
||||||
definition->material->base = colorToHSL(colorFromValues(0.05, 0.18, 0.2, 1.0));
|
|
||||||
definition->depth_color->r = 0.0;
|
|
||||||
definition->depth_color->g = 0.18;
|
|
||||||
definition->depth_color->b = 0.15;
|
|
||||||
definition->lighting_depth = 4.0;
|
|
||||||
definition->scaling = 1.5;
|
|
||||||
definition->waves_height = 1.0;
|
|
||||||
definition->detail_height = 0.06;
|
|
||||||
definition->turbulence = 0.3;
|
|
||||||
definition->foam_coverage = 0.4;
|
|
||||||
}
|
|
||||||
|
|
||||||
definition->depth_color->a = 1.0;
|
|
||||||
definition->material->base.a = 1.0;
|
|
||||||
definition->material->reflection = 1.0;
|
|
||||||
definition->material->shininess = 16.0;
|
|
||||||
definition->foam_material->base = colorToHSL(colorFromValues(0.8, 0.8, 0.8, 1.0));
|
|
||||||
definition->foam_material->reflection = 0.1;
|
|
||||||
definition->foam_material->shininess = 1.5;
|
|
||||||
|
|
||||||
definition->validate();
|
|
||||||
}
|
|
|
@ -19,7 +19,7 @@ public:
|
||||||
|
|
||||||
// Transitional C-API
|
// Transitional C-API
|
||||||
|
|
||||||
// Les pixels doivent être fournis en RGBA
|
// Les pixels doivent être fournis en BGRA
|
||||||
typedef unsigned int (*PictureCallbackSavePixel)(void* data, int x, int y);
|
typedef unsigned int (*PictureCallbackSavePixel)(void* data, int x, int y);
|
||||||
SYSTEMSHARED_EXPORT int systemSavePictureFile(const char* filepath, PictureCallbackSavePixel callback_pixel, void* data, int width, int height);
|
SYSTEMSHARED_EXPORT int systemSavePictureFile(const char* filepath, PictureCallbackSavePixel callback_pixel, void* data, int width, int height);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "tools/color.h"
|
#include "tools/color.h"
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
#include "renderer.h"
|
#include "SoftwareRenderer.h"
|
||||||
#include "atmosphere/public.h"
|
#include "atmosphere/public.h"
|
||||||
#include "Scenery.h"
|
#include "Scenery.h"
|
||||||
#include "System.h"
|
#include "System.h"
|
||||||
|
@ -17,63 +17,57 @@ static Color _postProcessFragment(Renderer* renderer, Vector3 location, void*)
|
||||||
|
|
||||||
TEST(Bruneton, AerialPerspective1)
|
TEST(Bruneton, AerialPerspective1)
|
||||||
{
|
{
|
||||||
Renderer* renderer = sceneryCreateStandardRenderer();
|
SoftwareRenderer renderer;
|
||||||
renderer->render_width = 800;
|
renderer.render_width = 800;
|
||||||
renderer->render_height = 600;
|
renderer.render_height = 600;
|
||||||
renderer->render_quality = 1;
|
renderer.render_quality = 1;
|
||||||
|
|
||||||
cameraSetLocation(renderer->render_camera, VECTOR_ZERO);
|
cameraSetLocation(renderer.render_camera, VECTOR_ZERO);
|
||||||
cameraSetTarget(renderer->render_camera, VECTOR_EAST);
|
cameraSetTarget(renderer.render_camera, VECTOR_EAST);
|
||||||
cameraSetRenderSize(renderer->render_camera, renderer->render_width, renderer->render_height);
|
cameraSetRenderSize(renderer.render_camera, renderer.render_width, renderer.render_height);
|
||||||
|
|
||||||
RenderParams params = {renderer->render_width, renderer->render_height, 1, 1};
|
RenderParams params = {renderer.render_width, renderer.render_height, 1, 1};
|
||||||
renderSetParams(renderer->render_area, params);
|
renderSetParams(renderer.render_area, params);
|
||||||
renderSetBackgroundColor(renderer->render_area, COLOR_BLACK);
|
renderSetBackgroundColor(renderer.render_area, COLOR_BLACK);
|
||||||
renderClear(renderer->render_area);
|
renderClear(renderer.render_area);
|
||||||
|
|
||||||
renderer->pushQuad(renderer, v3(50.0, -10.0, -50.0), v3(1.0, -10.0, -50.0), v3(1.0, -10.0, 50.0), v3(50.0, -10.0, 50.0), _postProcessFragment, NULL);
|
renderer.pushQuad(&renderer, v3(50.0, -10.0, -50.0), v3(1.0, -10.0, -50.0), v3(1.0, -10.0, 50.0), v3(50.0, -10.0, 50.0), _postProcessFragment, NULL);
|
||||||
renderer->pushQuad(renderer, v3(10.0, -10.0, -10.0), v3(10.0, -10.0, -5.0), v3(10.0, 50.0, -5.0), v3(10.0, 50.0, -10.0), _postProcessFragment, NULL);
|
renderer.pushQuad(&renderer, v3(10.0, -10.0, -10.0), v3(10.0, -10.0, -5.0), v3(10.0, 50.0, -5.0), v3(10.0, 50.0, -10.0), _postProcessFragment, NULL);
|
||||||
renderer->pushQuad(renderer, v3(15.0, -10.0, -5.0), v3(15.0, -10.0, 0.0), v3(15.0, 50.0, 0.0), v3(15.0, 50.0, -5.0), _postProcessFragment, NULL);
|
renderer.pushQuad(&renderer, v3(15.0, -10.0, -5.0), v3(15.0, -10.0, 0.0), v3(15.0, 50.0, 0.0), v3(15.0, 50.0, -5.0), _postProcessFragment, NULL);
|
||||||
renderer->pushQuad(renderer, v3(20.0, -10.0, 5.0), v3(20.0, -10.0, 10.0), v3(20.0, 50.0, 10.0), v3(20.0, 50.0, 5.0), _postProcessFragment, NULL);
|
renderer.pushQuad(&renderer, v3(20.0, -10.0, 5.0), v3(20.0, -10.0, 10.0), v3(20.0, 50.0, 10.0), v3(20.0, 50.0, 5.0), _postProcessFragment, NULL);
|
||||||
renderer->pushQuad(renderer, v3(30.0, -10.0, 25.0), v3(30.0, -10.0, 30.0), v3(30.0, 50.0, 30.0), v3(30.0, 50.0, 25.0), _postProcessFragment, NULL);
|
renderer.pushQuad(&renderer, v3(30.0, -10.0, 25.0), v3(30.0, -10.0, 30.0), v3(30.0, 50.0, 30.0), v3(30.0, 50.0, 25.0), _postProcessFragment, NULL);
|
||||||
renderPostProcess(renderer->render_area, System::getCoreCount());
|
renderPostProcess(renderer.render_area, System::getCoreCount());
|
||||||
|
|
||||||
renderSaveToFile(renderer->render_area, "./output/test_bruneton_perspective.png");
|
renderSaveToFile(renderer.render_area, "./output/test_bruneton_perspective.png");
|
||||||
|
|
||||||
rendererDelete(renderer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Bruneton, AerialPerspective2)
|
TEST(Bruneton, AerialPerspective2)
|
||||||
{
|
{
|
||||||
AtmosphereDefinition* atmo = (AtmosphereDefinition*)AtmosphereDefinitionClass.create();
|
AtmosphereDefinition* atmo = Scenery::getCurrent()->getAtmosphere();
|
||||||
sceneryGetAtmosphere(atmo);
|
|
||||||
atmo->hour = 6;
|
atmo->hour = 6;
|
||||||
atmo->minute = 30;
|
atmo->minute = 30;
|
||||||
scenerySetAtmosphere(atmo);
|
AtmosphereDefinitionClass.validate(atmo);
|
||||||
AtmosphereDefinitionClass.destroy(atmo);
|
|
||||||
|
|
||||||
Renderer* renderer = sceneryCreateStandardRenderer();
|
Renderer renderer;
|
||||||
renderer->render_width = 800;
|
renderer.render_width = 800;
|
||||||
renderer->render_height = 600;
|
renderer.render_height = 600;
|
||||||
renderer->render_quality = 1;
|
renderer.render_quality = 1;
|
||||||
|
|
||||||
cameraSetLocation(renderer->render_camera, VECTOR_ZERO);
|
cameraSetLocation(renderer.render_camera, VECTOR_ZERO);
|
||||||
cameraSetTarget(renderer->render_camera, VECTOR_EAST);
|
cameraSetTarget(renderer.render_camera, VECTOR_EAST);
|
||||||
cameraSetRenderSize(renderer->render_camera, renderer->render_width, renderer->render_height);
|
cameraSetRenderSize(renderer.render_camera, renderer.render_width, renderer.render_height);
|
||||||
|
|
||||||
RenderParams params = {renderer->render_width, renderer->render_height, 1, 1};
|
RenderParams params = {renderer.render_width, renderer.render_height, 1, 1};
|
||||||
renderSetParams(renderer->render_area, params);
|
renderSetParams(renderer.render_area, params);
|
||||||
renderSetBackgroundColor(renderer->render_area, COLOR_BLACK);
|
renderSetBackgroundColor(renderer.render_area, COLOR_BLACK);
|
||||||
renderClear(renderer->render_area);
|
renderClear(renderer.render_area);
|
||||||
|
|
||||||
renderer->pushQuad(renderer, v3(50.0, -10.0, -50.0), v3(1.0, -10.0, -50.0), v3(1.0, -10.0, 50.0), v3(50.0, -10.0, 50.0), _postProcessFragment, NULL);
|
renderer.pushQuad(&renderer, v3(50.0, -10.0, -50.0), v3(1.0, -10.0, -50.0), v3(1.0, -10.0, 50.0), v3(50.0, -10.0, 50.0), _postProcessFragment, NULL);
|
||||||
renderer->pushQuad(renderer, v3(10.0, -10.0, -10.0), v3(10.0, -10.0, -5.0), v3(10.0, 50.0, -5.0), v3(10.0, 50.0, -10.0), _postProcessFragment, NULL);
|
renderer.pushQuad(&renderer, v3(10.0, -10.0, -10.0), v3(10.0, -10.0, -5.0), v3(10.0, 50.0, -5.0), v3(10.0, 50.0, -10.0), _postProcessFragment, NULL);
|
||||||
renderer->pushQuad(renderer, v3(15.0, -10.0, -5.0), v3(15.0, -10.0, 0.0), v3(15.0, 50.0, 0.0), v3(15.0, 50.0, -5.0), _postProcessFragment, NULL);
|
renderer.pushQuad(&renderer, v3(15.0, -10.0, -5.0), v3(15.0, -10.0, 0.0), v3(15.0, 50.0, 0.0), v3(15.0, 50.0, -5.0), _postProcessFragment, NULL);
|
||||||
renderer->pushQuad(renderer, v3(20.0, -10.0, 5.0), v3(20.0, -10.0, 10.0), v3(20.0, 50.0, 10.0), v3(20.0, 50.0, 5.0), _postProcessFragment, NULL);
|
renderer.pushQuad(&renderer, v3(20.0, -10.0, 5.0), v3(20.0, -10.0, 10.0), v3(20.0, 50.0, 10.0), v3(20.0, 50.0, 5.0), _postProcessFragment, NULL);
|
||||||
renderer->pushQuad(renderer, v3(30.0, -10.0, 25.0), v3(30.0, -10.0, 30.0), v3(30.0, 50.0, 30.0), v3(30.0, 50.0, 25.0), _postProcessFragment, NULL);
|
renderer.pushQuad(&renderer, v3(30.0, -10.0, 25.0), v3(30.0, -10.0, 30.0), v3(30.0, 50.0, 30.0), v3(30.0, 50.0, 25.0), _postProcessFragment, NULL);
|
||||||
renderPostProcess(renderer->render_area, System::getCoreCount());
|
renderPostProcess(renderer.render_area, System::getCoreCount());
|
||||||
|
|
||||||
renderSaveToFile(renderer->render_area, "./output/test_bruneton_perspective1.png");
|
renderSaveToFile(renderer.render_area, "./output/test_bruneton_perspective1.png");
|
||||||
|
|
||||||
rendererDelete(renderer);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue