paysages : Clouds are now on the new layers system.
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@420 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
a98185c5e1
commit
8101669544
10 changed files with 219 additions and 385 deletions
|
@ -7,23 +7,25 @@
|
||||||
|
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
static CloudsDefinition _definition;
|
|
||||||
static CloudsLayerDefinition _layer;
|
|
||||||
|
|
||||||
/**************** Previews ****************/
|
/**************** Previews ****************/
|
||||||
class PreviewCloudsCoverage:public BasePreview
|
class PreviewCloudsCoverage:public BasePreview
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PreviewCloudsCoverage(QWidget* parent):BasePreview(parent)
|
PreviewCloudsCoverage(QWidget* parent, CloudsLayerDefinition* layer):BasePreview(parent)
|
||||||
{
|
{
|
||||||
_renderer = rendererCreate();
|
_renderer = rendererCreate();
|
||||||
_renderer.render_quality = 3;
|
_renderer.render_quality = 3;
|
||||||
_renderer.applyLightStatus = _applyLightStatus;
|
_renderer.applyLightStatus = _applyLightStatus;
|
||||||
|
|
||||||
|
_original_layer = layer;
|
||||||
_preview_layer = cloudsLayerCreateDefinition();
|
_preview_layer = cloudsLayerCreateDefinition();
|
||||||
|
|
||||||
configScaling(100.0, 1000.0, 20.0, 200.0);
|
configScaling(100.0, 1000.0, 20.0, 200.0);
|
||||||
}
|
}
|
||||||
|
~PreviewCloudsCoverage()
|
||||||
|
{
|
||||||
|
cloudsLayerDeleteDefinition(_preview_layer);
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
QColor getColor(double x, double y)
|
QColor getColor(double x, double y)
|
||||||
{
|
{
|
||||||
|
@ -38,12 +40,12 @@ protected:
|
||||||
look.z = 1.0;
|
look.z = 1.0;
|
||||||
look = v3Normalize(look);
|
look = v3Normalize(look);
|
||||||
|
|
||||||
color_layer = cloudsApplyLayer(&_preview_layer, COLOR_BLUE, &_renderer, eye, v3Add(eye, v3Scale(look, 1000.0)));
|
color_layer = cloudsApplyLayer(_preview_layer, COLOR_BLUE, &_renderer, eye, v3Add(eye, v3Scale(look, 1000.0)));
|
||||||
return colorToQColor(color_layer);
|
return colorToQColor(color_layer);
|
||||||
}
|
}
|
||||||
void updateData()
|
void updateData()
|
||||||
{
|
{
|
||||||
cloudsLayerCopyDefinition(&_layer, &_preview_layer);
|
cloudsLayerCopyDefinition(_original_layer, _preview_layer);
|
||||||
}
|
}
|
||||||
static Color _applyLightStatus(Renderer* renderer, LightStatus* status, Vector3 location, Vector3 normal, SurfaceMaterial material)
|
static Color _applyLightStatus(Renderer* renderer, LightStatus* status, Vector3 location, Vector3 normal, SurfaceMaterial material)
|
||||||
{
|
{
|
||||||
|
@ -52,16 +54,18 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Renderer _renderer;
|
Renderer _renderer;
|
||||||
CloudsLayerDefinition _preview_layer;
|
CloudsLayerDefinition* _original_layer;
|
||||||
|
CloudsLayerDefinition* _preview_layer;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PreviewCloudsColor:public BasePreview
|
class PreviewCloudsColor:public BasePreview
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PreviewCloudsColor(QWidget* parent):BasePreview(parent)
|
PreviewCloudsColor(QWidget* parent, CloudsLayerDefinition* layer):BasePreview(parent)
|
||||||
{
|
{
|
||||||
LightDefinition light;
|
LightDefinition light;
|
||||||
|
|
||||||
|
_original_layer = layer;
|
||||||
_preview_layer = cloudsLayerCreateDefinition();
|
_preview_layer = cloudsLayerCreateDefinition();
|
||||||
|
|
||||||
_lighting = lightingCreateDefinition();
|
_lighting = lightingCreateDefinition();
|
||||||
|
@ -80,7 +84,7 @@ public:
|
||||||
_renderer.render_quality = 3;
|
_renderer.render_quality = 3;
|
||||||
_renderer.alterLight = _alterLight;
|
_renderer.alterLight = _alterLight;
|
||||||
_renderer.getLightStatus = _getLightStatus;
|
_renderer.getLightStatus = _getLightStatus;
|
||||||
_renderer.customData[0] = &_preview_layer;
|
_renderer.customData[0] = _preview_layer;
|
||||||
_renderer.customData[1] = &_lighting;
|
_renderer.customData[1] = &_lighting;
|
||||||
|
|
||||||
configScaling(0.5, 2.0, 0.1, 2.0);
|
configScaling(0.5, 2.0, 0.1, 2.0);
|
||||||
|
@ -91,29 +95,30 @@ protected:
|
||||||
Vector3 start, end;
|
Vector3 start, end;
|
||||||
Color color_layer;
|
Color color_layer;
|
||||||
|
|
||||||
start.x = x * _preview_layer.thickness * 0.5;
|
start.x = x * _preview_layer->thickness * 0.5;
|
||||||
start.y = -y * _preview_layer.thickness * 0.5;
|
start.y = -y * _preview_layer->thickness * 0.5;
|
||||||
start.z = _preview_layer.thickness * 0.5;
|
start.z = _preview_layer->thickness * 0.5;
|
||||||
|
|
||||||
end.x = x * _preview_layer.thickness * 0.5;
|
end.x = x * _preview_layer->thickness * 0.5;
|
||||||
end.y = -y * _preview_layer.thickness * 0.5;
|
end.y = -y * _preview_layer->thickness * 0.5;
|
||||||
end.z = -_preview_layer.thickness * 0.5;
|
end.z = -_preview_layer->thickness * 0.5;
|
||||||
|
|
||||||
color_layer = cloudsApplyLayer(&_preview_layer, COLOR_BLUE, &_renderer, start, end);
|
color_layer = cloudsApplyLayer(_preview_layer, COLOR_BLUE, &_renderer, start, end);
|
||||||
return colorToQColor(color_layer);
|
return colorToQColor(color_layer);
|
||||||
}
|
}
|
||||||
void updateData()
|
void updateData()
|
||||||
{
|
{
|
||||||
cloudsLayerCopyDefinition(&_layer, &_preview_layer);
|
cloudsLayerCopyDefinition(_original_layer, _preview_layer);
|
||||||
//noiseForceValue(_preview_layer.shape_noise, 1.0);
|
//noiseForceValue(_preview_layer.shape_noise, 1.0);
|
||||||
_preview_layer.lower_altitude = -_preview_layer.thickness * 0.5;
|
_preview_layer->lower_altitude = -_preview_layer->thickness * 0.5;
|
||||||
//curveClear(_preview_layer.coverage_by_altitude);
|
//curveClear(_preview_layer.coverage_by_altitude);
|
||||||
_preview_layer.base_coverage = 1.0;
|
_preview_layer->base_coverage = 1.0;
|
||||||
_preview_layer._custom_coverage = _coverageFunc;
|
_preview_layer->_custom_coverage = _coverageFunc;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
Renderer _renderer;
|
Renderer _renderer;
|
||||||
CloudsLayerDefinition _preview_layer;
|
CloudsLayerDefinition* _original_layer;
|
||||||
|
CloudsLayerDefinition* _preview_layer;
|
||||||
LightingDefinition _lighting;
|
LightingDefinition _lighting;
|
||||||
|
|
||||||
static double _coverageFunc(CloudsLayerDefinition* layer, Vector3 position)
|
static double _coverageFunc(CloudsLayerDefinition* layer, Vector3 position)
|
||||||
|
@ -146,102 +151,52 @@ private:
|
||||||
|
|
||||||
/**************** Form ****************/
|
/**************** Form ****************/
|
||||||
FormClouds::FormClouds(QWidget *parent):
|
FormClouds::FormClouds(QWidget *parent):
|
||||||
BaseForm(parent, false, true)
|
BaseFormLayer(parent)
|
||||||
{
|
{
|
||||||
_definition = cloudsCreateDefinition();
|
_definition = cloudsCreateDefinition();
|
||||||
_layer = cloudsLayerCreateDefinition();
|
_layer = cloudsLayerCreateDefinition();
|
||||||
|
|
||||||
addPreview(new PreviewCloudsCoverage(parent), tr("Layer coverage (no lighting)"));
|
_previewCoverage = new PreviewCloudsCoverage(parent, _layer);
|
||||||
addPreview(new PreviewCloudsColor(parent), tr("Appearance"));
|
_previewColor = new PreviewCloudsColor(parent, _layer);
|
||||||
|
addPreview(_previewCoverage, tr("Layer coverage (no lighting)"));
|
||||||
|
addPreview(_previewColor, tr("Appearance"));
|
||||||
|
|
||||||
addInputDouble(tr("Lower altitude"), &_layer.lower_altitude, -10.0, 50.0, 0.5, 5.0);
|
addInputDouble(tr("Lower altitude"), &_layer->lower_altitude, -10.0, 50.0, 0.5, 5.0);
|
||||||
addInputDouble(tr("Layer thickness"), &_layer.thickness, 0.0, 20.0, 0.1, 1.0);
|
addInputDouble(tr("Layer thickness"), &_layer->thickness, 0.0, 20.0, 0.1, 1.0);
|
||||||
addInputDouble(tr("Max coverage"), &_layer.base_coverage, 0.0, 1.0, 0.01, 0.1);
|
addInputDouble(tr("Max coverage"), &_layer->base_coverage, 0.0, 1.0, 0.01, 0.1);
|
||||||
addInputCurve(tr("Coverage by altitude"), _layer.coverage_by_altitude, 0.0, 1.0, 0.0, 1.0, tr("Altitude in cloud layer"), tr("Coverage value"));
|
addInputCurve(tr("Coverage by altitude"), _layer->coverage_by_altitude, 0.0, 1.0, 0.0, 1.0, tr("Altitude in cloud layer"), tr("Coverage value"));
|
||||||
addInputNoise(tr("Shape noise"), _layer.shape_noise);
|
addInputNoise(tr("Shape noise"), _layer->shape_noise);
|
||||||
addInputDouble(tr("Shape scaling"), &_layer.shape_scaling, 1.0, 10.0, 0.1, 1.0);
|
addInputDouble(tr("Shape scaling"), &_layer->shape_scaling, 1.0, 10.0, 0.1, 1.0);
|
||||||
addInputNoise(tr("Edge noise"), _layer.edge_noise);
|
addInputNoise(tr("Edge noise"), _layer->edge_noise);
|
||||||
addInputDouble(tr("Edge scaling"), &_layer.edge_scaling, 0.02, 0.5, 0.01, 0.1);
|
addInputDouble(tr("Edge scaling"), &_layer->edge_scaling, 0.02, 0.5, 0.01, 0.1);
|
||||||
addInputDouble(tr("Edge length"), &_layer.edge_length, 0.0, 1.0, 0.01, 0.1);
|
addInputDouble(tr("Edge length"), &_layer->edge_length, 0.0, 1.0, 0.01, 0.1);
|
||||||
addInputMaterial(tr("Material"), &_layer.material);
|
addInputMaterial(tr("Material"), &_layer->material);
|
||||||
addInputDouble(tr("Hardness to light"), &_layer.hardness, 0.0, 1.0, 0.01, 0.1);
|
addInputDouble(tr("Hardness to light"), &_layer->hardness, 0.0, 1.0, 0.01, 0.1);
|
||||||
addInputDouble(tr("Transparency depth"), &_layer.transparencydepth, 0.0, 100.0, 0.5, 5.0);
|
addInputDouble(tr("Transparency depth"), &_layer->transparencydepth, 0.0, 100.0, 0.5, 5.0);
|
||||||
addInputDouble(tr("Light traversal depth"), &_layer.lighttraversal, 0.0, 100.0, 0.5, 5.0);
|
addInputDouble(tr("Light traversal depth"), &_layer->lighttraversal, 0.0, 100.0, 0.5, 5.0);
|
||||||
addInputDouble(tr("Minimum lighting"), &_layer.minimumlight, 0.0, 1.0, 0.01, 0.1);
|
addInputDouble(tr("Minimum lighting"), &_layer->minimumlight, 0.0, 1.0, 0.01, 0.1);
|
||||||
|
|
||||||
revertConfig();
|
setLayers(_definition.layers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormClouds::revertConfig()
|
void FormClouds::revertConfig()
|
||||||
{
|
{
|
||||||
sceneryGetClouds(&_definition);
|
sceneryGetClouds(&_definition);
|
||||||
BaseForm::revertConfig();
|
BaseFormLayer::revertConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormClouds::applyConfig()
|
void FormClouds::applyConfig()
|
||||||
{
|
{
|
||||||
|
BaseFormLayer::applyConfig();
|
||||||
scenerySetClouds(&_definition);
|
scenerySetClouds(&_definition);
|
||||||
BaseForm::applyConfig();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormClouds::configChangeEvent()
|
void FormClouds::layerGetCopy(void* layer_definition)
|
||||||
{
|
{
|
||||||
cloudsLayerCopyDefinition(&_layer, cloudsGetLayer(&_definition, currentLayer()));
|
cloudsLayerCopyDefinition((CloudsLayerDefinition*)layer_definition, _layer);
|
||||||
cloudsValidateDefinition(&_definition);
|
|
||||||
BaseForm::configChangeEvent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList FormClouds::getLayers()
|
void FormClouds::layerApply(void* layer_definition)
|
||||||
{
|
{
|
||||||
QStringList result;
|
cloudsLayerCopyDefinition(_layer, (CloudsLayerDefinition*)layer_definition);
|
||||||
CloudsLayerDefinition* layer;
|
|
||||||
int i, n;
|
|
||||||
|
|
||||||
n = cloudsGetLayerCount(&_definition);
|
|
||||||
for (i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
layer = cloudsGetLayer(&_definition, i);
|
|
||||||
result << QString::fromUtf8(layer->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FormClouds::layerAddedEvent()
|
|
||||||
{
|
|
||||||
if (cloudsAddLayer(&_definition) >= 0)
|
|
||||||
{
|
|
||||||
BaseForm::layerAddedEvent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FormClouds::layerMovedEvent(int layer, int new_position)
|
|
||||||
{
|
|
||||||
cloudsMoveLayer(&_definition, layer, new_position);
|
|
||||||
|
|
||||||
BaseForm::layerMovedEvent(layer, new_position);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FormClouds::layerDeletedEvent(int layer)
|
|
||||||
{
|
|
||||||
cloudsDeleteLayer(&_definition, layer);
|
|
||||||
|
|
||||||
BaseForm::layerDeletedEvent(layer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FormClouds::layerRenamedEvent(int layer, QString new_name)
|
|
||||||
{
|
|
||||||
CloudsLayerDefinition* layer_def;
|
|
||||||
|
|
||||||
layer_def = cloudsGetLayer(&_definition, layer);
|
|
||||||
cloudsLayerSetName(layer_def, new_name.toUtf8().data());
|
|
||||||
|
|
||||||
BaseForm::layerRenamedEvent(layer, new_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FormClouds::layerSelectedEvent(int layer)
|
|
||||||
{
|
|
||||||
cloudsLayerCopyDefinition(cloudsGetLayer(&_definition, layer), &_layer);
|
|
||||||
|
|
||||||
BaseForm::layerSelectedEvent(layer);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,10 @@
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include "basepreview.h"
|
#include "basepreview.h"
|
||||||
#include "baseform.h"
|
#include "baseformlayer.h"
|
||||||
|
#include "../lib_paysages/clouds.h"
|
||||||
|
|
||||||
class FormClouds : public BaseForm
|
class FormClouds : public BaseFormLayer
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -16,20 +17,15 @@ public slots:
|
||||||
virtual void revertConfig();
|
virtual void revertConfig();
|
||||||
virtual void applyConfig();
|
virtual void applyConfig();
|
||||||
|
|
||||||
protected slots:
|
|
||||||
virtual void configChangeEvent();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual QStringList getLayers();
|
virtual void layerGetCopy(void* layer_definition);
|
||||||
virtual void layerAddedEvent();
|
virtual void layerApply(void* layer_definition);
|
||||||
virtual void layerDeletedEvent(int layer);
|
|
||||||
virtual void layerMovedEvent(int layer, int new_position);
|
|
||||||
virtual void layerRenamedEvent(int layer, QString new_name);
|
|
||||||
virtual void layerSelectedEvent(int layer);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BasePreview* previewCoverage;
|
CloudsDefinition _definition;
|
||||||
BasePreview* previewColor;
|
CloudsLayerDefinition* _layer;
|
||||||
|
BasePreview* _previewCoverage;
|
||||||
|
BasePreview* _previewColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -139,10 +139,10 @@ FormTextures::FormTextures(QWidget *parent):
|
||||||
_supp.height_curve = curveCreate();
|
_supp.height_curve = curveCreate();
|
||||||
_supp.slope_curve = curveCreate();
|
_supp.slope_curve = curveCreate();
|
||||||
|
|
||||||
previewCoverage = new PreviewTexturesCoverage(this, _layer);
|
_previewCoverage = new PreviewTexturesCoverage(this, _layer);
|
||||||
previewColor = new PreviewTexturesColor(this, _layer);
|
_previewColor = new PreviewTexturesColor(this, _layer);
|
||||||
addPreview(previewCoverage, tr("Coverage preview"));
|
addPreview(_previewCoverage, tr("Coverage preview"));
|
||||||
addPreview(previewColor, tr("Lighted sample"));
|
addPreview(_previewColor, tr("Lighted sample"));
|
||||||
|
|
||||||
addInputNoise(tr("Surface noise"), _layer->bump_noise);
|
addInputNoise(tr("Surface noise"), _layer->bump_noise);
|
||||||
addInputDouble(tr("Surface noise height"), &_layer->bump_height, 0.0, 0.1, 0.001, 0.01);
|
addInputDouble(tr("Surface noise height"), &_layer->bump_height, 0.0, 0.1, 0.001, 0.01);
|
||||||
|
|
|
@ -25,8 +25,8 @@ protected:
|
||||||
private:
|
private:
|
||||||
TexturesDefinition _definition;
|
TexturesDefinition _definition;
|
||||||
TextureLayerDefinition* _layer;
|
TextureLayerDefinition* _layer;
|
||||||
BasePreview* previewCoverage;
|
BasePreview* _previewCoverage;
|
||||||
BasePreview* previewColor;
|
BasePreview* _previewColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -74,7 +74,7 @@ void autoGenRealisticLandscape(int seed)
|
||||||
|
|
||||||
/* Cloud layer */
|
/* Cloud layer */
|
||||||
clouds = cloudsCreateDefinition();
|
clouds = cloudsCreateDefinition();
|
||||||
cloudsAddLayer(&clouds);
|
layersAddLayer(clouds.layers, NULL);
|
||||||
scenerySetClouds(&clouds);
|
scenerySetClouds(&clouds);
|
||||||
cloudsDeleteDefinition(&clouds);
|
cloudsDeleteDefinition(&clouds);
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "shared/types.h"
|
#include "shared/types.h"
|
||||||
|
|
||||||
|
#define CLOUDS_MAX_LAYERS 6
|
||||||
#define MAX_SEGMENT_COUNT 30
|
#define MAX_SEGMENT_COUNT 30
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -18,120 +19,38 @@ typedef struct
|
||||||
double length;
|
double length;
|
||||||
} CloudSegment;
|
} CloudSegment;
|
||||||
|
|
||||||
static CloudsLayerDefinition NULL_LAYER;
|
|
||||||
|
|
||||||
void cloudsInit()
|
|
||||||
{
|
|
||||||
NULL_LAYER = cloudsLayerCreateDefinition();;
|
|
||||||
cloudsLayerValidateDefinition(&NULL_LAYER);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cloudsQuit()
|
|
||||||
{
|
|
||||||
cloudsLayerDeleteDefinition(&NULL_LAYER);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cloudsSave(PackStream* stream, CloudsDefinition* definition)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
CloudsLayerDefinition* layer;
|
|
||||||
|
|
||||||
packWriteInt(stream, &definition->nblayers);
|
|
||||||
for (i = 0; i < definition->nblayers; i++)
|
|
||||||
{
|
|
||||||
layer = definition->layers + i;
|
|
||||||
|
|
||||||
packWriteString(stream, layer->name, CLOUDS_MAX_NAME_LENGTH);
|
|
||||||
packWriteDouble(stream, &layer->lower_altitude);
|
|
||||||
packWriteDouble(stream, &layer->thickness);
|
|
||||||
curveSave(stream, layer->coverage_by_altitude);
|
|
||||||
noiseSaveGenerator(stream, layer->shape_noise);
|
|
||||||
noiseSaveGenerator(stream, layer->edge_noise);
|
|
||||||
materialSave(stream, &layer->material);
|
|
||||||
packWriteDouble(stream, &layer->hardness);
|
|
||||||
packWriteDouble(stream, &layer->transparencydepth);
|
|
||||||
packWriteDouble(stream, &layer->lighttraversal);
|
|
||||||
packWriteDouble(stream, &layer->minimumlight);
|
|
||||||
packWriteDouble(stream, &layer->shape_scaling);
|
|
||||||
packWriteDouble(stream, &layer->edge_scaling);
|
|
||||||
packWriteDouble(stream, &layer->edge_length);
|
|
||||||
packWriteDouble(stream, &layer->base_coverage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cloudsLoad(PackStream* stream, CloudsDefinition* definition)
|
|
||||||
{
|
|
||||||
int i, n;
|
|
||||||
CloudsLayerDefinition* layer;
|
|
||||||
|
|
||||||
while (definition->nblayers > 0)
|
|
||||||
{
|
|
||||||
cloudsDeleteLayer(definition, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
packReadInt(stream, &n);
|
|
||||||
for (i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
layer = definition->layers + cloudsAddLayer(definition);
|
|
||||||
|
|
||||||
packReadString(stream, layer->name, CLOUDS_MAX_NAME_LENGTH);
|
|
||||||
packReadDouble(stream, &layer->lower_altitude);
|
|
||||||
packReadDouble(stream, &layer->thickness);
|
|
||||||
curveLoad(stream, layer->coverage_by_altitude);
|
|
||||||
noiseLoadGenerator(stream, layer->shape_noise);
|
|
||||||
noiseLoadGenerator(stream, layer->edge_noise);
|
|
||||||
materialLoad(stream, &layer->material);
|
|
||||||
packReadDouble(stream, &layer->hardness);
|
|
||||||
packReadDouble(stream, &layer->transparencydepth);
|
|
||||||
packReadDouble(stream, &layer->lighttraversal);
|
|
||||||
packReadDouble(stream, &layer->minimumlight);
|
|
||||||
packReadDouble(stream, &layer->shape_scaling);
|
|
||||||
packReadDouble(stream, &layer->edge_scaling);
|
|
||||||
packReadDouble(stream, &layer->edge_length);
|
|
||||||
packReadDouble(stream, &layer->base_coverage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CloudsDefinition cloudsCreateDefinition()
|
CloudsDefinition cloudsCreateDefinition()
|
||||||
{
|
{
|
||||||
CloudsDefinition result;
|
CloudsDefinition result;
|
||||||
|
|
||||||
result.nblayers = 0;
|
result.layers = layersCreate(cloudsGetLayerType(), CLOUDS_MAX_LAYERS);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cloudsDeleteDefinition(CloudsDefinition* definition)
|
void cloudsDeleteDefinition(CloudsDefinition* definition)
|
||||||
{
|
{
|
||||||
while (definition->nblayers > 0)
|
layersDelete(definition->layers);
|
||||||
{
|
|
||||||
cloudsDeleteLayer(definition, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cloudsCopyDefinition(CloudsDefinition* source, CloudsDefinition* destination)
|
void cloudsCopyDefinition(CloudsDefinition* source, CloudsDefinition* destination)
|
||||||
{
|
{
|
||||||
CloudsLayerDefinition* layer;
|
layersCopy(source->layers, destination->layers);
|
||||||
int i;
|
|
||||||
|
|
||||||
while (destination->nblayers > 0)
|
|
||||||
{
|
|
||||||
cloudsDeleteLayer(destination, 0);
|
|
||||||
}
|
|
||||||
for (i = 0; i < source->nblayers; i++)
|
|
||||||
{
|
|
||||||
layer = cloudsGetLayer(destination, cloudsAddLayer(destination));
|
|
||||||
cloudsLayerCopyDefinition(source->layers + i, layer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cloudsValidateDefinition(CloudsDefinition* definition)
|
void cloudsValidateDefinition(CloudsDefinition* definition)
|
||||||
{
|
{
|
||||||
int i;
|
layersValidate(definition->layers);
|
||||||
for (i = 0; i < definition->nblayers; i++)
|
}
|
||||||
{
|
|
||||||
cloudsLayerValidateDefinition(&definition->layers[i]);
|
void cloudsSave(PackStream* stream, CloudsDefinition* definition)
|
||||||
}
|
{
|
||||||
|
layersSave(stream, definition->layers);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cloudsLoad(PackStream* stream, CloudsDefinition* definition)
|
||||||
|
{
|
||||||
|
layersLoad(stream, definition->layers);
|
||||||
}
|
}
|
||||||
|
|
||||||
static double _standardCoverageFunc(CloudsLayerDefinition* layer, Vector3 position)
|
static double _standardCoverageFunc(CloudsLayerDefinition* layer, Vector3 position)
|
||||||
|
@ -146,58 +65,57 @@ static double _standardCoverageFunc(CloudsLayerDefinition* layer, Vector3 positi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CloudsLayerDefinition cloudsLayerCreateDefinition()
|
CloudsLayerDefinition* cloudsLayerCreateDefinition()
|
||||||
{
|
{
|
||||||
CloudsLayerDefinition result;
|
CloudsLayerDefinition* result;
|
||||||
|
|
||||||
cloudsLayerSetName(&result, "Unnamed");
|
result = malloc(sizeof(CloudsLayerDefinition));
|
||||||
result.lower_altitude = 4.0;
|
|
||||||
result.thickness = 6.0;
|
|
||||||
result.coverage_by_altitude = curveCreate();
|
|
||||||
curveQuickAddPoint(result.coverage_by_altitude, 0.0, 0.0);
|
|
||||||
curveQuickAddPoint(result.coverage_by_altitude, 0.3, 1.0);
|
|
||||||
curveQuickAddPoint(result.coverage_by_altitude, 0.5, 1.0);
|
|
||||||
curveQuickAddPoint(result.coverage_by_altitude, 1.0, 0.0);
|
|
||||||
result.material.base.r = 0.7;
|
|
||||||
result.material.base.g = 0.7;
|
|
||||||
result.material.base.b = 0.7;
|
|
||||||
result.material.base.a = 1.0;
|
|
||||||
result.material.reflection = 0.3;
|
|
||||||
result.material.shininess = 0.8;
|
|
||||||
result.hardness = 0.25;
|
|
||||||
result.transparencydepth = 1.5;
|
|
||||||
result.lighttraversal = 7.0;
|
|
||||||
result.minimumlight = 0.4;
|
|
||||||
result.shape_scaling = 3.5;
|
|
||||||
result.edge_scaling = 0.07;
|
|
||||||
result.edge_length = 0.2;
|
|
||||||
result.base_coverage = 0.35;
|
|
||||||
result.shape_noise = noiseCreateGenerator();
|
|
||||||
noiseGenerateBaseNoise(result.shape_noise, 200000);
|
|
||||||
noiseAddLevelsSimple(result.shape_noise, 5, 1.0, 1.0);
|
|
||||||
result.edge_noise = noiseCreateGenerator();
|
|
||||||
noiseGenerateBaseNoise(result.edge_noise, 800000);
|
|
||||||
noiseAddLevelsSimple(result.edge_noise, 8, 1.0, 1.0);
|
|
||||||
|
|
||||||
result._custom_coverage = _standardCoverageFunc;
|
result->lower_altitude = 4.0;
|
||||||
|
result->thickness = 6.0;
|
||||||
|
result->coverage_by_altitude = curveCreate();
|
||||||
|
curveQuickAddPoint(result->coverage_by_altitude, 0.0, 0.0);
|
||||||
|
curveQuickAddPoint(result->coverage_by_altitude, 0.3, 1.0);
|
||||||
|
curveQuickAddPoint(result->coverage_by_altitude, 0.5, 1.0);
|
||||||
|
curveQuickAddPoint(result->coverage_by_altitude, 1.0, 0.0);
|
||||||
|
result->material.base.r = 0.7;
|
||||||
|
result->material.base.g = 0.7;
|
||||||
|
result->material.base.b = 0.7;
|
||||||
|
result->material.base.a = 1.0;
|
||||||
|
result->material.reflection = 0.3;
|
||||||
|
result->material.shininess = 0.8;
|
||||||
|
result->hardness = 0.25;
|
||||||
|
result->transparencydepth = 1.5;
|
||||||
|
result->lighttraversal = 7.0;
|
||||||
|
result->minimumlight = 0.4;
|
||||||
|
result->shape_scaling = 3.5;
|
||||||
|
result->edge_scaling = 0.07;
|
||||||
|
result->edge_length = 0.2;
|
||||||
|
result->base_coverage = 0.35;
|
||||||
|
result->shape_noise = noiseCreateGenerator();
|
||||||
|
noiseGenerateBaseNoise(result->shape_noise, 200000);
|
||||||
|
noiseAddLevelsSimple(result->shape_noise, 5, 1.0, 1.0);
|
||||||
|
result->edge_noise = noiseCreateGenerator();
|
||||||
|
noiseGenerateBaseNoise(result->edge_noise, 800000);
|
||||||
|
noiseAddLevelsSimple(result->edge_noise, 8, 1.0, 1.0);
|
||||||
|
|
||||||
|
result->_custom_coverage = _standardCoverageFunc;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cloudsLayerDeleteDefinition(CloudsLayerDefinition* definition)
|
void cloudsLayerDeleteDefinition(CloudsLayerDefinition* definition)
|
||||||
{
|
{
|
||||||
|
curveDelete(definition->coverage_by_altitude);
|
||||||
noiseDeleteGenerator(definition->shape_noise);
|
noiseDeleteGenerator(definition->shape_noise);
|
||||||
|
noiseDeleteGenerator(definition->edge_noise);
|
||||||
|
free(definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cloudsLayerCopyDefinition(CloudsLayerDefinition* source, CloudsLayerDefinition* destination)
|
void cloudsLayerCopyDefinition(CloudsLayerDefinition* source, CloudsLayerDefinition* destination)
|
||||||
{
|
{
|
||||||
CloudsLayerDefinition temp;
|
CloudsLayerDefinition temp;
|
||||||
|
|
||||||
if (destination == &NULL_LAYER)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
temp = *destination;
|
temp = *destination;
|
||||||
*destination = *source;
|
*destination = *source;
|
||||||
|
|
||||||
|
@ -213,7 +131,6 @@ void cloudsLayerCopyDefinition(CloudsLayerDefinition* source, CloudsLayerDefinit
|
||||||
|
|
||||||
void cloudsLayerValidateDefinition(CloudsLayerDefinition* definition)
|
void cloudsLayerValidateDefinition(CloudsLayerDefinition* definition)
|
||||||
{
|
{
|
||||||
definition->name[CLOUDS_MAX_NAME_LENGTH] = '\0';
|
|
||||||
if (definition->shape_scaling < 0.0001)
|
if (definition->shape_scaling < 0.0001)
|
||||||
{
|
{
|
||||||
definition->shape_scaling = 0.00001;
|
definition->shape_scaling = 0.00001;
|
||||||
|
@ -228,74 +145,54 @@ void cloudsLayerValidateDefinition(CloudsLayerDefinition* definition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cloudsLayerSetName(CloudsLayerDefinition* definition, const char* name)
|
void _cloudsLayerSave(PackStream* stream, CloudsLayerDefinition* layer)
|
||||||
{
|
{
|
||||||
strncpy(definition->name, name, CLOUDS_MAX_NAME_LENGTH);
|
packWriteDouble(stream, &layer->lower_altitude);
|
||||||
|
packWriteDouble(stream, &layer->thickness);
|
||||||
|
curveSave(stream, layer->coverage_by_altitude);
|
||||||
|
noiseSaveGenerator(stream, layer->shape_noise);
|
||||||
|
noiseSaveGenerator(stream, layer->edge_noise);
|
||||||
|
materialSave(stream, &layer->material);
|
||||||
|
packWriteDouble(stream, &layer->hardness);
|
||||||
|
packWriteDouble(stream, &layer->transparencydepth);
|
||||||
|
packWriteDouble(stream, &layer->lighttraversal);
|
||||||
|
packWriteDouble(stream, &layer->minimumlight);
|
||||||
|
packWriteDouble(stream, &layer->shape_scaling);
|
||||||
|
packWriteDouble(stream, &layer->edge_scaling);
|
||||||
|
packWriteDouble(stream, &layer->edge_length);
|
||||||
|
packWriteDouble(stream, &layer->base_coverage);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cloudsGetLayerCount(CloudsDefinition* definition)
|
void _cloudsLayerLoad(PackStream* stream, CloudsLayerDefinition* layer)
|
||||||
{
|
{
|
||||||
return definition->nblayers;
|
packReadDouble(stream, &layer->lower_altitude);
|
||||||
|
packReadDouble(stream, &layer->thickness);
|
||||||
|
curveLoad(stream, layer->coverage_by_altitude);
|
||||||
|
noiseLoadGenerator(stream, layer->shape_noise);
|
||||||
|
noiseLoadGenerator(stream, layer->edge_noise);
|
||||||
|
materialLoad(stream, &layer->material);
|
||||||
|
packReadDouble(stream, &layer->hardness);
|
||||||
|
packReadDouble(stream, &layer->transparencydepth);
|
||||||
|
packReadDouble(stream, &layer->lighttraversal);
|
||||||
|
packReadDouble(stream, &layer->minimumlight);
|
||||||
|
packReadDouble(stream, &layer->shape_scaling);
|
||||||
|
packReadDouble(stream, &layer->edge_scaling);
|
||||||
|
packReadDouble(stream, &layer->edge_length);
|
||||||
|
packReadDouble(stream, &layer->base_coverage);
|
||||||
}
|
}
|
||||||
|
|
||||||
CloudsLayerDefinition* cloudsGetLayer(CloudsDefinition* definition, int layer)
|
LayerType cloudsGetLayerType()
|
||||||
{
|
{
|
||||||
if (layer >= 0 && layer < definition->nblayers)
|
LayerType result;
|
||||||
{
|
|
||||||
return definition->layers + layer;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return &NULL_LAYER;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int cloudsAddLayer(CloudsDefinition* definition)
|
result.callback_create = (LayerCallbackCreate)cloudsLayerCreateDefinition;
|
||||||
{
|
result.callback_delete = (LayerCallbackDelete)cloudsLayerDeleteDefinition;
|
||||||
CloudsLayerDefinition* layer;
|
result.callback_copy = (LayerCallbackCopy)cloudsLayerCopyDefinition;
|
||||||
|
result.callback_validate = (LayerCallbackValidate)cloudsLayerValidateDefinition;
|
||||||
|
result.callback_save = (LayerCallbackSave)_cloudsLayerSave;
|
||||||
|
result.callback_load = (LayerCallbackLoad)_cloudsLayerLoad;
|
||||||
|
|
||||||
if (definition->nblayers < CLOUDS_MAX_LAYERS)
|
return result;
|
||||||
{
|
|
||||||
layer = definition->layers + definition->nblayers;
|
|
||||||
*layer = cloudsLayerCreateDefinition();
|
|
||||||
|
|
||||||
return definition->nblayers++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cloudsDeleteLayer(CloudsDefinition* definition, int layer)
|
|
||||||
{
|
|
||||||
if (layer >= 0 && layer < definition->nblayers)
|
|
||||||
{
|
|
||||||
cloudsLayerDeleteDefinition(definition->layers + layer);
|
|
||||||
if (definition->nblayers > 1 && layer < definition->nblayers - 1)
|
|
||||||
{
|
|
||||||
memmove(definition->layers + layer, definition->layers + layer + 1, sizeof(CloudsLayerDefinition) * (definition->nblayers - layer - 1));
|
|
||||||
}
|
|
||||||
definition->nblayers--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cloudsMoveLayer(CloudsDefinition* definition, int layer, int new_position)
|
|
||||||
{
|
|
||||||
if (layer >= 0 && layer < definition->nblayers && new_position != layer && new_position >= 0 && new_position < definition->nblayers)
|
|
||||||
{
|
|
||||||
CloudsLayerDefinition temp;
|
|
||||||
temp = definition->layers[layer];
|
|
||||||
if (new_position > layer)
|
|
||||||
{
|
|
||||||
memmove(definition->layers + layer, definition->layers + layer + 1, sizeof(CloudsLayerDefinition) * (new_position - layer));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
memmove(definition->layers + new_position + 1, definition->layers + new_position, sizeof(CloudsLayerDefinition) * (layer - new_position));
|
|
||||||
}
|
|
||||||
definition->layers[new_position] = temp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double _getDistanceToBorder(CloudsLayerDefinition* layer, Vector3 position)
|
static inline double _getDistanceToBorder(CloudsLayerDefinition* layer, Vector3 position)
|
||||||
|
@ -613,26 +510,25 @@ Color cloudsApplyLayer(CloudsLayerDefinition* definition, Color base, Renderer*
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _cmpLayer(const void* layer1, const void* layer2)
|
/*static int _cmpLayer(const void* layer1, const void* layer2)
|
||||||
{
|
{
|
||||||
return (((CloudsLayerDefinition*)layer1)->lower_altitude > ((CloudsLayerDefinition*)layer2)->lower_altitude) ? -1 : 1;
|
return (((CloudsLayerDefinition*)layer1)->lower_altitude > ((CloudsLayerDefinition*)layer2)->lower_altitude) ? -1 : 1;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
Color cloudsApply(CloudsDefinition* definition, Color base, Renderer* renderer, Vector3 start, Vector3 end)
|
Color cloudsApply(CloudsDefinition* definition, Color base, Renderer* renderer, Vector3 start, Vector3 end)
|
||||||
{
|
{
|
||||||
int i;
|
int i, n;
|
||||||
CloudsLayerDefinition layers[CLOUDS_MAX_LAYERS];
|
|
||||||
|
|
||||||
if (definition->nblayers < 1)
|
n = layersCount(definition->layers);
|
||||||
|
if (n < 1)
|
||||||
{
|
{
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(layers, definition->layers, sizeof(CloudsLayerDefinition) * definition->nblayers);
|
/* TODO Iter layers in sorted order */
|
||||||
qsort(layers, definition->nblayers, sizeof(CloudsLayerDefinition), _cmpLayer);
|
for (i = 0; i < n; i++)
|
||||||
for (i = 0; i < definition->nblayers; i++)
|
|
||||||
{
|
{
|
||||||
base = cloudsApplyLayer(layers + i, base, renderer, start, end);
|
base = cloudsApplyLayer(layersGetLayer(definition->layers, i), base, renderer, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
return base;
|
return base;
|
||||||
|
@ -671,11 +567,13 @@ Color cloudsLayerFilterLight(CloudsLayerDefinition* definition, Renderer* render
|
||||||
|
|
||||||
Color cloudsFilterLight(CloudsDefinition* definition, Renderer* renderer, Color light, Vector3 location, Vector3 light_location, Vector3 direction_to_light)
|
Color cloudsFilterLight(CloudsDefinition* definition, Renderer* renderer, Color light, Vector3 location, Vector3 light_location, Vector3 direction_to_light)
|
||||||
{
|
{
|
||||||
int i;
|
int i, n;
|
||||||
/* TODO Order layers ? */
|
|
||||||
for (i = 0; i < definition->nblayers; i++)
|
/* TODO Iter layers in sorted order */
|
||||||
|
n = layersCount(definition->layers);
|
||||||
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
light = cloudsLayerFilterLight(definition->layers + i, renderer, light, location, light_location, direction_to_light);
|
light = cloudsLayerFilterLight(layersGetLayer(definition->layers, i), renderer, light, location, light_location, direction_to_light);
|
||||||
}
|
}
|
||||||
return light;
|
return light;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,24 +2,20 @@
|
||||||
#define _PAYSAGES_CLOUDS_H_
|
#define _PAYSAGES_CLOUDS_H_
|
||||||
|
|
||||||
#include "shared/types.h"
|
#include "shared/types.h"
|
||||||
|
#include "layers.h"
|
||||||
#include "noise.h"
|
#include "noise.h"
|
||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CLOUDS_MAX_LAYERS 6
|
|
||||||
#define CLOUDS_MAX_NAME_LENGTH 50
|
|
||||||
|
|
||||||
typedef struct CloudsLayerDefinition CloudsLayerDefinition;
|
typedef struct CloudsLayerDefinition CloudsLayerDefinition;
|
||||||
|
|
||||||
typedef double (*CloudCoverageFunc)(CloudsLayerDefinition* definition, Vector3 position);
|
typedef double (*CloudCoverageFunc)(CloudsLayerDefinition* definition, Vector3 position);
|
||||||
|
|
||||||
struct CloudsLayerDefinition
|
struct CloudsLayerDefinition
|
||||||
{
|
{
|
||||||
char name[CLOUDS_MAX_NAME_LENGTH + 1];
|
|
||||||
double lower_altitude;
|
double lower_altitude;
|
||||||
double thickness;
|
double thickness;
|
||||||
double base_coverage;
|
double base_coverage;
|
||||||
|
@ -39,31 +35,22 @@ struct CloudsLayerDefinition
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int nblayers;
|
Layers* layers;
|
||||||
CloudsLayerDefinition layers[CLOUDS_MAX_LAYERS];
|
|
||||||
} CloudsDefinition;
|
} CloudsDefinition;
|
||||||
|
|
||||||
void cloudsInit();
|
|
||||||
void cloudsQuit();
|
|
||||||
void cloudsSave(PackStream* stream, CloudsDefinition* definition);
|
|
||||||
void cloudsLoad(PackStream* stream, CloudsDefinition* definition);
|
|
||||||
|
|
||||||
CloudsDefinition cloudsCreateDefinition();
|
CloudsDefinition cloudsCreateDefinition();
|
||||||
void cloudsDeleteDefinition(CloudsDefinition* definition);
|
void cloudsDeleteDefinition(CloudsDefinition* definition);
|
||||||
void cloudsCopyDefinition(CloudsDefinition* source, CloudsDefinition* destination);
|
void cloudsCopyDefinition(CloudsDefinition* source, CloudsDefinition* destination);
|
||||||
void cloudsValidateDefinition(CloudsDefinition* definition);
|
void cloudsValidateDefinition(CloudsDefinition* definition);
|
||||||
|
void cloudsSave(PackStream* stream, CloudsDefinition* definition);
|
||||||
|
void cloudsLoad(PackStream* stream, CloudsDefinition* definition);
|
||||||
|
|
||||||
CloudsLayerDefinition cloudsLayerCreateDefinition();
|
CloudsLayerDefinition* cloudsLayerCreateDefinition();
|
||||||
void cloudsLayerDeleteDefinition(CloudsLayerDefinition* definition);
|
void cloudsLayerDeleteDefinition(CloudsLayerDefinition* definition);
|
||||||
void cloudsLayerCopyDefinition(CloudsLayerDefinition* source, CloudsLayerDefinition* destination);
|
void cloudsLayerCopyDefinition(CloudsLayerDefinition* source, CloudsLayerDefinition* destination);
|
||||||
void cloudsLayerValidateDefinition(CloudsLayerDefinition* definition);
|
void cloudsLayerValidateDefinition(CloudsLayerDefinition* definition);
|
||||||
void cloudsLayerSetName(CloudsLayerDefinition* definition, const char* name);
|
void cloudsLayerSetName(CloudsLayerDefinition* definition, const char* name);
|
||||||
|
LayerType cloudsGetLayerType();
|
||||||
int cloudsGetLayerCount(CloudsDefinition* definition);
|
|
||||||
CloudsLayerDefinition* cloudsGetLayer(CloudsDefinition* definition, int layer);
|
|
||||||
int cloudsAddLayer(CloudsDefinition* definition);
|
|
||||||
void cloudsDeleteLayer(CloudsDefinition* definition, int layer);
|
|
||||||
void cloudsMoveLayer(CloudsDefinition* definition, int layer, int new_position);
|
|
||||||
|
|
||||||
Color cloudsApplyLayer(CloudsLayerDefinition* definition, Color base, Renderer* renderer, Vector3 start, Vector3 end);
|
Color cloudsApplyLayer(CloudsLayerDefinition* definition, Color base, Renderer* renderer, Vector3 start, Vector3 end);
|
||||||
Color cloudsApply(CloudsDefinition* definition, Color base, Renderer* renderer, Vector3 start, Vector3 end);
|
Color cloudsApply(CloudsDefinition* definition, Color base, Renderer* renderer, Vector3 start, Vector3 end);
|
||||||
|
|
|
@ -24,7 +24,6 @@ static void* _custom_data = NULL;
|
||||||
void sceneryInit()
|
void sceneryInit()
|
||||||
{
|
{
|
||||||
noiseInit();
|
noiseInit();
|
||||||
cloudsInit();
|
|
||||||
lightingInit();
|
lightingInit();
|
||||||
|
|
||||||
_atmosphere = atmosphereCreateDefinition();
|
_atmosphere = atmosphereCreateDefinition();
|
||||||
|
@ -53,7 +52,6 @@ void sceneryQuit()
|
||||||
vegetationDeleteDefinition(_vegetation);
|
vegetationDeleteDefinition(_vegetation);
|
||||||
waterDeleteDefinition(&_water);
|
waterDeleteDefinition(&_water);
|
||||||
|
|
||||||
cloudsQuit();
|
|
||||||
lightingQuit();
|
lightingQuit();
|
||||||
noiseQuit();
|
noiseQuit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,30 +22,6 @@ typedef struct
|
||||||
TextureLayerDefinition* definition;
|
TextureLayerDefinition* definition;
|
||||||
} TextureResult;
|
} TextureResult;
|
||||||
|
|
||||||
static void texturesLayerSave(PackStream* stream, TextureLayerDefinition* layer)
|
|
||||||
{
|
|
||||||
zoneSave(stream, layer->zone);
|
|
||||||
noiseSaveGenerator(stream, layer->bump_noise);
|
|
||||||
packWriteDouble(stream, &layer->bump_height);
|
|
||||||
packWriteDouble(stream, &layer->bump_scaling);
|
|
||||||
materialSave(stream, &layer->material);
|
|
||||||
packWriteDouble(stream, &layer->thickness);
|
|
||||||
packWriteDouble(stream, &layer->slope_range);
|
|
||||||
packWriteDouble(stream, &layer->thickness_transparency);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void texturesLayerLoad(PackStream* stream, TextureLayerDefinition* layer)
|
|
||||||
{
|
|
||||||
zoneLoad(stream, layer->zone);
|
|
||||||
noiseLoadGenerator(stream, layer->bump_noise);
|
|
||||||
packReadDouble(stream, &layer->bump_height);
|
|
||||||
packReadDouble(stream, &layer->bump_scaling);
|
|
||||||
materialLoad(stream, &layer->material);
|
|
||||||
packReadDouble(stream, &layer->thickness);
|
|
||||||
packReadDouble(stream, &layer->slope_range);
|
|
||||||
packReadDouble(stream, &layer->thickness_transparency);
|
|
||||||
}
|
|
||||||
|
|
||||||
TexturesDefinition texturesCreateDefinition()
|
TexturesDefinition texturesCreateDefinition()
|
||||||
{
|
{
|
||||||
TexturesDefinition result;
|
TexturesDefinition result;
|
||||||
|
@ -80,20 +56,6 @@ void texturesLoad(PackStream* stream, TexturesDefinition* definition)
|
||||||
layersLoad(stream, definition->layers);
|
layersLoad(stream, definition->layers);
|
||||||
}
|
}
|
||||||
|
|
||||||
LayerType texturesGetLayerType()
|
|
||||||
{
|
|
||||||
LayerType result;
|
|
||||||
|
|
||||||
result.callback_create = (LayerCallbackCreate)texturesLayerCreateDefinition;
|
|
||||||
result.callback_delete = (LayerCallbackDelete)texturesLayerDeleteDefinition;
|
|
||||||
result.callback_copy = (LayerCallbackCopy)texturesLayerCopyDefinition;
|
|
||||||
result.callback_validate = (LayerCallbackValidate)texturesLayerValidateDefinition;
|
|
||||||
result.callback_save = (LayerCallbackSave)texturesLayerSave;
|
|
||||||
result.callback_load = (LayerCallbackLoad)texturesLayerLoad;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
TextureLayerDefinition* texturesLayerCreateDefinition()
|
TextureLayerDefinition* texturesLayerCreateDefinition()
|
||||||
{
|
{
|
||||||
TextureLayerDefinition* result;
|
TextureLayerDefinition* result;
|
||||||
|
@ -147,6 +109,44 @@ void texturesLayerValidateDefinition(TextureLayerDefinition* definition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _texturesLayerSave(PackStream* stream, TextureLayerDefinition* layer)
|
||||||
|
{
|
||||||
|
zoneSave(stream, layer->zone);
|
||||||
|
noiseSaveGenerator(stream, layer->bump_noise);
|
||||||
|
packWriteDouble(stream, &layer->bump_height);
|
||||||
|
packWriteDouble(stream, &layer->bump_scaling);
|
||||||
|
materialSave(stream, &layer->material);
|
||||||
|
packWriteDouble(stream, &layer->thickness);
|
||||||
|
packWriteDouble(stream, &layer->slope_range);
|
||||||
|
packWriteDouble(stream, &layer->thickness_transparency);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _texturesLayerLoad(PackStream* stream, TextureLayerDefinition* layer)
|
||||||
|
{
|
||||||
|
zoneLoad(stream, layer->zone);
|
||||||
|
noiseLoadGenerator(stream, layer->bump_noise);
|
||||||
|
packReadDouble(stream, &layer->bump_height);
|
||||||
|
packReadDouble(stream, &layer->bump_scaling);
|
||||||
|
materialLoad(stream, &layer->material);
|
||||||
|
packReadDouble(stream, &layer->thickness);
|
||||||
|
packReadDouble(stream, &layer->slope_range);
|
||||||
|
packReadDouble(stream, &layer->thickness_transparency);
|
||||||
|
}
|
||||||
|
|
||||||
|
LayerType texturesGetLayerType()
|
||||||
|
{
|
||||||
|
LayerType result;
|
||||||
|
|
||||||
|
result.callback_create = (LayerCallbackCreate)texturesLayerCreateDefinition;
|
||||||
|
result.callback_delete = (LayerCallbackDelete)texturesLayerDeleteDefinition;
|
||||||
|
result.callback_copy = (LayerCallbackCopy)texturesLayerCopyDefinition;
|
||||||
|
result.callback_validate = (LayerCallbackValidate)texturesLayerValidateDefinition;
|
||||||
|
result.callback_save = (LayerCallbackSave)_texturesLayerSave;
|
||||||
|
result.callback_load = (LayerCallbackLoad)_texturesLayerLoad;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static inline Vector3 _getNormal4(Vector3 center, Vector3 north, Vector3 east, Vector3 south, Vector3 west)
|
static inline Vector3 _getNormal4(Vector3 center, Vector3 north, Vector3 east, Vector3 south, Vector3 west)
|
||||||
{
|
{
|
||||||
Vector3 dnorth, deast, dsouth, dwest, normal;
|
Vector3 dnorth, deast, dsouth, dwest, normal;
|
||||||
|
|
|
@ -37,11 +37,11 @@ void texturesValidateDefinition(TexturesDefinition* definition);
|
||||||
void texturesSave(PackStream* stream, TexturesDefinition* definition);
|
void texturesSave(PackStream* stream, TexturesDefinition* definition);
|
||||||
void texturesLoad(PackStream* stream, TexturesDefinition* definition);
|
void texturesLoad(PackStream* stream, TexturesDefinition* definition);
|
||||||
|
|
||||||
LayerType texturesGetLayerType();
|
|
||||||
TextureLayerDefinition* texturesLayerCreateDefinition();
|
TextureLayerDefinition* texturesLayerCreateDefinition();
|
||||||
void texturesLayerDeleteDefinition(TextureLayerDefinition* definition);
|
void texturesLayerDeleteDefinition(TextureLayerDefinition* definition);
|
||||||
void texturesLayerCopyDefinition(TextureLayerDefinition* source, TextureLayerDefinition* destination);
|
void texturesLayerCopyDefinition(TextureLayerDefinition* source, TextureLayerDefinition* destination);
|
||||||
void texturesLayerValidateDefinition(TextureLayerDefinition* definition);
|
void texturesLayerValidateDefinition(TextureLayerDefinition* definition);
|
||||||
|
LayerType texturesGetLayerType();
|
||||||
|
|
||||||
double texturesGetLayerCoverage(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, double detail);
|
double texturesGetLayerCoverage(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, double detail);
|
||||||
Color texturesGetLayerColor(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, double detail);
|
Color texturesGetLayerColor(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, double detail);
|
||||||
|
|
Loading…
Reference in a new issue