paysages: Save and load methods have been uniformized + end of the functions.h.
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@250 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
b46d25628a
commit
23586ee5f4
41 changed files with 543 additions and 479 deletions
1
TODO
1
TODO
|
@ -2,7 +2,6 @@
|
||||||
- Camera should respect ratio aspect of render area.
|
- Camera should respect ratio aspect of render area.
|
||||||
- All noises should use the same entropy pool (saved separately), and avoid reallocs.
|
- All noises should use the same entropy pool (saved separately), and avoid reallocs.
|
||||||
- Implement light multi-sampling (mainly for skydome).
|
- Implement light multi-sampling (mainly for skydome).
|
||||||
- All Save and Load methods should have same signature : void ...Save(FILE*, ...*).
|
|
||||||
- Remove all global variables (render_quality, render_width...), it should all be set in Renderer.
|
- Remove all global variables (render_quality, render_width...), it should all be set in Renderer.
|
||||||
- Implement scaling and scrolling on previews.
|
- Implement scaling and scrolling on previews.
|
||||||
- Water and terrain LOD moves with the camera, fix it like in the wanderer.
|
- Water and terrain LOD moves with the camera, fix it like in the wanderer.
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "../lib_paysages/shared/functions.h"
|
|
||||||
#include "../lib_paysages/auto.h"
|
#include "../lib_paysages/auto.h"
|
||||||
#include "../lib_paysages/render.h"
|
#include "../lib_paysages/render.h"
|
||||||
#include "../lib_paysages/scenery.h"
|
#include "../lib_paysages/scenery.h"
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include "../lib_paysages/render.h"
|
#include "../lib_paysages/render.h"
|
||||||
#include "../lib_paysages/scenery.h"
|
#include "../lib_paysages/scenery.h"
|
||||||
#include "../lib_paysages/auto.h"
|
#include "../lib_paysages/auto.h"
|
||||||
#include "../lib_paysages/shared/functions.h"
|
|
||||||
|
|
||||||
class RenderThread:public QThread
|
class RenderThread:public QThread
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#include "inputcamera.h"
|
#include "inputcamera.h"
|
||||||
#include "../lib_paysages/render.h"
|
#include "../lib_paysages/render.h"
|
||||||
#include "../lib_paysages/scenery.h"
|
#include "../lib_paysages/scenery.h"
|
||||||
#include "../lib_paysages/shared/functions.h"
|
|
||||||
|
|
||||||
/**************** Form ****************/
|
/**************** Form ****************/
|
||||||
FormRender::FormRender(QWidget *parent) :
|
FormRender::FormRender(QWidget *parent) :
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include "../lib_paysages/sky.h"
|
#include "../lib_paysages/sky.h"
|
||||||
#include "../lib_paysages/scenery.h"
|
#include "../lib_paysages/scenery.h"
|
||||||
#include "../lib_paysages/renderer.h"
|
#include "../lib_paysages/renderer.h"
|
||||||
#include "../lib_paysages/shared/functions.h"
|
|
||||||
#include "../lib_paysages/shared/constants.h"
|
#include "../lib_paysages/shared/constants.h"
|
||||||
|
|
||||||
static SkyDefinition _definition;
|
static SkyDefinition _definition;
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
#include "../lib_paysages/terrain.h"
|
#include "../lib_paysages/terrain.h"
|
||||||
#include "../lib_paysages/scenery.h"
|
#include "../lib_paysages/scenery.h"
|
||||||
#include "../lib_paysages/shared/functions.h"
|
|
||||||
#include "../lib_paysages/shared/constants.h"
|
#include "../lib_paysages/shared/constants.h"
|
||||||
|
|
||||||
static TerrainDefinition _definition;
|
static TerrainDefinition _definition;
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
#include "preview.h"
|
#include "preview.h"
|
||||||
#include "formwater.h"
|
#include "formwater.h"
|
||||||
#include "tools.h"
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "../lib_paysages/shared/constants.h"
|
||||||
|
#include "../lib_paysages/euclid.h"
|
||||||
|
#include "../lib_paysages/lighting.h"
|
||||||
|
#include "../lib_paysages/renderer.h"
|
||||||
|
#include "../lib_paysages/scenery.h"
|
||||||
#include "../lib_paysages/terrain.h"
|
#include "../lib_paysages/terrain.h"
|
||||||
#include "../lib_paysages/water.h"
|
#include "../lib_paysages/water.h"
|
||||||
#include "../lib_paysages/lighting.h"
|
#include "tools.h"
|
||||||
#include "../lib_paysages/scenery.h"
|
|
||||||
#include "../lib_paysages/renderer.h"
|
|
||||||
#include "../lib_paysages/shared/functions.h"
|
|
||||||
#include "../lib_paysages/shared/constants.h"
|
|
||||||
|
|
||||||
static WaterDefinition _definition;
|
static WaterDefinition _definition;
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
|
|
||||||
#include "dialogwanderer.h"
|
#include "dialogwanderer.h"
|
||||||
|
|
||||||
#include "../lib_paysages/shared/functions.h"
|
|
||||||
|
|
||||||
InputCamera::InputCamera(QWidget* form, QString label, CameraDefinition* value):BaseInput(form, label)
|
InputCamera::InputCamera(QWidget* form, QString label, CameraDefinition* value):BaseInput(form, label)
|
||||||
{
|
{
|
||||||
_value = value;
|
_value = value;
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
|
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
#include "../lib_paysages/shared/functions.h"
|
|
||||||
|
|
||||||
class ColorGradationPreview:public QWidget
|
class ColorGradationPreview:public QWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
|
|
||||||
#include "dialognoise.h"
|
#include "dialognoise.h"
|
||||||
|
|
||||||
#include "../lib_paysages/shared/functions.h"
|
|
||||||
|
|
||||||
class NoiseSmallPreview:public QWidget
|
class NoiseSmallPreview:public QWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
#include "dialogrender.h"
|
#include "dialogrender.h"
|
||||||
#include "dialogwanderer.h"
|
#include "dialogwanderer.h"
|
||||||
|
|
||||||
|
#include "../lib_paysages/main.h"
|
||||||
#include "../lib_paysages/auto.h"
|
#include "../lib_paysages/auto.h"
|
||||||
#include "../lib_paysages/scenery.h"
|
#include "../lib_paysages/scenery.h"
|
||||||
#include "../lib_paysages/shared/functions.h"
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
|
||||||
#include "../lib_paysages/shared/types.h"
|
#include "../lib_paysages/shared/types.h"
|
||||||
#include "../lib_paysages/shared/functions.h"
|
#include "../lib_paysages/color.h"
|
||||||
|
|
||||||
static inline QColor colorToQColor(Color color)
|
static inline QColor colorToQColor(Color color)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include "shared/types.h"
|
#include "array.h"
|
||||||
#include "shared/functions.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
22
lib_paysages/array.h
Normal file
22
lib_paysages/array.h
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#ifndef _PAYSAGES_ARRAY_H_
|
||||||
|
#define _PAYSAGES_ARRAY_H_
|
||||||
|
|
||||||
|
#include "shared/types.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void arrayCreate(Array* array, int item_size);
|
||||||
|
void arrayDelete(Array* array);
|
||||||
|
void* arrayAppend(Array* array, void* item);
|
||||||
|
void arrayInsert(Array* array, void* item, int position);
|
||||||
|
void arrayReplace(Array* array, void* item, int position);
|
||||||
|
void arrayLStrip(Array* array, int count);
|
||||||
|
void arrayClear(Array* array);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,7 +1,10 @@
|
||||||
#include "atmosphere.h"
|
#include "atmosphere.h"
|
||||||
#include "shared/functions.h"
|
|
||||||
#include "shared/constants.h"
|
#include "shared/constants.h"
|
||||||
#include "scenery.h"
|
#include "scenery.h"
|
||||||
|
#include "euclid.h"
|
||||||
|
#include "color.h"
|
||||||
|
#include "tools.h"
|
||||||
|
|
||||||
void atmosphereInit()
|
void atmosphereInit()
|
||||||
{
|
{
|
||||||
|
@ -9,20 +12,20 @@ void atmosphereInit()
|
||||||
|
|
||||||
void atmosphereSave(FILE* f, AtmosphereDefinition* definition)
|
void atmosphereSave(FILE* f, AtmosphereDefinition* definition)
|
||||||
{
|
{
|
||||||
toolsSaveDouble(f, definition->distance_near);
|
toolsSaveDouble(f, &definition->distance_near);
|
||||||
toolsSaveDouble(f, definition->distance_far);
|
toolsSaveDouble(f, &definition->distance_far);
|
||||||
toolsSaveDouble(f, definition->full_mask);
|
toolsSaveDouble(f, &definition->full_mask);
|
||||||
toolsSaveInt(f, definition->auto_lock_on_haze);
|
toolsSaveInt(f, &definition->auto_lock_on_haze);
|
||||||
colorSave(definition->color, f);
|
colorSave(f, &definition->color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void atmosphereLoad(FILE* f, AtmosphereDefinition* definition)
|
void atmosphereLoad(FILE* f, AtmosphereDefinition* definition)
|
||||||
{
|
{
|
||||||
definition->distance_near = toolsLoadDouble(f);
|
toolsLoadDouble(f, &definition->distance_near);
|
||||||
definition->distance_far = toolsLoadDouble(f);
|
toolsLoadDouble(f, &definition->distance_far);
|
||||||
definition->full_mask = toolsLoadDouble(f);
|
toolsLoadDouble(f, &definition->full_mask);
|
||||||
definition->auto_lock_on_haze = toolsLoadInt(f);
|
toolsLoadInt(f, &definition->auto_lock_on_haze);
|
||||||
definition->color = colorLoad(f);
|
colorLoad(f, &definition->color);
|
||||||
|
|
||||||
atmosphereValidateDefinition(definition);
|
atmosphereValidateDefinition(definition);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,20 +5,20 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include "shared/types.h"
|
#include "shared/types.h"
|
||||||
#include "shared/functions.h"
|
|
||||||
#include "shared/constants.h"
|
#include "shared/constants.h"
|
||||||
#include "shared/globals.h"
|
#include "shared/globals.h"
|
||||||
|
|
||||||
#include "system.h"
|
|
||||||
#include "water.h"
|
|
||||||
#include "clouds.h"
|
#include "clouds.h"
|
||||||
#include "sky.h"
|
#include "color.h"
|
||||||
|
#include "lighting.h"
|
||||||
#include "modifiers.h"
|
#include "modifiers.h"
|
||||||
|
#include "render.h"
|
||||||
#include "terrain.h"
|
#include "terrain.h"
|
||||||
#include "textures.h"
|
#include "textures.h"
|
||||||
#include "lighting.h"
|
|
||||||
#include "scenery.h"
|
#include "scenery.h"
|
||||||
#include "render.h"
|
#include "sky.h"
|
||||||
|
#include "system.h"
|
||||||
|
#include "water.h"
|
||||||
|
#include "zone.h"
|
||||||
|
|
||||||
static int _is_rendering = 0;
|
static int _is_rendering = 0;
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include "euclid.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "shared/types.h"
|
#include "shared/types.h"
|
||||||
#include "shared/globals.h"
|
#include "shared/globals.h"
|
||||||
#include "shared/constants.h"
|
#include "shared/constants.h"
|
||||||
#include "shared/functions.h"
|
|
||||||
#include "scenery.h"
|
#include "scenery.h"
|
||||||
|
#include "tools.h"
|
||||||
|
|
||||||
void cameraInit()
|
void cameraInit()
|
||||||
{
|
{
|
||||||
|
@ -16,18 +16,18 @@ void cameraInit()
|
||||||
|
|
||||||
void cameraSave(FILE* f, CameraDefinition* camera)
|
void cameraSave(FILE* f, CameraDefinition* camera)
|
||||||
{
|
{
|
||||||
v3Save(camera->location, f);
|
v3Save(f, &camera->location);
|
||||||
toolsSaveDouble(f, camera->yaw);
|
toolsSaveDouble(f, &camera->yaw);
|
||||||
toolsSaveDouble(f, camera->pitch);
|
toolsSaveDouble(f, &camera->pitch);
|
||||||
toolsSaveDouble(f, camera->roll);
|
toolsSaveDouble(f, &camera->roll);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cameraLoad(FILE* f, CameraDefinition* camera)
|
void cameraLoad(FILE* f, CameraDefinition* camera)
|
||||||
{
|
{
|
||||||
camera->location = v3Load(f);
|
v3Load(f, &camera->location);
|
||||||
camera->yaw = toolsLoadDouble(f);
|
toolsLoadDouble(f, &camera->yaw);
|
||||||
camera->pitch = toolsLoadDouble(f);
|
toolsLoadDouble(f, &camera->pitch);
|
||||||
camera->roll = toolsLoadDouble(f);
|
toolsLoadDouble(f, &camera->roll);
|
||||||
|
|
||||||
cameraValidateDefinition(camera, 0);
|
cameraValidateDefinition(camera, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,11 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include "color.h"
|
||||||
|
#include "euclid.h"
|
||||||
#include "lighting.h"
|
#include "lighting.h"
|
||||||
|
#include "tools.h"
|
||||||
#include "shared/types.h"
|
#include "shared/types.h"
|
||||||
#include "shared/functions.h"
|
|
||||||
#include "shared/constants.h"
|
#include "shared/constants.h"
|
||||||
#include "shared/globals.h"
|
#include "shared/globals.h"
|
||||||
|
|
||||||
|
@ -29,17 +30,18 @@ void cloudsSave(FILE* f, CloudsDefinition* definition)
|
||||||
int i;
|
int i;
|
||||||
CloudsLayerDefinition* layer;
|
CloudsLayerDefinition* layer;
|
||||||
|
|
||||||
toolsSaveInt(f, definition->nblayers);
|
toolsSaveInt(f, &definition->nblayers);
|
||||||
for (i = 0; i < definition->nblayers; i++)
|
for (i = 0; i < definition->nblayers; i++)
|
||||||
{
|
{
|
||||||
layer = definition->layers + i;
|
layer = definition->layers + i;
|
||||||
toolsSaveDouble(f, layer->ycenter);
|
|
||||||
toolsSaveDouble(f, layer->ymin);
|
toolsSaveDouble(f, &layer->ycenter);
|
||||||
toolsSaveDouble(f, layer->ymax);
|
toolsSaveDouble(f, &layer->ymin);
|
||||||
noiseSave(layer->noise, f);
|
toolsSaveDouble(f, &layer->ymax);
|
||||||
colorSave(layer->color, f);
|
noiseSave(f, layer->noise);
|
||||||
toolsSaveDouble(f, layer->scaling);
|
colorSave(f, &layer->color);
|
||||||
toolsSaveDouble(f, layer->coverage);
|
toolsSaveDouble(f, &layer->scaling);
|
||||||
|
toolsSaveDouble(f, &layer->coverage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,18 +55,18 @@ void cloudsLoad(FILE* f, CloudsDefinition* definition)
|
||||||
cloudsDeleteLayer(definition, 0);
|
cloudsDeleteLayer(definition, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
n = toolsLoadInt(f);
|
toolsLoadInt(f, &n);
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
layer = definition->layers + cloudsAddLayer(definition);
|
layer = definition->layers + cloudsAddLayer(definition);
|
||||||
|
|
||||||
layer->ycenter = toolsLoadDouble(f);
|
toolsLoadDouble(f, &layer->ycenter);
|
||||||
layer->ymin = toolsLoadDouble(f);
|
toolsLoadDouble(f, &layer->ymin);
|
||||||
layer->ymax = toolsLoadDouble(f);
|
toolsLoadDouble(f, &layer->ymax);
|
||||||
noiseLoad(layer->noise, f);
|
noiseLoad(f, layer->noise);
|
||||||
layer->color = colorLoad(f);
|
colorLoad(f, &layer->color);
|
||||||
layer->scaling = toolsLoadDouble(f);
|
toolsLoadDouble(f, &layer->scaling);
|
||||||
layer->coverage = toolsLoadDouble(f);
|
toolsLoadDouble(f, &layer->coverage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
|
#include "color.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "shared/types.h"
|
|
||||||
#include "shared/constants.h"
|
#include "shared/constants.h"
|
||||||
#include "shared/functions.h"
|
#include "tools.h"
|
||||||
|
|
||||||
Color COLOR_TRANSPARENT = {0.0, 0.0, 0.0, 0.0};
|
Color COLOR_TRANSPARENT = {0.0, 0.0, 0.0, 0.0};
|
||||||
Color COLOR_BLACK = {0.0, 0.0, 0.0, 1.0};
|
Color COLOR_BLACK = {0.0, 0.0, 0.0, 1.0};
|
||||||
|
@ -13,22 +13,20 @@ Color COLOR_BLUE = {0.0, 0.0, 1.0, 1.0};
|
||||||
Color COLOR_WHITE = {1.0, 1.0, 1.0, 1.0};
|
Color COLOR_WHITE = {1.0, 1.0, 1.0, 1.0};
|
||||||
Color COLOR_GREY = {0.5, 0.5, 0.5, 1.0};
|
Color COLOR_GREY = {0.5, 0.5, 0.5, 1.0};
|
||||||
|
|
||||||
void colorSave(Color col, FILE* f)
|
void colorSave(FILE* f, Color* col)
|
||||||
{
|
{
|
||||||
toolsSaveDouble(f, col.r);
|
toolsSaveDouble(f, &col->r);
|
||||||
toolsSaveDouble(f, col.g);
|
toolsSaveDouble(f, &col->g);
|
||||||
toolsSaveDouble(f, col.b);
|
toolsSaveDouble(f, &col->b);
|
||||||
toolsSaveDouble(f, col.a);
|
toolsSaveDouble(f, &col->a);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color colorLoad(FILE* f)
|
void colorLoad(FILE* f, Color* col)
|
||||||
{
|
{
|
||||||
Color col;
|
toolsLoadDouble(f, &col->r);
|
||||||
col.r = toolsLoadDouble(f);
|
toolsLoadDouble(f, &col->g);
|
||||||
col.g = toolsLoadDouble(f);
|
toolsLoadDouble(f, &col->b);
|
||||||
col.b = toolsLoadDouble(f);
|
toolsLoadDouble(f, &col->a);
|
||||||
col.a = toolsLoadDouble(f);
|
|
||||||
return col;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int colorTo32BitRGBA(Color* col)
|
unsigned int colorTo32BitRGBA(Color* col)
|
||||||
|
@ -124,6 +122,30 @@ int _part_compare(const void* part1, const void* part2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void colorGradationSave(FILE* f, ColorGradation* gradation)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
toolsSaveInt(f, &gradation->nbparts);
|
||||||
|
for (i = 0; i < gradation->nbparts; i++)
|
||||||
|
{
|
||||||
|
toolsSaveDouble(f, &gradation->parts[i].start);
|
||||||
|
colorSave(f, &gradation->parts[i].col);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void colorGradationLoad(FILE* f, ColorGradation* gradation)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
toolsLoadInt(f, &gradation->nbparts);
|
||||||
|
for (i = 0; i < gradation->nbparts; i++)
|
||||||
|
{
|
||||||
|
toolsLoadDouble(f, &gradation->parts[i].start);
|
||||||
|
colorLoad(f, &gradation->parts[i].col);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void colorGradationAdd(ColorGradation* gradation, double value, Color* col)
|
void colorGradationAdd(ColorGradation* gradation, double value, Color* col)
|
||||||
{
|
{
|
||||||
if (gradation->nbparts == MAX_COLORGRADATION_PARTS)
|
if (gradation->nbparts == MAX_COLORGRADATION_PARTS)
|
||||||
|
@ -188,29 +210,3 @@ Color colorGradationGet(ColorGradation* gradation, double value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void colorGradationSave(FILE* f, ColorGradation gradation)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
toolsSaveInt(f, gradation.nbparts);
|
|
||||||
for (i = 0; i < gradation.nbparts; i++)
|
|
||||||
{
|
|
||||||
toolsSaveDouble(f, gradation.parts[i].start);
|
|
||||||
colorSave(gradation.parts[i].col, f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ColorGradation colorGradationLoad(FILE* f)
|
|
||||||
{
|
|
||||||
ColorGradation result;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
result.nbparts = toolsLoadInt(f);
|
|
||||||
for (i = 0; i < result.nbparts; i++)
|
|
||||||
{
|
|
||||||
result.parts[i].start = toolsLoadDouble(f);
|
|
||||||
result.parts[i].col = colorLoad(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
31
lib_paysages/color.h
Normal file
31
lib_paysages/color.h
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#ifndef _PAYSAGES_COLOR_H_
|
||||||
|
#define _PAYSAGES_COLOR_H_
|
||||||
|
|
||||||
|
#include "shared/types.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void colorSave(FILE* f, Color* col);
|
||||||
|
void colorLoad(FILE* f, Color* col);
|
||||||
|
unsigned int colorTo32BitRGBA(Color* col);
|
||||||
|
unsigned int colorTo32BitBGRA(Color* col);
|
||||||
|
unsigned int colorTo32BitARGB(Color* col);
|
||||||
|
unsigned int colorTo32BitABGR(Color* col);
|
||||||
|
void colorMask(Color* base, Color* mask);
|
||||||
|
double colorNormalize(Color* col);
|
||||||
|
double colorGetValue(Color* col);
|
||||||
|
|
||||||
|
ColorGradation colorGradationCreate();
|
||||||
|
void colorGradationSave(FILE* f, ColorGradation* gradation);
|
||||||
|
void colorGradationLoad(FILE* f, ColorGradation* gradation);
|
||||||
|
void colorGradationAdd(ColorGradation* gradation, double value, Color* col);
|
||||||
|
void colorGradationAddRgba(ColorGradation* gradation, double value, double r, double g, double b, double a);
|
||||||
|
Color colorGradationGet(ColorGradation* gradation, double value);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,70 +1,23 @@
|
||||||
|
#include "euclid.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "shared/functions.h"
|
#include "tools.h"
|
||||||
#include "shared/types.h"
|
|
||||||
|
|
||||||
Vector3 VECTOR_ZERO = {0.0, 0.0, 0.0};
|
Vector3 VECTOR_ZERO = {0.0, 0.0, 0.0};
|
||||||
|
|
||||||
void v3Save(Vector3 v, FILE* f)
|
void v3Save(FILE* f, Vector3* v)
|
||||||
{
|
{
|
||||||
toolsSaveDouble(f, v.x);
|
toolsSaveDouble(f, &v->x);
|
||||||
toolsSaveDouble(f, v.y);
|
toolsSaveDouble(f, &v->y);
|
||||||
toolsSaveDouble(f, v.z);
|
toolsSaveDouble(f, &v->z);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 v3Load(FILE* f)
|
void v3Load(FILE* f, Vector3* v)
|
||||||
{
|
{
|
||||||
Vector3 result;
|
toolsLoadDouble(f, &v->x);
|
||||||
|
toolsLoadDouble(f, &v->y);
|
||||||
result.x = toolsLoadDouble(f);
|
toolsLoadDouble(f, &v->z);
|
||||||
result.y = toolsLoadDouble(f);
|
|
||||||
result.z = toolsLoadDouble(f);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void m4Save(Matrix4 m, FILE* f)
|
|
||||||
{
|
|
||||||
toolsSaveDouble(f, m.a);
|
|
||||||
toolsSaveDouble(f, m.b);
|
|
||||||
toolsSaveDouble(f, m.c);
|
|
||||||
toolsSaveDouble(f, m.d);
|
|
||||||
toolsSaveDouble(f, m.e);
|
|
||||||
toolsSaveDouble(f, m.f);
|
|
||||||
toolsSaveDouble(f, m.g);
|
|
||||||
toolsSaveDouble(f, m.h);
|
|
||||||
toolsSaveDouble(f, m.i);
|
|
||||||
toolsSaveDouble(f, m.j);
|
|
||||||
toolsSaveDouble(f, m.k);
|
|
||||||
toolsSaveDouble(f, m.l);
|
|
||||||
toolsSaveDouble(f, m.m);
|
|
||||||
toolsSaveDouble(f, m.n);
|
|
||||||
toolsSaveDouble(f, m.o);
|
|
||||||
toolsSaveDouble(f, m.p);
|
|
||||||
}
|
|
||||||
|
|
||||||
Matrix4 m4Load(FILE* f)
|
|
||||||
{
|
|
||||||
Matrix4 result;
|
|
||||||
|
|
||||||
result.a = toolsLoadDouble(f);
|
|
||||||
result.b = toolsLoadDouble(f);
|
|
||||||
result.c = toolsLoadDouble(f);
|
|
||||||
result.d = toolsLoadDouble(f);
|
|
||||||
result.e = toolsLoadDouble(f);
|
|
||||||
result.f = toolsLoadDouble(f);
|
|
||||||
result.g = toolsLoadDouble(f);
|
|
||||||
result.h = toolsLoadDouble(f);
|
|
||||||
result.i = toolsLoadDouble(f);
|
|
||||||
result.j = toolsLoadDouble(f);
|
|
||||||
result.k = toolsLoadDouble(f);
|
|
||||||
result.l = toolsLoadDouble(f);
|
|
||||||
result.m = toolsLoadDouble(f);
|
|
||||||
result.n = toolsLoadDouble(f);
|
|
||||||
result.o = toolsLoadDouble(f);
|
|
||||||
result.p = toolsLoadDouble(f);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 v3Translate(Vector3 v1, double x, double y, double z)
|
Vector3 v3Translate(Vector3 v1, double x, double y, double z)
|
||||||
|
@ -144,6 +97,46 @@ Vector3 v3Cross(Vector3 v1, Vector3 v2)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void m4Save(FILE* f, Matrix4* m)
|
||||||
|
{
|
||||||
|
toolsSaveDouble(f, &m->a);
|
||||||
|
toolsSaveDouble(f, &m->b);
|
||||||
|
toolsSaveDouble(f, &m->c);
|
||||||
|
toolsSaveDouble(f, &m->d);
|
||||||
|
toolsSaveDouble(f, &m->e);
|
||||||
|
toolsSaveDouble(f, &m->f);
|
||||||
|
toolsSaveDouble(f, &m->g);
|
||||||
|
toolsSaveDouble(f, &m->h);
|
||||||
|
toolsSaveDouble(f, &m->i);
|
||||||
|
toolsSaveDouble(f, &m->j);
|
||||||
|
toolsSaveDouble(f, &m->k);
|
||||||
|
toolsSaveDouble(f, &m->l);
|
||||||
|
toolsSaveDouble(f, &m->m);
|
||||||
|
toolsSaveDouble(f, &m->n);
|
||||||
|
toolsSaveDouble(f, &m->o);
|
||||||
|
toolsSaveDouble(f, &m->p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void m4Load(FILE* f, Matrix4* m)
|
||||||
|
{
|
||||||
|
toolsLoadDouble(f, &m->a);
|
||||||
|
toolsLoadDouble(f, &m->b);
|
||||||
|
toolsLoadDouble(f, &m->c);
|
||||||
|
toolsLoadDouble(f, &m->d);
|
||||||
|
toolsLoadDouble(f, &m->e);
|
||||||
|
toolsLoadDouble(f, &m->f);
|
||||||
|
toolsLoadDouble(f, &m->g);
|
||||||
|
toolsLoadDouble(f, &m->h);
|
||||||
|
toolsLoadDouble(f, &m->i);
|
||||||
|
toolsLoadDouble(f, &m->j);
|
||||||
|
toolsLoadDouble(f, &m->k);
|
||||||
|
toolsLoadDouble(f, &m->l);
|
||||||
|
toolsLoadDouble(f, &m->m);
|
||||||
|
toolsLoadDouble(f, &m->n);
|
||||||
|
toolsLoadDouble(f, &m->o);
|
||||||
|
toolsLoadDouble(f, &m->p);
|
||||||
|
}
|
||||||
|
|
||||||
Matrix4 m4NewIdentity()
|
Matrix4 m4NewIdentity()
|
||||||
{
|
{
|
||||||
Matrix4 result;
|
Matrix4 result;
|
||||||
|
|
46
lib_paysages/euclid.h
Normal file
46
lib_paysages/euclid.h
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
#ifndef _PAYSAGES_EUCLID_H_
|
||||||
|
#define _PAYSAGES_EUCLID_H_
|
||||||
|
|
||||||
|
#include "shared/types.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void v3Save(FILE* f, Vector3* v);
|
||||||
|
void v3Load(FILE* f, Vector3* v);
|
||||||
|
Vector3 v3Translate(Vector3 v1, double x, double y, double z);
|
||||||
|
Vector3 v3Add(Vector3 v1, Vector3 v2);
|
||||||
|
Vector3 v3Sub(Vector3 v1, Vector3 v2);
|
||||||
|
Vector3 v3Neg(Vector3 v);
|
||||||
|
Vector3 v3Scale(Vector3 v, double scale);
|
||||||
|
double v3Norm(Vector3 v);
|
||||||
|
Vector3 v3Normalize(Vector3 v);
|
||||||
|
double v3Dot(Vector3 v1, Vector3 v2);
|
||||||
|
Vector3 v3Cross(Vector3 v1, Vector3 v2);
|
||||||
|
|
||||||
|
void m4Save(FILE* f, Matrix4* m);
|
||||||
|
void m4Load(FILE* f, Matrix4* m);
|
||||||
|
Matrix4 m4NewIdentity();
|
||||||
|
Matrix4 m4Mult(Matrix4 m1, Matrix4 m2);
|
||||||
|
Vector3 m4MultPoint(Matrix4 m, Vector3 v);
|
||||||
|
Vector3 m4Transform(Matrix4 m, Vector3 v);
|
||||||
|
Matrix4 m4Transpose(Matrix4 m);
|
||||||
|
Matrix4 m4NewScale(double x, double y, double z);
|
||||||
|
Matrix4 m4NewTranslate(double x, double y, double z);
|
||||||
|
Matrix4 m4NewRotateX(double angle);
|
||||||
|
Matrix4 m4NewRotateY(double angle);
|
||||||
|
Matrix4 m4NewRotateZ(double angle);
|
||||||
|
Matrix4 m4NewRotateAxis(double angle, Vector3 axis);
|
||||||
|
Matrix4 m4NewRotateEuler(double heading, double attitude, double bank);
|
||||||
|
Matrix4 m4NewRotateTripleAxis(Vector3 x, Vector3 y, Vector3 z);
|
||||||
|
Matrix4 m4NewLookAt(Vector3 eye, Vector3 at, Vector3 up);
|
||||||
|
Matrix4 m4NewPerspective(double fov_y, double aspect, double near, double far);
|
||||||
|
double m4Determinant(Matrix4 m);
|
||||||
|
Matrix4 m4Inverse(Matrix4 m);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -6,14 +6,16 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "shared/types.h"
|
#include "shared/types.h"
|
||||||
#include "shared/functions.h"
|
|
||||||
#include "shared/constants.h"
|
#include "shared/constants.h"
|
||||||
#include "shared/globals.h"
|
#include "shared/globals.h"
|
||||||
#include "sky.h"
|
#include "color.h"
|
||||||
#include "water.h"
|
#include "euclid.h"
|
||||||
#include "terrain.h"
|
|
||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
#include "scenery.h"
|
#include "scenery.h"
|
||||||
|
#include "sky.h"
|
||||||
|
#include "terrain.h"
|
||||||
|
#include "tools.h"
|
||||||
|
#include "water.h"
|
||||||
|
|
||||||
static LightDefinition _LIGHT_NULL;
|
static LightDefinition _LIGHT_NULL;
|
||||||
|
|
||||||
|
@ -33,16 +35,16 @@ void lightingSave(FILE* f, LightingDefinition* definition)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
toolsSaveInt(f, definition->autosetfromsky);
|
toolsSaveInt(f, &definition->autosetfromsky);
|
||||||
toolsSaveInt(f, definition->nblights);
|
toolsSaveInt(f, &definition->nblights);
|
||||||
for (i = 0; i < definition->nblights; i++)
|
for (i = 0; i < definition->nblights; i++)
|
||||||
{
|
{
|
||||||
v3Save(definition->lights[i].direction, f);
|
v3Save(f, &definition->lights[i].direction);
|
||||||
colorSave(definition->lights[i].color, f);
|
colorSave(f, &definition->lights[i].color);
|
||||||
toolsSaveDouble(f, definition->lights[i].reflection);
|
toolsSaveDouble(f, &definition->lights[i].reflection);
|
||||||
toolsSaveInt(f, definition->lights[i].filtered);
|
toolsSaveInt(f, &definition->lights[i].filtered);
|
||||||
toolsSaveInt(f, definition->lights[i].masked);
|
toolsSaveInt(f, &definition->lights[i].masked);
|
||||||
toolsSaveDouble(f, definition->lights[i].amplitude);
|
toolsSaveDouble(f, &definition->lights[i].amplitude);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,16 +52,16 @@ void lightingLoad(FILE* f, LightingDefinition* definition)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
definition->autosetfromsky = toolsLoadInt(f);
|
toolsLoadInt(f, &definition->autosetfromsky);
|
||||||
definition->nblights = toolsLoadInt(f);
|
toolsLoadInt(f, &definition->nblights);
|
||||||
for (i = 0; i < definition->nblights; i++)
|
for (i = 0; i < definition->nblights; i++)
|
||||||
{
|
{
|
||||||
definition->lights[i].direction = v3Load(f);
|
v3Load(f, &definition->lights[i].direction);
|
||||||
definition->lights[i].color = colorLoad(f);
|
colorLoad(f, &definition->lights[i].color);
|
||||||
definition->lights[i].reflection = toolsLoadDouble(f);
|
toolsLoadDouble(f, &definition->lights[i].reflection);
|
||||||
definition->lights[i].filtered = toolsLoadInt(f);
|
toolsLoadInt(f, &definition->lights[i].filtered);
|
||||||
definition->lights[i].masked = toolsLoadInt(f);
|
toolsLoadInt(f, &definition->lights[i].masked);
|
||||||
definition->lights[i].amplitude = toolsLoadDouble(f);
|
toolsLoadDouble(f, &definition->lights[i].amplitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
lightingValidateDefinition(definition);
|
lightingValidateDefinition(definition);
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include "shared/types.h"
|
#include "shared/types.h"
|
||||||
#include "shared/constants.h"
|
#include "shared/constants.h"
|
||||||
#include "shared/functions.h"
|
|
||||||
#include "shared/globals.h"
|
#include "shared/globals.h"
|
||||||
|
|
||||||
#include "auto.h"
|
#include "auto.h"
|
||||||
|
|
16
lib_paysages/main.h
Normal file
16
lib_paysages/main.h
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#ifndef _PAYSAGES_MAIN_H_
|
||||||
|
#define _PAYSAGES_MAIN_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void paysagesInit();
|
||||||
|
void paysagesSave(char* filepath);
|
||||||
|
void paysagesLoad(char* filepath);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,20 +1,18 @@
|
||||||
#include "shared/types.h"
|
|
||||||
#include "shared/functions.h"
|
|
||||||
#include "modifiers.h"
|
#include "modifiers.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
typedef enum
|
#include "shared/types.h"
|
||||||
{
|
#include "tools.h"
|
||||||
MODE_NULL,
|
|
||||||
MODE_ADD_VALUE,
|
#define MODE_NULL 0
|
||||||
MODE_FIX_VALUE
|
#define MODE_ADD_VALUE 1
|
||||||
} _EnumMode;
|
#define MODE_FIX_VALUE 2
|
||||||
|
|
||||||
struct HeightModifier
|
struct HeightModifier
|
||||||
{
|
{
|
||||||
Zone* zone;
|
Zone* zone;
|
||||||
_EnumMode mode;
|
int mode;
|
||||||
double value;
|
double value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -48,18 +46,18 @@ void modifierDelete(HeightModifier* modifier)
|
||||||
free(modifier);
|
free(modifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
void modifierSave(HeightModifier* modifier, FILE* f)
|
void modifierSave(FILE* f, HeightModifier* modifier)
|
||||||
{
|
{
|
||||||
toolsSaveInt(f, modifier->mode);
|
toolsSaveInt(f, &modifier->mode);
|
||||||
toolsSaveDouble(f, modifier->value);
|
toolsSaveDouble(f, &modifier->value);
|
||||||
zoneSave(modifier->zone, f);
|
zoneSave(f, modifier->zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
void modifierLoad(HeightModifier* modifier, FILE* f)
|
void modifierLoad(FILE* f, HeightModifier* modifier)
|
||||||
{
|
{
|
||||||
modifier->mode = toolsLoadInt(f);
|
toolsLoadInt(f, &modifier->mode);
|
||||||
modifier->value = toolsLoadDouble(f);
|
toolsLoadDouble(f, &modifier->value);
|
||||||
zoneLoad(modifier->zone, f);
|
zoneLoad(f, modifier->zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
Zone* modifierGetZone(HeightModifier* modifier)
|
Zone* modifierGetZone(HeightModifier* modifier)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define _PAYSAGES_MODIFIERS_H_
|
#define _PAYSAGES_MODIFIERS_H_
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "zone.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -12,8 +13,8 @@ typedef struct HeightModifier HeightModifier;
|
||||||
HeightModifier* modifierCreate();
|
HeightModifier* modifierCreate();
|
||||||
HeightModifier* modifierCreateCopy(HeightModifier* source);
|
HeightModifier* modifierCreateCopy(HeightModifier* source);
|
||||||
void modifierDelete(HeightModifier* modifier);
|
void modifierDelete(HeightModifier* modifier);
|
||||||
void modifierSave(HeightModifier* modifier, FILE* f);
|
void modifierSave(FILE* f, HeightModifier* modifier);
|
||||||
void modifierLoad(HeightModifier* modifier, FILE* f);
|
void modifierLoad(FILE* f, HeightModifier* modifier);
|
||||||
Zone* modifierGetZone(HeightModifier* modifier);
|
Zone* modifierGetZone(HeightModifier* modifier);
|
||||||
void modifierActionAddValue(HeightModifier* modifier, double value);
|
void modifierActionAddValue(HeightModifier* modifier, double value);
|
||||||
void modifierActionFixValue(HeightModifier* modifier, double value);
|
void modifierActionFixValue(HeightModifier* modifier, double value);
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
#include "noise.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "tools.h"
|
||||||
|
|
||||||
struct NoiseLevel;
|
struct NoiseLevel;
|
||||||
|
|
||||||
struct NoiseGenerator
|
struct NoiseGenerator
|
||||||
|
@ -11,14 +19,6 @@ struct NoiseGenerator
|
||||||
struct NoiseLevel* levels;
|
struct NoiseLevel* levels;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "noise.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "shared/functions.h"
|
|
||||||
|
|
||||||
static inline double _cubicInterpolate(double* p, double x)
|
static inline double _cubicInterpolate(double* p, double x)
|
||||||
{
|
{
|
||||||
return p[1] + 0.5 * x * (p[2] - p[0] + x * (2.0 * p[0] - 5.0 * p[1] + 4.0 * p[2] - p[3] + x * (3.0 * (p[1] - p[2]) + p[3] - p[0])));
|
return p[1] + 0.5 * x * (p[2] - p[0] + x * (2.0 * p[0] - 5.0 * p[1] + 4.0 * p[2] - p[3] + x * (3.0 * (p[1] - p[2]) + p[3] - p[0])));
|
||||||
|
@ -49,61 +49,63 @@ void noiseDeleteGenerator(NoiseGenerator* generator)
|
||||||
free(generator);
|
free(generator);
|
||||||
}
|
}
|
||||||
|
|
||||||
void noiseSave(NoiseGenerator* perlin, FILE* f)
|
void noiseSave(FILE* f, NoiseGenerator* perlin)
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
double* it_noise;
|
double* it_noise;
|
||||||
|
|
||||||
toolsSaveInt(f, perlin->size1);
|
toolsSaveInt(f, &perlin->size1);
|
||||||
toolsSaveInt(f, perlin->size2);
|
toolsSaveInt(f, &perlin->size2);
|
||||||
toolsSaveInt(f, perlin->size3);
|
toolsSaveInt(f, &perlin->size3);
|
||||||
toolsSaveDouble(f, perlin->height_offset);
|
toolsSaveDouble(f, &perlin->height_offset);
|
||||||
toolsSaveInt(f, perlin->level_count);
|
toolsSaveInt(f, &perlin->level_count);
|
||||||
|
|
||||||
it_noise = perlin->noise;
|
it_noise = perlin->noise;
|
||||||
for (x = 0; x < perlin->size1; x++)
|
for (x = 0; x < perlin->size1; x++)
|
||||||
{
|
{
|
||||||
toolsSaveDouble(f, *(it_noise++));
|
toolsSaveDouble(f, it_noise++);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (x = 0; x < perlin->level_count; x++)
|
for (x = 0; x < perlin->level_count; x++)
|
||||||
{
|
{
|
||||||
NoiseLevel level = perlin->levels[x];
|
NoiseLevel* level = perlin->levels + x;
|
||||||
toolsSaveDouble(f, level.scaling);
|
|
||||||
toolsSaveDouble(f, level.height);
|
toolsSaveDouble(f, &level->scaling);
|
||||||
toolsSaveDouble(f, level.xoffset);
|
toolsSaveDouble(f, &level->height);
|
||||||
toolsSaveDouble(f, level.yoffset);
|
toolsSaveDouble(f, &level->xoffset);
|
||||||
toolsSaveDouble(f, level.zoffset);
|
toolsSaveDouble(f, &level->yoffset);
|
||||||
|
toolsSaveDouble(f, &level->zoffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void noiseLoad(NoiseGenerator* perlin, FILE* f)
|
void noiseLoad(FILE* f, NoiseGenerator* perlin)
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
double* it_noise;
|
double* it_noise;
|
||||||
|
|
||||||
perlin->size1 = toolsLoadInt(f);
|
toolsLoadInt(f, &perlin->size1);
|
||||||
perlin->size2 = toolsLoadInt(f);
|
toolsLoadInt(f, &perlin->size2);
|
||||||
perlin->size3 = toolsLoadInt(f);
|
toolsLoadInt(f, &perlin->size3);
|
||||||
perlin->height_offset = toolsLoadDouble(f);
|
toolsLoadDouble(f, &perlin->height_offset);
|
||||||
perlin->level_count = toolsLoadInt(f);
|
toolsLoadInt(f, &perlin->level_count);
|
||||||
|
|
||||||
perlin->noise = realloc(perlin->noise, sizeof(double) * perlin->size1);
|
perlin->noise = realloc(perlin->noise, sizeof(double) * perlin->size1);
|
||||||
it_noise = perlin->noise;
|
it_noise = perlin->noise;
|
||||||
for (x = 0; x < perlin->size1; x++)
|
for (x = 0; x < perlin->size1; x++)
|
||||||
{
|
{
|
||||||
*(it_noise++) = toolsLoadDouble(f);
|
toolsLoadDouble(f, it_noise++);
|
||||||
}
|
}
|
||||||
|
|
||||||
perlin->levels = realloc(perlin->levels, sizeof(NoiseLevel) * perlin->level_count);
|
perlin->levels = realloc(perlin->levels, sizeof(NoiseLevel) * perlin->level_count);
|
||||||
for (x = 0; x < perlin->level_count; x++)
|
for (x = 0; x < perlin->level_count; x++)
|
||||||
{
|
{
|
||||||
NoiseLevel* level = perlin->levels + x;
|
NoiseLevel* level = perlin->levels + x;
|
||||||
level->scaling = toolsLoadDouble(f);
|
|
||||||
level->height = toolsLoadDouble(f);
|
toolsLoadDouble(f, &level->scaling);
|
||||||
level->xoffset = toolsLoadDouble(f);
|
toolsLoadDouble(f, &level->height);
|
||||||
level->yoffset = toolsLoadDouble(f);
|
toolsLoadDouble(f, &level->xoffset);
|
||||||
level->zoffset = toolsLoadDouble(f);
|
toolsLoadDouble(f, &level->yoffset);
|
||||||
|
toolsLoadDouble(f, &level->zoffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,8 @@ typedef struct NoiseGenerator NoiseGenerator;
|
||||||
|
|
||||||
NoiseGenerator* noiseCreateGenerator();
|
NoiseGenerator* noiseCreateGenerator();
|
||||||
void noiseDeleteGenerator(NoiseGenerator* generator);
|
void noiseDeleteGenerator(NoiseGenerator* generator);
|
||||||
void noiseSave(NoiseGenerator* perlin, FILE* f);
|
void noiseSave(FILE* f, NoiseGenerator* perlin);
|
||||||
void noiseLoad(NoiseGenerator* perlin, FILE* f);
|
void noiseLoad(FILE* f, NoiseGenerator* perlin);
|
||||||
void noiseCopy(NoiseGenerator* source, NoiseGenerator* destination);
|
void noiseCopy(NoiseGenerator* source, NoiseGenerator* destination);
|
||||||
void noiseGenerateBaseNoise(NoiseGenerator* generator, int size);
|
void noiseGenerateBaseNoise(NoiseGenerator* generator, int size);
|
||||||
int noiseGetBaseSize(NoiseGenerator* generator);
|
int noiseGetBaseSize(NoiseGenerator* generator);
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "IL/il.h"
|
#include "IL/il.h"
|
||||||
#include "IL/ilu.h"
|
#include "IL/ilu.h"
|
||||||
|
|
||||||
#include "shared/types.h"
|
#include "shared/types.h"
|
||||||
#include "shared/constants.h"
|
#include "shared/constants.h"
|
||||||
#include "shared/functions.h"
|
#include "array.h"
|
||||||
|
#include "color.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
int render_width;
|
int render_width;
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
#include "scenery.h"
|
#include "scenery.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "shared/functions.h"
|
#include "color.h"
|
||||||
#include "system.h"
|
#include "euclid.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
|
#include "system.h"
|
||||||
|
|
||||||
AtmosphereDefinition _atmosphere;
|
AtmosphereDefinition _atmosphere;
|
||||||
CameraDefinition _camera;
|
CameraDefinition _camera;
|
||||||
|
@ -48,6 +49,7 @@ void scenerySaveToFile(char* filepath)
|
||||||
texturesSave(f, &_textures);
|
texturesSave(f, &_textures);
|
||||||
waterSave(f, &_water);
|
waterSave(f, &_water);
|
||||||
|
|
||||||
|
fflush(f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,101 +0,0 @@
|
||||||
#ifndef _PAYSAGES_FUNCTIONS_H_
|
|
||||||
#define _PAYSAGES_FUNCTIONS_H_
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "types.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
void paysagesInit();
|
|
||||||
void paysagesSave(char* filepath);
|
|
||||||
void paysagesLoad(char* filepath);
|
|
||||||
|
|
||||||
/* array.c */
|
|
||||||
void arrayCreate(Array* array, int item_size);
|
|
||||||
void arrayDelete(Array* array);
|
|
||||||
void* arrayAppend(Array* array, void* item);
|
|
||||||
void arrayInsert(Array* array, void* item, int position);
|
|
||||||
void arrayReplace(Array* array, void* item, int position);
|
|
||||||
void arrayLStrip(Array* array, int count);
|
|
||||||
void arrayClear(Array* array);
|
|
||||||
|
|
||||||
/* color.c */
|
|
||||||
void colorSave(Color col, FILE* f);
|
|
||||||
Color colorLoad(FILE* f);
|
|
||||||
unsigned int colorTo32BitRGBA(Color* col);
|
|
||||||
unsigned int colorTo32BitBGRA(Color* col);
|
|
||||||
unsigned int colorTo32BitARGB(Color* col);
|
|
||||||
unsigned int colorTo32BitABGR(Color* col);
|
|
||||||
void colorMask(Color* base, Color* mask);
|
|
||||||
double colorNormalize(Color* col);
|
|
||||||
double colorGetValue(Color* col);
|
|
||||||
ColorGradation colorGradationCreate();
|
|
||||||
void colorGradationAdd(ColorGradation* gradation, double value, Color* col);
|
|
||||||
void colorGradationAddRgba(ColorGradation* gradation, double value, double r, double g, double b, double a);
|
|
||||||
Color colorGradationGet(ColorGradation* gradation, double value);
|
|
||||||
void colorGradationSave(FILE* f, ColorGradation gradation);
|
|
||||||
ColorGradation colorGradationLoad(FILE* f);
|
|
||||||
|
|
||||||
/* euclid.c */
|
|
||||||
void v3Save(Vector3 v, FILE* f);
|
|
||||||
Vector3 v3Load(FILE* f);
|
|
||||||
void m4Save(Matrix4 m, FILE* f);
|
|
||||||
Matrix4 m4Load(FILE* f);
|
|
||||||
Vector3 v3Translate(Vector3 v1, double x, double y, double z);
|
|
||||||
Vector3 v3Add(Vector3 v1, Vector3 v2);
|
|
||||||
Vector3 v3Sub(Vector3 v1, Vector3 v2);
|
|
||||||
Vector3 v3Neg(Vector3 v);
|
|
||||||
Vector3 v3Scale(Vector3 v, double scale);
|
|
||||||
double v3Norm(Vector3 v);
|
|
||||||
Vector3 v3Normalize(Vector3 v);
|
|
||||||
double v3Dot(Vector3 v1, Vector3 v2);
|
|
||||||
Vector3 v3Cross(Vector3 v1, Vector3 v2);
|
|
||||||
Matrix4 m4NewIdentity();
|
|
||||||
Matrix4 m4Mult(Matrix4 m1, Matrix4 m2);
|
|
||||||
Vector3 m4MultPoint(Matrix4 m, Vector3 v);
|
|
||||||
Vector3 m4Transform(Matrix4 m, Vector3 v);
|
|
||||||
Matrix4 m4Transpose(Matrix4 m);
|
|
||||||
Matrix4 m4NewScale(double x, double y, double z);
|
|
||||||
Matrix4 m4NewTranslate(double x, double y, double z);
|
|
||||||
Matrix4 m4NewRotateX(double angle);
|
|
||||||
Matrix4 m4NewRotateY(double angle);
|
|
||||||
Matrix4 m4NewRotateZ(double angle);
|
|
||||||
Matrix4 m4NewRotateAxis(double angle, Vector3 axis);
|
|
||||||
Matrix4 m4NewRotateEuler(double heading, double attitude, double bank);
|
|
||||||
Matrix4 m4NewRotateTripleAxis(Vector3 x, Vector3 y, Vector3 z);
|
|
||||||
Matrix4 m4NewLookAt(Vector3 eye, Vector3 at, Vector3 up);
|
|
||||||
Matrix4 m4NewPerspective(double fov_y, double aspect, double near, double far);
|
|
||||||
double m4Determinant(Matrix4 m);
|
|
||||||
Matrix4 m4Inverse(Matrix4 m);
|
|
||||||
|
|
||||||
/* tools.c */
|
|
||||||
double toolsRandom();
|
|
||||||
double toolsBicubicInterpolate(double stencil[16], double x, double y);
|
|
||||||
void toolsFloat2DMapCopy(double* src, double* dest, int src_xstart, int src_ystart, int dest_xstart, int dest_ystart, int xsize, int ysize, int src_xstep, int src_ystep, int dest_xstep, int dest_ystep);
|
|
||||||
Vector3 toolsGetNormalFromTriangle(Vector3 center, Vector3 bottom, Vector3 right);
|
|
||||||
void toolsSaveDouble(FILE* f, double value);
|
|
||||||
double toolsLoadDouble(FILE* f);
|
|
||||||
void toolsSaveInt(FILE* f, int value);
|
|
||||||
int toolsLoadInt(FILE* f);
|
|
||||||
void materialSave(FILE* f, SurfaceMaterial* material);
|
|
||||||
void materialLoad(FILE* f, SurfaceMaterial* material);
|
|
||||||
|
|
||||||
/* zone.c */
|
|
||||||
Zone* zoneCreate();
|
|
||||||
void zoneDelete(Zone* zone);
|
|
||||||
void zoneSave(Zone* zone, FILE* f);
|
|
||||||
void zoneLoad(Zone* zone, FILE* f);
|
|
||||||
void zoneCopy(Zone* source, Zone* destination);
|
|
||||||
void zoneIncludeCircleArea(Zone* zone, double value, double centerx, double centerz, double softradius, double hardradius);
|
|
||||||
void zoneExcludeCircleArea(Zone* zone, double centerx, double centerz, double softradius, double hardradius);
|
|
||||||
void zoneAddHeightRange(Zone* zone, double value, double hardmin, double softmin, double softmax, double hardmax);
|
|
||||||
void zoneAddSteepnessRange(Zone* zone, double value, double hardmin, double softmin, double softmax, double hardmax);
|
|
||||||
double zoneGetValue(Zone* zone, Vector3 location, Vector3 normal);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef _PAYSAGES_TYPES_H_
|
#ifndef _PAYSAGES_TYPES_H_
|
||||||
#define _PAYSAGES_TYPES_H_
|
#define _PAYSAGES_TYPES_H_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -4,12 +4,14 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "shared/types.h"
|
#include "shared/types.h"
|
||||||
#include "shared/functions.h"
|
|
||||||
#include "shared/globals.h"
|
#include "shared/globals.h"
|
||||||
#include "shared/constants.h"
|
#include "shared/constants.h"
|
||||||
#include "render.h"
|
#include "color.h"
|
||||||
#include "clouds.h"
|
#include "clouds.h"
|
||||||
|
#include "euclid.h"
|
||||||
#include "lighting.h"
|
#include "lighting.h"
|
||||||
|
#include "render.h"
|
||||||
|
#include "tools.h"
|
||||||
|
|
||||||
#define SPHERE_SIZE 1000.0
|
#define SPHERE_SIZE 1000.0
|
||||||
|
|
||||||
|
@ -19,24 +21,24 @@ void skyInit()
|
||||||
|
|
||||||
void skySave(FILE* f, SkyDefinition* definition)
|
void skySave(FILE* f, SkyDefinition* definition)
|
||||||
{
|
{
|
||||||
toolsSaveDouble(f, definition->daytime);
|
toolsSaveDouble(f, &definition->daytime);
|
||||||
colorGradationSave(f, definition->sun_color);
|
colorGradationSave(f, &definition->sun_color);
|
||||||
toolsSaveDouble(f, definition->sun_radius);
|
toolsSaveDouble(f, &definition->sun_radius);
|
||||||
colorGradationSave(f, definition->zenith_color);
|
colorGradationSave(f, &definition->zenith_color);
|
||||||
colorGradationSave(f, definition->haze_color);
|
colorGradationSave(f, &definition->haze_color);
|
||||||
toolsSaveDouble(f, definition->haze_height);
|
toolsSaveDouble(f, &definition->haze_height);
|
||||||
toolsSaveDouble(f, definition->haze_smoothing);
|
toolsSaveDouble(f, &definition->haze_smoothing);
|
||||||
}
|
}
|
||||||
|
|
||||||
void skyLoad(FILE* f, SkyDefinition* definition)
|
void skyLoad(FILE* f, SkyDefinition* definition)
|
||||||
{
|
{
|
||||||
definition->daytime = toolsLoadDouble(f);
|
toolsLoadDouble(f, &definition->daytime);
|
||||||
definition->sun_color = colorGradationLoad(f);
|
colorGradationLoad(f, &definition->sun_color);
|
||||||
definition->sun_radius = toolsLoadDouble(f);
|
toolsLoadDouble(f, &definition->sun_radius);
|
||||||
definition->zenith_color = colorGradationLoad(f);
|
colorGradationLoad(f, &definition->zenith_color);
|
||||||
definition->haze_color = colorGradationLoad(f);
|
colorGradationLoad(f, &definition->haze_color);
|
||||||
definition->haze_height = toolsLoadDouble(f);
|
toolsLoadDouble(f, &definition->haze_height);
|
||||||
definition->haze_smoothing = toolsLoadDouble(f);
|
toolsLoadDouble(f, &definition->haze_smoothing);
|
||||||
|
|
||||||
skyValidateDefinition(definition);
|
skyValidateDefinition(definition);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,13 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "shared/types.h"
|
#include "shared/types.h"
|
||||||
#include "shared/functions.h"
|
|
||||||
#include "shared/globals.h"
|
#include "shared/globals.h"
|
||||||
#include "shared/constants.h"
|
#include "shared/constants.h"
|
||||||
|
#include "euclid.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "textures.h"
|
#include "textures.h"
|
||||||
#include "water.h"
|
#include "water.h"
|
||||||
|
#include "tools.h"
|
||||||
|
|
||||||
void terrainInit()
|
void terrainInit()
|
||||||
{
|
{
|
||||||
|
@ -22,14 +22,14 @@ void terrainSave(FILE* f, TerrainDefinition* definition)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
noiseSave(definition->height_noise, f);
|
noiseSave(f, definition->height_noise);
|
||||||
toolsSaveDouble(f, definition->height_factor);
|
toolsSaveDouble(f, &definition->height_factor);
|
||||||
toolsSaveDouble(f, definition->scaling);
|
toolsSaveDouble(f, &definition->scaling);
|
||||||
|
|
||||||
toolsSaveInt(f, definition->height_modifiers_count);
|
toolsSaveInt(f, &definition->height_modifiers_count);
|
||||||
for (i = 0; i < definition->height_modifiers_count; i++)
|
for (i = 0; i < definition->height_modifiers_count; i++)
|
||||||
{
|
{
|
||||||
modifierSave(definition->height_modifiers[i], f);
|
modifierSave(f, definition->height_modifiers[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,19 +38,19 @@ void terrainLoad(FILE* f, TerrainDefinition* definition)
|
||||||
int i, n;
|
int i, n;
|
||||||
HeightModifier* modifier;
|
HeightModifier* modifier;
|
||||||
|
|
||||||
noiseLoad(definition->height_noise, f);
|
noiseLoad(f, definition->height_noise);
|
||||||
definition->height_factor = toolsLoadDouble(f);
|
toolsLoadDouble(f, &definition->height_factor);
|
||||||
definition->scaling = toolsLoadDouble(f);
|
toolsLoadDouble(f, &definition->scaling);
|
||||||
|
|
||||||
while (definition->height_modifiers_count > 0)
|
while (definition->height_modifiers_count > 0)
|
||||||
{
|
{
|
||||||
terrainDelModifier(definition, 0);
|
terrainDelModifier(definition, 0);
|
||||||
}
|
}
|
||||||
n = toolsLoadInt(f);
|
toolsLoadInt(f, &n);
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
modifier = modifierCreate();
|
modifier = modifierCreate();
|
||||||
modifierLoad(modifier, f);
|
modifierLoad(f, modifier);
|
||||||
terrainAddModifier(definition, modifier);
|
terrainAddModifier(definition, modifier);
|
||||||
modifierDelete(modifier);
|
modifierDelete(modifier);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
|
#include "textures.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "shared/types.h"
|
#include "shared/types.h"
|
||||||
#include "shared/functions.h"
|
|
||||||
#include "shared/constants.h"
|
#include "shared/constants.h"
|
||||||
#include "shared/globals.h"
|
#include "shared/globals.h"
|
||||||
|
#include "color.h"
|
||||||
#include "textures.h"
|
#include "euclid.h"
|
||||||
#include "terrain.h"
|
|
||||||
#include "lighting.h"
|
#include "lighting.h"
|
||||||
|
#include "terrain.h"
|
||||||
|
#include "tools.h"
|
||||||
|
|
||||||
static TextureLayerDefinition _NULL_LAYER;
|
static TextureLayerDefinition _NULL_LAYER;
|
||||||
|
|
||||||
|
@ -23,12 +25,12 @@ void texturesSave(FILE* f, TexturesDefinition* definition)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
toolsSaveInt(f, definition->nbtextures);
|
toolsSaveInt(f, &definition->nbtextures);
|
||||||
for (i = 0; i < definition->nbtextures; i++)
|
for (i = 0; i < definition->nbtextures; i++)
|
||||||
{
|
{
|
||||||
zoneSave(definition->textures[i].zone, f);
|
zoneSave(f, definition->textures[i].zone);
|
||||||
noiseSave(definition->textures[i].bump_noise, f);
|
noiseSave(f, definition->textures[i].bump_noise);
|
||||||
colorSave(definition->textures[i].color, f);
|
colorSave(f, &definition->textures[i].color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,14 +44,14 @@ void texturesLoad(FILE* f, TexturesDefinition* definition)
|
||||||
texturesDeleteLayer(definition, 0);
|
texturesDeleteLayer(definition, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
n = toolsLoadInt(f);
|
toolsLoadInt(f, &n);
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
layer = definition->textures + texturesAddLayer(definition);
|
layer = definition->textures + texturesAddLayer(definition);
|
||||||
|
|
||||||
zoneLoad(layer->zone, f);
|
zoneLoad(f, layer->zone);
|
||||||
noiseLoad(layer->bump_noise, f);
|
noiseLoad(f, layer->bump_noise);
|
||||||
layer->color = colorLoad(f);
|
colorLoad(f, &layer->color);
|
||||||
}
|
}
|
||||||
|
|
||||||
texturesValidateDefinition(definition);
|
texturesValidateDefinition(definition);
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
|
#include "tools.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "shared/types.h"
|
#include "color.h"
|
||||||
#include "shared/functions.h"
|
#include "euclid.h"
|
||||||
|
|
||||||
double toolsRandom()
|
double toolsRandom()
|
||||||
{
|
{
|
||||||
|
@ -55,40 +58,42 @@ Vector3 toolsGetNormalFromTriangle(Vector3 center, Vector3 bottom, Vector3 right
|
||||||
return v3Normalize(v3Cross(dz, dx));
|
return v3Normalize(v3Cross(dz, dx));
|
||||||
}
|
}
|
||||||
|
|
||||||
void toolsSaveDouble(FILE* f, double value)
|
void toolsSaveDouble(FILE* f, double* value)
|
||||||
{
|
{
|
||||||
fprintf(f, "%.20le;", value);
|
fprintf(f, "%.20le;", *value);
|
||||||
}
|
}
|
||||||
|
|
||||||
double toolsLoadDouble(FILE* f)
|
void toolsLoadDouble(FILE* f, double* value)
|
||||||
{
|
{
|
||||||
double value;
|
int read;
|
||||||
fscanf(f, "%le;", &value);
|
|
||||||
return value;
|
read = fscanf(f, "%le;", value);
|
||||||
|
assert(read == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void toolsSaveInt(FILE* f, int value)
|
void toolsSaveInt(FILE* f, int* value)
|
||||||
{
|
{
|
||||||
fprintf(f, "%d;", value);
|
fprintf(f, "%d;", *value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int toolsLoadInt(FILE* f)
|
void toolsLoadInt(FILE* f, int* value)
|
||||||
{
|
{
|
||||||
int value;
|
int read;
|
||||||
fscanf(f, "%d;", &value);
|
|
||||||
return value;
|
read = fscanf(f, "%d;", value);
|
||||||
|
assert(read == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void materialSave(FILE* f, SurfaceMaterial* material)
|
void materialSave(FILE* f, SurfaceMaterial* material)
|
||||||
{
|
{
|
||||||
colorSave(material->base, f);
|
colorSave(f, &material->base);
|
||||||
toolsSaveDouble(f, material->reflection);
|
toolsSaveDouble(f, &material->reflection);
|
||||||
toolsSaveDouble(f, material->shininess);
|
toolsSaveDouble(f, &material->shininess);
|
||||||
}
|
}
|
||||||
|
|
||||||
void materialLoad(FILE* f, SurfaceMaterial* material)
|
void materialLoad(FILE* f, SurfaceMaterial* material)
|
||||||
{
|
{
|
||||||
material->base = colorLoad(f);
|
colorLoad(f, &material->base);
|
||||||
material->reflection = toolsLoadDouble(f);
|
toolsLoadDouble(f, &material->reflection);
|
||||||
material->shininess = toolsLoadDouble(f);
|
toolsLoadDouble(f, &material->shininess);
|
||||||
}
|
}
|
||||||
|
|
26
lib_paysages/tools.h
Normal file
26
lib_paysages/tools.h
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef _PAYSAGES_TOOLS_H_
|
||||||
|
#define _PAYSAGES_TOOLS_H_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "shared/types.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
double toolsRandom();
|
||||||
|
double toolsBicubicInterpolate(double stencil[16], double x, double y);
|
||||||
|
void toolsFloat2DMapCopy(double* src, double* dest, int src_xstart, int src_ystart, int dest_xstart, int dest_ystart, int xsize, int ysize, int src_xstep, int src_ystep, int dest_xstep, int dest_ystep);
|
||||||
|
Vector3 toolsGetNormalFromTriangle(Vector3 center, Vector3 bottom, Vector3 right);
|
||||||
|
void toolsSaveDouble(FILE* f, double* value);
|
||||||
|
void toolsLoadDouble(FILE* f, double* value);
|
||||||
|
void toolsSaveInt(FILE* f, int* value);
|
||||||
|
void toolsLoadInt(FILE* f, int* value);
|
||||||
|
void materialSave(FILE* f, SurfaceMaterial* material);
|
||||||
|
void materialLoad(FILE* f, SurfaceMaterial* material);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,12 +1,14 @@
|
||||||
#include "water.h"
|
#include "water.h"
|
||||||
|
|
||||||
#include "shared/types.h"
|
#include "shared/types.h"
|
||||||
#include "shared/functions.h"
|
|
||||||
#include "shared/constants.h"
|
#include "shared/constants.h"
|
||||||
#include "shared/globals.h"
|
#include "shared/globals.h"
|
||||||
|
#include "color.h"
|
||||||
|
#include "euclid.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "terrain.h"
|
#include "terrain.h"
|
||||||
#include "lighting.h"
|
#include "lighting.h"
|
||||||
|
#include "tools.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
@ -16,30 +18,30 @@ void waterInit()
|
||||||
|
|
||||||
void waterSave(FILE* f, WaterDefinition* definition)
|
void waterSave(FILE* f, WaterDefinition* definition)
|
||||||
{
|
{
|
||||||
toolsSaveDouble(f, definition->height);
|
toolsSaveDouble(f, &definition->height);
|
||||||
materialSave(f, &definition->material);
|
materialSave(f, &definition->material);
|
||||||
colorSave(definition->depth_color, f);
|
colorSave(f, &definition->depth_color);
|
||||||
toolsSaveDouble(f, definition->transparency_depth);
|
toolsSaveDouble(f, &definition->transparency_depth);
|
||||||
toolsSaveDouble(f, definition->transparency);
|
toolsSaveDouble(f, &definition->transparency);
|
||||||
toolsSaveDouble(f, definition->reflection);
|
toolsSaveDouble(f, &definition->reflection);
|
||||||
toolsSaveDouble(f, definition->lighting_depth);
|
toolsSaveDouble(f, &definition->lighting_depth);
|
||||||
noiseSave(definition->waves_noise, f);
|
noiseSave(f, definition->waves_noise);
|
||||||
toolsSaveDouble(f, definition->waves_noise_height);
|
toolsSaveDouble(f, &definition->waves_noise_height);
|
||||||
toolsSaveDouble(f, definition->waves_noise_scale);
|
toolsSaveDouble(f, &definition->waves_noise_scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void waterLoad(FILE* f, WaterDefinition* definition)
|
void waterLoad(FILE* f, WaterDefinition* definition)
|
||||||
{
|
{
|
||||||
definition->height = toolsLoadDouble(f);
|
toolsLoadDouble(f, &definition->height);
|
||||||
materialLoad(f, &definition->material);
|
materialLoad(f, &definition->material);
|
||||||
definition->depth_color = colorLoad(f);
|
colorLoad(f, &definition->depth_color);
|
||||||
definition->transparency_depth = toolsLoadDouble(f);
|
toolsLoadDouble(f, &definition->transparency_depth);
|
||||||
definition->transparency = toolsLoadDouble(f);
|
toolsLoadDouble(f, &definition->transparency);
|
||||||
definition->reflection = toolsLoadDouble(f);
|
toolsLoadDouble(f, &definition->reflection);
|
||||||
definition->lighting_depth = toolsLoadDouble(f);
|
toolsLoadDouble(f, &definition->lighting_depth);
|
||||||
noiseLoad(definition->waves_noise, f);
|
noiseLoad(f, definition->waves_noise);
|
||||||
definition->waves_noise_height = toolsLoadDouble(f);
|
toolsLoadDouble(f, &definition->waves_noise_height);
|
||||||
definition->waves_noise_scale = toolsLoadDouble(f);
|
toolsLoadDouble(f, &definition->waves_noise_scale);
|
||||||
|
|
||||||
waterValidateDefinition(definition);
|
waterValidateDefinition(definition);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
|
#include "zone.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include "tools.h"
|
||||||
|
|
||||||
#define MAX_RANGES 20
|
#define MAX_RANGES 20
|
||||||
#define MAX_CIRCLES 20
|
#define MAX_CIRCLES 20
|
||||||
|
@ -36,9 +39,6 @@ struct Zone {
|
||||||
int circles_excluded_count;
|
int circles_excluded_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "shared/types.h"
|
|
||||||
#include "shared/functions.h"
|
|
||||||
|
|
||||||
Zone* zoneCreate()
|
Zone* zoneCreate()
|
||||||
{
|
{
|
||||||
Zone* result;
|
Zone* result;
|
||||||
|
@ -57,93 +57,93 @@ void zoneDelete(Zone* zone)
|
||||||
free(zone);
|
free(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
void zoneSave(Zone* zone, FILE* f)
|
void zoneSave(FILE* f, Zone* zone)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
toolsSaveInt(f, zone->height_ranges_count);
|
toolsSaveInt(f, &zone->height_ranges_count);
|
||||||
for (i = 0; i < zone->height_ranges_count; i++)
|
for (i = 0; i < zone->height_ranges_count; i++)
|
||||||
{
|
{
|
||||||
toolsSaveDouble(f, zone->height_ranges[i].value);
|
toolsSaveDouble(f, &zone->height_ranges[i].value);
|
||||||
toolsSaveDouble(f, zone->height_ranges[i].hardmin);
|
toolsSaveDouble(f, &zone->height_ranges[i].hardmin);
|
||||||
toolsSaveDouble(f, zone->height_ranges[i].softmin);
|
toolsSaveDouble(f, &zone->height_ranges[i].softmin);
|
||||||
toolsSaveDouble(f, zone->height_ranges[i].softmax);
|
toolsSaveDouble(f, &zone->height_ranges[i].softmax);
|
||||||
toolsSaveDouble(f, zone->height_ranges[i].hardmax);
|
toolsSaveDouble(f, &zone->height_ranges[i].hardmax);
|
||||||
}
|
}
|
||||||
|
|
||||||
toolsSaveInt(f, zone->steepness_ranges_count);
|
toolsSaveInt(f, &zone->steepness_ranges_count);
|
||||||
for (i = 0; i < zone->steepness_ranges_count; i++)
|
for (i = 0; i < zone->steepness_ranges_count; i++)
|
||||||
{
|
{
|
||||||
toolsSaveDouble(f, zone->steepness_ranges[i].value);
|
toolsSaveDouble(f, &zone->steepness_ranges[i].value);
|
||||||
toolsSaveDouble(f, zone->steepness_ranges[i].hardmin);
|
toolsSaveDouble(f, &zone->steepness_ranges[i].hardmin);
|
||||||
toolsSaveDouble(f, zone->steepness_ranges[i].softmin);
|
toolsSaveDouble(f, &zone->steepness_ranges[i].softmin);
|
||||||
toolsSaveDouble(f, zone->steepness_ranges[i].softmax);
|
toolsSaveDouble(f, &zone->steepness_ranges[i].softmax);
|
||||||
toolsSaveDouble(f, zone->steepness_ranges[i].hardmax);
|
toolsSaveDouble(f, &zone->steepness_ranges[i].hardmax);
|
||||||
}
|
}
|
||||||
|
|
||||||
toolsSaveInt(f, zone->circles_included_count);
|
toolsSaveInt(f, &zone->circles_included_count);
|
||||||
for (i = 0; i < zone->circles_included_count; i++)
|
for (i = 0; i < zone->circles_included_count; i++)
|
||||||
{
|
{
|
||||||
toolsSaveDouble(f, zone->circles_included[i].value);
|
toolsSaveDouble(f, &zone->circles_included[i].value);
|
||||||
toolsSaveDouble(f, zone->circles_included[i].centerx);
|
toolsSaveDouble(f, &zone->circles_included[i].centerx);
|
||||||
toolsSaveDouble(f, zone->circles_included[i].centerz);
|
toolsSaveDouble(f, &zone->circles_included[i].centerz);
|
||||||
toolsSaveDouble(f, zone->circles_included[i].softradius);
|
toolsSaveDouble(f, &zone->circles_included[i].softradius);
|
||||||
toolsSaveDouble(f, zone->circles_included[i].hardradius);
|
toolsSaveDouble(f, &zone->circles_included[i].hardradius);
|
||||||
}
|
}
|
||||||
|
|
||||||
toolsSaveInt(f, zone->circles_excluded_count);
|
toolsSaveInt(f, &zone->circles_excluded_count);
|
||||||
for (i = 0; i < zone->circles_excluded_count; i++)
|
for (i = 0; i < zone->circles_excluded_count; i++)
|
||||||
{
|
{
|
||||||
toolsSaveDouble(f, zone->circles_excluded[i].value);
|
toolsSaveDouble(f, &zone->circles_excluded[i].value);
|
||||||
toolsSaveDouble(f, zone->circles_excluded[i].centerx);
|
toolsSaveDouble(f, &zone->circles_excluded[i].centerx);
|
||||||
toolsSaveDouble(f, zone->circles_excluded[i].centerz);
|
toolsSaveDouble(f, &zone->circles_excluded[i].centerz);
|
||||||
toolsSaveDouble(f, zone->circles_excluded[i].softradius);
|
toolsSaveDouble(f, &zone->circles_excluded[i].softradius);
|
||||||
toolsSaveDouble(f, zone->circles_excluded[i].hardradius);
|
toolsSaveDouble(f, &zone->circles_excluded[i].hardradius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void zoneLoad(Zone* zone, FILE* f)
|
void zoneLoad(FILE* f, Zone* zone)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
zone->height_ranges_count = toolsLoadInt(f);
|
toolsLoadInt(f, &zone->height_ranges_count);
|
||||||
for (i = 0; i < zone->height_ranges_count; i++)
|
for (i = 0; i < zone->height_ranges_count; i++)
|
||||||
{
|
{
|
||||||
zone->height_ranges[i].value = toolsLoadDouble(f);
|
toolsLoadDouble(f, &zone->height_ranges[i].value);
|
||||||
zone->height_ranges[i].hardmin = toolsLoadDouble(f);
|
toolsLoadDouble(f, &zone->height_ranges[i].hardmin);
|
||||||
zone->height_ranges[i].softmin = toolsLoadDouble(f);
|
toolsLoadDouble(f, &zone->height_ranges[i].softmin);
|
||||||
zone->height_ranges[i].softmax = toolsLoadDouble(f);
|
toolsLoadDouble(f, &zone->height_ranges[i].softmax);
|
||||||
zone->height_ranges[i].hardmax = toolsLoadDouble(f);
|
toolsLoadDouble(f, &zone->height_ranges[i].hardmax);
|
||||||
}
|
}
|
||||||
|
|
||||||
zone->steepness_ranges_count = toolsLoadInt(f);
|
toolsLoadInt(f, &zone->steepness_ranges_count);
|
||||||
for (i = 0; i < zone->steepness_ranges_count; i++)
|
for (i = 0; i < zone->steepness_ranges_count; i++)
|
||||||
{
|
{
|
||||||
zone->steepness_ranges[i].value = toolsLoadDouble(f);
|
toolsLoadDouble(f, &zone->steepness_ranges[i].value);
|
||||||
zone->steepness_ranges[i].hardmin = toolsLoadDouble(f);
|
toolsLoadDouble(f, &zone->steepness_ranges[i].hardmin);
|
||||||
zone->steepness_ranges[i].softmin = toolsLoadDouble(f);
|
toolsLoadDouble(f, &zone->steepness_ranges[i].softmin);
|
||||||
zone->steepness_ranges[i].softmax = toolsLoadDouble(f);
|
toolsLoadDouble(f, &zone->steepness_ranges[i].softmax);
|
||||||
zone->steepness_ranges[i].hardmax = toolsLoadDouble(f);
|
toolsLoadDouble(f, &zone->steepness_ranges[i].hardmax);
|
||||||
}
|
}
|
||||||
|
|
||||||
zone->circles_included_count = toolsLoadInt(f);
|
toolsLoadInt(f, &zone->circles_included_count);
|
||||||
for (i = 0; i < zone->circles_included_count; i++)
|
for (i = 0; i < zone->circles_included_count; i++)
|
||||||
{
|
{
|
||||||
zone->circles_included[i].value = toolsLoadDouble(f);
|
toolsLoadDouble(f, &zone->circles_included[i].value);
|
||||||
zone->circles_included[i].centerx = toolsLoadDouble(f);
|
toolsLoadDouble(f, &zone->circles_included[i].centerx);
|
||||||
zone->circles_included[i].centerz = toolsLoadDouble(f);
|
toolsLoadDouble(f, &zone->circles_included[i].centerz);
|
||||||
zone->circles_included[i].softradius = toolsLoadDouble(f);
|
toolsLoadDouble(f, &zone->circles_included[i].softradius);
|
||||||
zone->circles_included[i].hardradius = toolsLoadDouble(f);
|
toolsLoadDouble(f, &zone->circles_included[i].hardradius);
|
||||||
}
|
}
|
||||||
|
|
||||||
zone->circles_excluded_count = toolsLoadInt(f);
|
toolsLoadInt(f, &zone->circles_excluded_count);
|
||||||
for (i = 0; i < zone->circles_excluded_count; i++)
|
for (i = 0; i < zone->circles_excluded_count; i++)
|
||||||
{
|
{
|
||||||
zone->circles_excluded[i].value = toolsLoadDouble(f);
|
toolsLoadDouble(f, &zone->circles_excluded[i].value);
|
||||||
zone->circles_excluded[i].centerx = toolsLoadDouble(f);
|
toolsLoadDouble(f, &zone->circles_excluded[i].centerx);
|
||||||
zone->circles_excluded[i].centerz = toolsLoadDouble(f);
|
toolsLoadDouble(f, &zone->circles_excluded[i].centerz);
|
||||||
zone->circles_excluded[i].softradius = toolsLoadDouble(f);
|
toolsLoadDouble(f, &zone->circles_excluded[i].softradius);
|
||||||
zone->circles_excluded[i].hardradius = toolsLoadDouble(f);
|
toolsLoadDouble(f, &zone->circles_excluded[i].hardradius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
25
lib_paysages/zone.h
Normal file
25
lib_paysages/zone.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#ifndef _PAYSAGES_ZONE_H_
|
||||||
|
#define _PAYSAGES_ZONE_H_
|
||||||
|
|
||||||
|
#include "shared/types.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Zone* zoneCreate();
|
||||||
|
void zoneDelete(Zone* zone);
|
||||||
|
void zoneSave(FILE* f, Zone* zone);
|
||||||
|
void zoneLoad(FILE* f, Zone* zone);
|
||||||
|
void zoneCopy(Zone* source, Zone* destination);
|
||||||
|
void zoneIncludeCircleArea(Zone* zone, double value, double centerx, double centerz, double softradius, double hardradius);
|
||||||
|
void zoneExcludeCircleArea(Zone* zone, double centerx, double centerz, double softradius, double hardradius);
|
||||||
|
void zoneAddHeightRange(Zone* zone, double value, double hardmin, double softmin, double softmax, double hardmax);
|
||||||
|
void zoneAddSteepnessRange(Zone* zone, double value, double hardmin, double softmin, double softmax, double hardmax);
|
||||||
|
double zoneGetValue(Zone* zone, Vector3 location, Vector3 normal);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in a new issue