paysages: Added PackStream to load/save.
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@303 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
3c7c682e07
commit
e56489062a
41 changed files with 556 additions and 480 deletions
9
Makefile
9
Makefile
|
@ -23,4 +23,13 @@ run_cli:
|
||||||
run_qt:
|
run_qt:
|
||||||
LD_LIBRARY_PATH=${BUILDPATH} ${BUILDPATH}/paysages-qt
|
LD_LIBRARY_PATH=${BUILDPATH} ${BUILDPATH}/paysages-qt
|
||||||
|
|
||||||
|
profile:
|
||||||
|
sudo opcontrol --setup --no-vmlinux --event=CPU_CLK_UNHALTED:3000000:0:1:1 --buffer-size=65536 --callgraph=5 --separate=none
|
||||||
|
sudo opcontrol --reset
|
||||||
|
sudo opcontrol --start
|
||||||
|
LD_LIBRARY_PATH=${BUILDPATH} ${BUILDPATH}/paysages-qt || true
|
||||||
|
sudo opcontrol --shutdown
|
||||||
|
opannotate --source --output-dir=annotated ${BUILDPATH}/libpaysages.so --base-dirs=. --search-dirs=lib_paysages
|
||||||
|
opreport -l ${BUILDPATH}/libpaysages.so -c -g | less
|
||||||
|
|
||||||
.PHONY:all clean release
|
.PHONY:all clean release
|
||||||
|
|
7
TODO
7
TODO
|
@ -1,14 +1,13 @@
|
||||||
Technology Preview 1 :
|
|
||||||
- Find a licence and apply it.
|
|
||||||
|
|
||||||
Technology Preview 2 :
|
Technology Preview 2 :
|
||||||
|
- Render tab previews should not rerender when changing render options.
|
||||||
|
- Compute shadows only once for all textures at a same location.
|
||||||
|
- Add antialiasing option (pay attention to memory usage).
|
||||||
- Add an OSD ability on previews and use it for camera location and user landmarks.
|
- Add an OSD ability on previews and use it for camera location and user landmarks.
|
||||||
- Add a material editor dialog.
|
- Add a material editor dialog.
|
||||||
- Add a zone editor dialog for localized textures.
|
- Add a zone editor dialog for localized textures.
|
||||||
- Add a terrain modifier dialog with zones.
|
- Add a terrain modifier dialog with zones.
|
||||||
- Add a noise filler (and maybe noise intervals ?).
|
- Add a noise filler (and maybe noise intervals ?).
|
||||||
- Improve curve editor.
|
- Improve curve editor.
|
||||||
- Replace FILE* by a custom type for Save and Load.
|
|
||||||
- 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.
|
||||||
- Implement a file header/versioning.
|
- Implement a file header/versioning.
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ DialogWanderer::DialogWanderer(QWidget* parent, CameraDefinition* camera, bool c
|
||||||
panel->setLayout(new QVBoxLayout());
|
panel->setLayout(new QVBoxLayout());
|
||||||
panel->setMaximumWidth(230);
|
panel->setMaximumWidth(230);
|
||||||
|
|
||||||
panel->layout()->addWidget(new QLabel(tr("COMMANDS\n\nLeft click : Look around\nRight click : Pan (adjust framing)\nWheel : Move forward/backward\nHold SHIFT : Slower\nHold CTRL : Faster"), panel));
|
panel->layout()->addWidget(new QLabel(tr("COMMANDS\n\nLeft click : Look around\nRight click : Pan (adjust framing)\nWheel : Move forward/backward\nHold SHIFT : Faster\nHold CTRL : Slower"), panel));
|
||||||
|
|
||||||
button = new QPushButton(tr("Reset camera"), panel);
|
button = new QPushButton(tr("Reset camera"), panel);
|
||||||
panel->layout()->addWidget(button);
|
panel->layout()->addWidget(button);
|
||||||
|
|
|
@ -8,9 +8,6 @@ MOC_DIR = ./moc/$$BUILDMODE/
|
||||||
DESTDIR = ../build/$$BUILDMODE/
|
DESTDIR = ../build/$$BUILDMODE/
|
||||||
CONFIG += $$BUILDMODE
|
CONFIG += $$BUILDMODE
|
||||||
|
|
||||||
QMAKE_CXXFLAGS_DEBUG += -pg
|
|
||||||
QMAKE_LFLAGS_DEBUG += -pg
|
|
||||||
|
|
||||||
unix:LIBS += -L$$DESTDIR -lpaysages
|
unix:LIBS += -L$$DESTDIR -lpaysages
|
||||||
win32:LIBS += ../libpaysages.a -lDevIL -lILU -lILUT -lglib-2.0 -lgthread-2.0
|
win32:LIBS += ../libpaysages.a -lDevIL -lILU -lILUT -lglib-2.0 -lgthread-2.0
|
||||||
|
|
||||||
|
|
|
@ -42,11 +42,11 @@ void WidgetWanderer::keyPressEvent(QKeyEvent* event)
|
||||||
{
|
{
|
||||||
double factor;
|
double factor;
|
||||||
|
|
||||||
if (event->modifiers() & Qt::ShiftModifier)
|
if (event->modifiers() & Qt::ControlModifier)
|
||||||
{
|
{
|
||||||
factor = 0.1;
|
factor = 0.1;
|
||||||
}
|
}
|
||||||
else if (event->modifiers() & Qt::ControlModifier)
|
else if (event->modifiers() & Qt::ShiftModifier)
|
||||||
{
|
{
|
||||||
factor = 10.0;
|
factor = 10.0;
|
||||||
}
|
}
|
||||||
|
@ -104,11 +104,11 @@ void WidgetWanderer::mouseMoveEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
double factor;
|
double factor;
|
||||||
|
|
||||||
if (event->modifiers() & Qt::ShiftModifier)
|
if (event->modifiers() & Qt::ControlModifier)
|
||||||
{
|
{
|
||||||
factor = 0.01;
|
factor = 0.01;
|
||||||
}
|
}
|
||||||
else if (event->modifiers() & Qt::ControlModifier)
|
else if (event->modifiers() & Qt::ShiftModifier)
|
||||||
{
|
{
|
||||||
factor = 1.0;
|
factor = 1.0;
|
||||||
}
|
}
|
||||||
|
@ -145,11 +145,11 @@ void WidgetWanderer::wheelEvent(QWheelEvent* event)
|
||||||
{
|
{
|
||||||
double factor;
|
double factor;
|
||||||
|
|
||||||
if (event->modifiers() & Qt::ShiftModifier)
|
if (event->modifiers() & Qt::ControlModifier)
|
||||||
{
|
{
|
||||||
factor = 0.01;
|
factor = 0.01;
|
||||||
}
|
}
|
||||||
else if (event->modifiers() & Qt::ControlModifier)
|
else if (event->modifiers() & Qt::ShiftModifier)
|
||||||
{
|
{
|
||||||
factor = 1.0;
|
factor = 1.0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,6 +169,7 @@ Cliquez avec le bouton droit sur un point pour le supprimer.</translation>
|
||||||
<translation>Paysages 3D - Exploration</translation>
|
<translation>Paysages 3D - Exploration</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
|
<location filename="../gui_qt/dialogwanderer.cpp" line="25"/>
|
||||||
<source>COMMANDS
|
<source>COMMANDS
|
||||||
|
|
||||||
Left click : Look around
|
Left click : Look around
|
||||||
|
@ -176,16 +177,15 @@ Right click : Pan (adjust framing)
|
||||||
Wheel : Move forward/backward
|
Wheel : Move forward/backward
|
||||||
Hold SHIFT : Faster
|
Hold SHIFT : Faster
|
||||||
Hold CTRL : Slower</source>
|
Hold CTRL : Slower</source>
|
||||||
<translation type="obsolete">COMMANDES
|
<translation>COMMANDES
|
||||||
|
|
||||||
Clic gauche : Regarder autour
|
Clic gauche : Regarder autour
|
||||||
Clic droit : Déplacer le cadrage
|
Clic droit : Déplacer le cadrage
|
||||||
Molette : Avancer/reculer
|
Molette : Avancer/reculer
|
||||||
Maintenir MAJ : Plus rapide
|
Maintenir Maj : Plus rapide
|
||||||
Maintenir Ctrl : Plus lent</translation>
|
Maintenir Ctrl : Plus lent</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui_qt/dialogwanderer.cpp" line="25"/>
|
|
||||||
<source>COMMANDS
|
<source>COMMANDS
|
||||||
|
|
||||||
Left click : Look around
|
Left click : Look around
|
||||||
|
@ -193,7 +193,7 @@ Right click : Pan (adjust framing)
|
||||||
Wheel : Move forward/backward
|
Wheel : Move forward/backward
|
||||||
Hold SHIFT : Slower
|
Hold SHIFT : Slower
|
||||||
Hold CTRL : Faster</source>
|
Hold CTRL : Faster</source>
|
||||||
<translation>COMMANDES
|
<translation type="obsolete">COMMANDES
|
||||||
|
|
||||||
Clic gauche : Regarder autour
|
Clic gauche : Regarder autour
|
||||||
Clic droit : Déplacer le cadrage
|
Clic droit : Déplacer le cadrage
|
||||||
|
|
|
@ -14,22 +14,22 @@ void atmosphereQuit()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void atmosphereSave(FILE* f, AtmosphereDefinition* definition)
|
void atmosphereSave(PackStream* stream, AtmosphereDefinition* definition)
|
||||||
{
|
{
|
||||||
toolsSaveDouble(f, &definition->distance_near);
|
packWriteDouble(stream, &definition->distance_near);
|
||||||
toolsSaveDouble(f, &definition->distance_far);
|
packWriteDouble(stream, &definition->distance_far);
|
||||||
toolsSaveDouble(f, &definition->full_mask);
|
packWriteDouble(stream, &definition->full_mask);
|
||||||
toolsSaveInt(f, &definition->auto_lock_on_haze);
|
packWriteInt(stream, &definition->auto_lock_on_haze);
|
||||||
colorSave(f, &definition->color);
|
colorSave(stream, &definition->color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void atmosphereLoad(FILE* f, AtmosphereDefinition* definition)
|
void atmosphereLoad(PackStream* stream, AtmosphereDefinition* definition)
|
||||||
{
|
{
|
||||||
toolsLoadDouble(f, &definition->distance_near);
|
packReadDouble(stream, &definition->distance_near);
|
||||||
toolsLoadDouble(f, &definition->distance_far);
|
packReadDouble(stream, &definition->distance_far);
|
||||||
toolsLoadDouble(f, &definition->full_mask);
|
packReadDouble(stream, &definition->full_mask);
|
||||||
toolsLoadInt(f, &definition->auto_lock_on_haze);
|
packReadInt(stream, &definition->auto_lock_on_haze);
|
||||||
colorLoad(f, &definition->color);
|
colorLoad(stream, &definition->color);
|
||||||
|
|
||||||
atmosphereValidateDefinition(definition);
|
atmosphereValidateDefinition(definition);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define _PAYSAGES_ATMOSPHERE_H_
|
#define _PAYSAGES_ATMOSPHERE_H_
|
||||||
|
|
||||||
#include "shared/types.h"
|
#include "shared/types.h"
|
||||||
|
#include "pack.h"
|
||||||
#include "lighting.h"
|
#include "lighting.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
@ -20,8 +21,8 @@ typedef struct
|
||||||
|
|
||||||
void atmosphereInit();
|
void atmosphereInit();
|
||||||
void atmosphereQuit();
|
void atmosphereQuit();
|
||||||
void atmosphereSave(FILE* f, AtmosphereDefinition* definition);
|
void atmosphereSave(PackStream* stream, AtmosphereDefinition* definition);
|
||||||
void atmosphereLoad(FILE* f, AtmosphereDefinition* definition);
|
void atmosphereLoad(PackStream* stream, AtmosphereDefinition* definition);
|
||||||
|
|
||||||
AtmosphereDefinition atmosphereCreateDefinition();
|
AtmosphereDefinition atmosphereCreateDefinition();
|
||||||
void atmosphereDeleteDefinition(AtmosphereDefinition* definition);
|
void atmosphereDeleteDefinition(AtmosphereDefinition* definition);
|
||||||
|
|
|
@ -17,20 +17,20 @@ void cameraQuit()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void cameraSave(FILE* f, CameraDefinition* camera)
|
void cameraSave(PackStream* stream, CameraDefinition* camera)
|
||||||
{
|
{
|
||||||
v3Save(f, &camera->location);
|
v3Save(stream, &camera->location);
|
||||||
toolsSaveDouble(f, &camera->yaw);
|
packWriteDouble(stream, &camera->yaw);
|
||||||
toolsSaveDouble(f, &camera->pitch);
|
packWriteDouble(stream, &camera->pitch);
|
||||||
toolsSaveDouble(f, &camera->roll);
|
packWriteDouble(stream, &camera->roll);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cameraLoad(FILE* f, CameraDefinition* camera)
|
void cameraLoad(PackStream* stream, CameraDefinition* camera)
|
||||||
{
|
{
|
||||||
v3Load(f, &camera->location);
|
v3Load(stream, &camera->location);
|
||||||
toolsLoadDouble(f, &camera->yaw);
|
packReadDouble(stream, &camera->yaw);
|
||||||
toolsLoadDouble(f, &camera->pitch);
|
packReadDouble(stream, &camera->pitch);
|
||||||
toolsLoadDouble(f, &camera->roll);
|
packReadDouble(stream, &camera->roll);
|
||||||
|
|
||||||
cameraValidateDefinition(camera, 0);
|
cameraValidateDefinition(camera, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef _PAYSAGES_CAMERA_H_
|
#ifndef _PAYSAGES_CAMERA_H_
|
||||||
#define _PAYSAGES_CAMERA_H_
|
#define _PAYSAGES_CAMERA_H_
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "shared/types.h"
|
#include "shared/types.h"
|
||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
|
#include "pack.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -11,8 +11,8 @@ extern "C" {
|
||||||
|
|
||||||
void cameraInit();
|
void cameraInit();
|
||||||
void cameraQuit();
|
void cameraQuit();
|
||||||
void cameraSave(FILE* f, CameraDefinition* camera);
|
void cameraSave(PackStream* stream, CameraDefinition* camera);
|
||||||
void cameraLoad(FILE* f, CameraDefinition* camera);
|
void cameraLoad(PackStream* stream, CameraDefinition* camera);
|
||||||
|
|
||||||
CameraDefinition cameraCreateDefinition();
|
CameraDefinition cameraCreateDefinition();
|
||||||
void cameraDeleteDefinition(CameraDefinition* definition);
|
void cameraDeleteDefinition(CameraDefinition* definition);
|
||||||
|
|
|
@ -32,30 +32,30 @@ void cloudsQuit()
|
||||||
cloudsLayerDeleteDefinition(&NULL_LAYER);
|
cloudsLayerDeleteDefinition(&NULL_LAYER);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cloudsSave(FILE* f, CloudsDefinition* definition)
|
void cloudsSave(PackStream* stream, CloudsDefinition* definition)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
CloudsLayerDefinition* layer;
|
CloudsLayerDefinition* layer;
|
||||||
|
|
||||||
toolsSaveInt(f, &definition->nblayers);
|
packWriteInt(stream, &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);
|
packWriteDouble(stream, &layer->ycenter);
|
||||||
toolsSaveDouble(f, &layer->ymin);
|
packWriteDouble(stream, &layer->ymin);
|
||||||
toolsSaveDouble(f, &layer->ymax);
|
packWriteDouble(stream, &layer->ymax);
|
||||||
noiseSaveGenerator(f, layer->noise);
|
noiseSaveGenerator(stream, layer->noise);
|
||||||
materialSave(f, &layer->material);
|
materialSave(stream, &layer->material);
|
||||||
toolsSaveDouble(f, &layer->transparencydepth);
|
packWriteDouble(stream, &layer->transparencydepth);
|
||||||
toolsSaveDouble(f, &layer->lighttraversal);
|
packWriteDouble(stream, &layer->lighttraversal);
|
||||||
toolsSaveDouble(f, &layer->minimumlight);
|
packWriteDouble(stream, &layer->minimumlight);
|
||||||
toolsSaveDouble(f, &layer->scaling);
|
packWriteDouble(stream, &layer->scaling);
|
||||||
toolsSaveDouble(f, &layer->coverage);
|
packWriteDouble(stream, &layer->coverage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cloudsLoad(FILE* f, CloudsDefinition* definition)
|
void cloudsLoad(PackStream* stream, CloudsDefinition* definition)
|
||||||
{
|
{
|
||||||
int i, n;
|
int i, n;
|
||||||
CloudsLayerDefinition* layer;
|
CloudsLayerDefinition* layer;
|
||||||
|
@ -65,21 +65,21 @@ void cloudsLoad(FILE* f, CloudsDefinition* definition)
|
||||||
cloudsDeleteLayer(definition, 0);
|
cloudsDeleteLayer(definition, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
toolsLoadInt(f, &n);
|
packReadInt(stream, &n);
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
layer = definition->layers + cloudsAddLayer(definition);
|
layer = definition->layers + cloudsAddLayer(definition);
|
||||||
|
|
||||||
toolsLoadDouble(f, &layer->ycenter);
|
packReadDouble(stream, &layer->ycenter);
|
||||||
toolsLoadDouble(f, &layer->ymin);
|
packReadDouble(stream, &layer->ymin);
|
||||||
toolsLoadDouble(f, &layer->ymax);
|
packReadDouble(stream, &layer->ymax);
|
||||||
noiseLoadGenerator(f, layer->noise);
|
noiseLoadGenerator(stream, layer->noise);
|
||||||
materialLoad(f, &layer->material);
|
materialLoad(stream, &layer->material);
|
||||||
toolsLoadDouble(f, &layer->transparencydepth);
|
packReadDouble(stream, &layer->transparencydepth);
|
||||||
toolsLoadDouble(f, &layer->lighttraversal);
|
packReadDouble(stream, &layer->lighttraversal);
|
||||||
toolsLoadDouble(f, &layer->minimumlight);
|
packReadDouble(stream, &layer->minimumlight);
|
||||||
toolsLoadDouble(f, &layer->scaling);
|
packReadDouble(stream, &layer->scaling);
|
||||||
toolsLoadDouble(f, &layer->coverage);
|
packReadDouble(stream, &layer->coverage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,8 @@ typedef struct
|
||||||
|
|
||||||
void cloudsInit();
|
void cloudsInit();
|
||||||
void cloudsQuit();
|
void cloudsQuit();
|
||||||
void cloudsSave(FILE* f, CloudsDefinition* definition);
|
void cloudsSave(PackStream* stream, CloudsDefinition* definition);
|
||||||
void cloudsLoad(FILE* f, CloudsDefinition* definition);
|
void cloudsLoad(PackStream* stream, CloudsDefinition* definition);
|
||||||
|
|
||||||
CloudsDefinition cloudsCreateDefinition();
|
CloudsDefinition cloudsCreateDefinition();
|
||||||
void cloudsDeleteDefinition(CloudsDefinition* definition);
|
void cloudsDeleteDefinition(CloudsDefinition* definition);
|
||||||
|
|
|
@ -22,20 +22,20 @@ struct ColorGradation
|
||||||
Curve* blue;
|
Curve* blue;
|
||||||
};
|
};
|
||||||
|
|
||||||
void colorSave(FILE* f, Color* col)
|
void colorSave(PackStream* stream, Color* col)
|
||||||
{
|
{
|
||||||
toolsSaveDouble(f, &col->r);
|
packWriteDouble(stream, &col->r);
|
||||||
toolsSaveDouble(f, &col->g);
|
packWriteDouble(stream, &col->g);
|
||||||
toolsSaveDouble(f, &col->b);
|
packWriteDouble(stream, &col->b);
|
||||||
toolsSaveDouble(f, &col->a);
|
packWriteDouble(stream, &col->a);
|
||||||
}
|
}
|
||||||
|
|
||||||
void colorLoad(FILE* f, Color* col)
|
void colorLoad(PackStream* stream, Color* col)
|
||||||
{
|
{
|
||||||
toolsLoadDouble(f, &col->r);
|
packReadDouble(stream, &col->r);
|
||||||
toolsLoadDouble(f, &col->g);
|
packReadDouble(stream, &col->g);
|
||||||
toolsLoadDouble(f, &col->b);
|
packReadDouble(stream, &col->b);
|
||||||
toolsLoadDouble(f, &col->a);
|
packReadDouble(stream, &col->a);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int colorTo32BitRGBA(Color* col)
|
unsigned int colorTo32BitRGBA(Color* col)
|
||||||
|
@ -137,18 +137,18 @@ void colorGradationCopy(ColorGradation* source, ColorGradation* destination)
|
||||||
curveCopy(source->blue, destination->blue);
|
curveCopy(source->blue, destination->blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void colorGradationSave(FILE* f, ColorGradation* gradation)
|
void colorGradationSave(PackStream* stream, ColorGradation* gradation)
|
||||||
{
|
{
|
||||||
curveSave(f, gradation->red);
|
curveSave(stream, gradation->red);
|
||||||
curveSave(f, gradation->green);
|
curveSave(stream, gradation->green);
|
||||||
curveSave(f, gradation->blue);
|
curveSave(stream, gradation->blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void colorGradationLoad(FILE* f, ColorGradation* gradation)
|
void colorGradationLoad(PackStream* stream, ColorGradation* gradation)
|
||||||
{
|
{
|
||||||
curveLoad(f, gradation->red);
|
curveLoad(stream, gradation->red);
|
||||||
curveLoad(f, gradation->green);
|
curveLoad(stream, gradation->green);
|
||||||
curveLoad(f, gradation->blue);
|
curveLoad(stream, gradation->blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void colorGradationGetRedCurve(ColorGradation* gradation, Curve* curve)
|
void colorGradationGetRedCurve(ColorGradation* gradation, Curve* curve)
|
||||||
|
|
|
@ -10,8 +10,8 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Color */
|
/* Color */
|
||||||
void colorSave(FILE* f, Color* col);
|
void colorSave(PackStream* stream, Color* col);
|
||||||
void colorLoad(FILE* f, Color* col);
|
void colorLoad(PackStream* stream, Color* col);
|
||||||
|
|
||||||
unsigned int colorTo32BitRGBA(Color* col);
|
unsigned int colorTo32BitRGBA(Color* col);
|
||||||
unsigned int colorTo32BitBGRA(Color* col);
|
unsigned int colorTo32BitBGRA(Color* col);
|
||||||
|
@ -29,8 +29,8 @@ ColorGradation* colorGradationCreate();
|
||||||
void colorGradationDelete(ColorGradation* gradation);
|
void colorGradationDelete(ColorGradation* gradation);
|
||||||
void colorGradationCopy(ColorGradation* source, ColorGradation* destination);
|
void colorGradationCopy(ColorGradation* source, ColorGradation* destination);
|
||||||
|
|
||||||
void colorGradationSave(FILE* f, ColorGradation* gradation);
|
void colorGradationSave(PackStream* stream, ColorGradation* gradation);
|
||||||
void colorGradationLoad(FILE* f, ColorGradation* gradation);
|
void colorGradationLoad(PackStream* stream, ColorGradation* gradation);
|
||||||
|
|
||||||
void colorGradationGetRedCurve(ColorGradation* gradation, Curve* curve);
|
void colorGradationGetRedCurve(ColorGradation* gradation, Curve* curve);
|
||||||
void colorGradationGetGreenCurve(ColorGradation* gradation, Curve* curve);
|
void colorGradationGetGreenCurve(ColorGradation* gradation, Curve* curve);
|
||||||
|
|
|
@ -32,27 +32,27 @@ void curveCopy(Curve* source, Curve* destination)
|
||||||
*destination = *source;
|
*destination = *source;
|
||||||
}
|
}
|
||||||
|
|
||||||
void curveSave(FILE* f, Curve* curve)
|
void curveSave(PackStream* stream, Curve* curve)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
toolsSaveInt(f, &curve->nbpoints);
|
packWriteInt(stream, &curve->nbpoints);
|
||||||
for (i = 0; i < curve->nbpoints; i++)
|
for (i = 0; i < curve->nbpoints; i++)
|
||||||
{
|
{
|
||||||
toolsSaveDouble(f, &curve->points[i].position);
|
packWriteDouble(stream, &curve->points[i].position);
|
||||||
toolsSaveDouble(f, &curve->points[i].value);
|
packWriteDouble(stream, &curve->points[i].value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void curveLoad(FILE* f, Curve* curve)
|
void curveLoad(PackStream* stream, Curve* curve)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
toolsLoadInt(f, &curve->nbpoints);
|
packReadInt(stream, &curve->nbpoints);
|
||||||
for (i = 0; i < curve->nbpoints; i++)
|
for (i = 0; i < curve->nbpoints; i++)
|
||||||
{
|
{
|
||||||
toolsLoadDouble(f, &curve->points[i].position);
|
packReadDouble(stream, &curve->points[i].position);
|
||||||
toolsLoadDouble(f, &curve->points[i].value);
|
packReadDouble(stream, &curve->points[i].value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef _PAYSAGES_CURVE_H_
|
#ifndef _PAYSAGES_CURVE_H_
|
||||||
#define _PAYSAGES_CURVE_H_
|
#define _PAYSAGES_CURVE_H_
|
||||||
|
|
||||||
#include <stdio.h>
|
#include "pack.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -17,8 +17,8 @@ Curve* curveCreate();
|
||||||
void curveDelete(Curve* curve);
|
void curveDelete(Curve* curve);
|
||||||
void curveCopy(Curve* source, Curve* destination);
|
void curveCopy(Curve* source, Curve* destination);
|
||||||
|
|
||||||
void curveSave(FILE* f, Curve* curve);
|
void curveSave(PackStream* stream, Curve* curve);
|
||||||
void curveLoad(FILE* f, Curve* curve);
|
void curveLoad(PackStream* stream, Curve* curve);
|
||||||
|
|
||||||
void curveClear(Curve* curve);
|
void curveClear(Curve* curve);
|
||||||
int curveAddPoint(Curve* curve, CurvePoint* point);
|
int curveAddPoint(Curve* curve, CurvePoint* point);
|
||||||
|
|
|
@ -6,18 +6,18 @@
|
||||||
|
|
||||||
Vector3 VECTOR_ZERO = {0.0, 0.0, 0.0};
|
Vector3 VECTOR_ZERO = {0.0, 0.0, 0.0};
|
||||||
|
|
||||||
void v3Save(FILE* f, Vector3* v)
|
void v3Save(PackStream* stream, Vector3* v)
|
||||||
{
|
{
|
||||||
toolsSaveDouble(f, &v->x);
|
packWriteDouble(stream, &v->x);
|
||||||
toolsSaveDouble(f, &v->y);
|
packWriteDouble(stream, &v->y);
|
||||||
toolsSaveDouble(f, &v->z);
|
packWriteDouble(stream, &v->z);
|
||||||
}
|
}
|
||||||
|
|
||||||
void v3Load(FILE* f, Vector3* v)
|
void v3Load(PackStream* stream, Vector3* v)
|
||||||
{
|
{
|
||||||
toolsLoadDouble(f, &v->x);
|
packReadDouble(stream, &v->x);
|
||||||
toolsLoadDouble(f, &v->y);
|
packReadDouble(stream, &v->y);
|
||||||
toolsLoadDouble(f, &v->z);
|
packReadDouble(stream, &v->z);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 v3Translate(Vector3 v1, double x, double y, double z)
|
Vector3 v3Translate(Vector3 v1, double x, double y, double z)
|
||||||
|
@ -97,44 +97,44 @@ Vector3 v3Cross(Vector3 v1, Vector3 v2)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void m4Save(FILE* f, Matrix4* m)
|
void m4Save(PackStream* stream, Matrix4* m)
|
||||||
{
|
{
|
||||||
toolsSaveDouble(f, &m->a);
|
packWriteDouble(stream, &m->a);
|
||||||
toolsSaveDouble(f, &m->b);
|
packWriteDouble(stream, &m->b);
|
||||||
toolsSaveDouble(f, &m->c);
|
packWriteDouble(stream, &m->c);
|
||||||
toolsSaveDouble(f, &m->d);
|
packWriteDouble(stream, &m->d);
|
||||||
toolsSaveDouble(f, &m->e);
|
packWriteDouble(stream, &m->e);
|
||||||
toolsSaveDouble(f, &m->f);
|
packWriteDouble(stream, &m->f);
|
||||||
toolsSaveDouble(f, &m->g);
|
packWriteDouble(stream, &m->g);
|
||||||
toolsSaveDouble(f, &m->h);
|
packWriteDouble(stream, &m->h);
|
||||||
toolsSaveDouble(f, &m->i);
|
packWriteDouble(stream, &m->i);
|
||||||
toolsSaveDouble(f, &m->j);
|
packWriteDouble(stream, &m->j);
|
||||||
toolsSaveDouble(f, &m->k);
|
packWriteDouble(stream, &m->k);
|
||||||
toolsSaveDouble(f, &m->l);
|
packWriteDouble(stream, &m->l);
|
||||||
toolsSaveDouble(f, &m->m);
|
packWriteDouble(stream, &m->m);
|
||||||
toolsSaveDouble(f, &m->n);
|
packWriteDouble(stream, &m->n);
|
||||||
toolsSaveDouble(f, &m->o);
|
packWriteDouble(stream, &m->o);
|
||||||
toolsSaveDouble(f, &m->p);
|
packWriteDouble(stream, &m->p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void m4Load(FILE* f, Matrix4* m)
|
void m4Load(PackStream* stream, Matrix4* m)
|
||||||
{
|
{
|
||||||
toolsLoadDouble(f, &m->a);
|
packReadDouble(stream, &m->a);
|
||||||
toolsLoadDouble(f, &m->b);
|
packReadDouble(stream, &m->b);
|
||||||
toolsLoadDouble(f, &m->c);
|
packReadDouble(stream, &m->c);
|
||||||
toolsLoadDouble(f, &m->d);
|
packReadDouble(stream, &m->d);
|
||||||
toolsLoadDouble(f, &m->e);
|
packReadDouble(stream, &m->e);
|
||||||
toolsLoadDouble(f, &m->f);
|
packReadDouble(stream, &m->f);
|
||||||
toolsLoadDouble(f, &m->g);
|
packReadDouble(stream, &m->g);
|
||||||
toolsLoadDouble(f, &m->h);
|
packReadDouble(stream, &m->h);
|
||||||
toolsLoadDouble(f, &m->i);
|
packReadDouble(stream, &m->i);
|
||||||
toolsLoadDouble(f, &m->j);
|
packReadDouble(stream, &m->j);
|
||||||
toolsLoadDouble(f, &m->k);
|
packReadDouble(stream, &m->k);
|
||||||
toolsLoadDouble(f, &m->l);
|
packReadDouble(stream, &m->l);
|
||||||
toolsLoadDouble(f, &m->m);
|
packReadDouble(stream, &m->m);
|
||||||
toolsLoadDouble(f, &m->n);
|
packReadDouble(stream, &m->n);
|
||||||
toolsLoadDouble(f, &m->o);
|
packReadDouble(stream, &m->o);
|
||||||
toolsLoadDouble(f, &m->p);
|
packReadDouble(stream, &m->p);
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4 m4NewIdentity()
|
Matrix4 m4NewIdentity()
|
||||||
|
|
|
@ -2,13 +2,14 @@
|
||||||
#define _PAYSAGES_EUCLID_H_
|
#define _PAYSAGES_EUCLID_H_
|
||||||
|
|
||||||
#include "shared/types.h"
|
#include "shared/types.h"
|
||||||
|
#include "pack.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void v3Save(FILE* f, Vector3* v);
|
void v3Save(PackStream* stream, Vector3* v);
|
||||||
void v3Load(FILE* f, Vector3* v);
|
void v3Load(PackStream* stream, Vector3* v);
|
||||||
Vector3 v3Translate(Vector3 v1, double x, double y, double z);
|
Vector3 v3Translate(Vector3 v1, double x, double y, double z);
|
||||||
Vector3 v3Add(Vector3 v1, Vector3 v2);
|
Vector3 v3Add(Vector3 v1, Vector3 v2);
|
||||||
Vector3 v3Sub(Vector3 v1, Vector3 v2);
|
Vector3 v3Sub(Vector3 v1, Vector3 v2);
|
||||||
|
@ -19,8 +20,8 @@ Vector3 v3Normalize(Vector3 v);
|
||||||
double v3Dot(Vector3 v1, Vector3 v2);
|
double v3Dot(Vector3 v1, Vector3 v2);
|
||||||
Vector3 v3Cross(Vector3 v1, Vector3 v2);
|
Vector3 v3Cross(Vector3 v1, Vector3 v2);
|
||||||
|
|
||||||
void m4Save(FILE* f, Matrix4* m);
|
void m4Save(PackStream* stream, Matrix4* m);
|
||||||
void m4Load(FILE* f, Matrix4* m);
|
void m4Load(PackStream* stream, Matrix4* m);
|
||||||
Matrix4 m4NewIdentity();
|
Matrix4 m4NewIdentity();
|
||||||
Matrix4 m4Mult(Matrix4 m1, Matrix4 m2);
|
Matrix4 m4Mult(Matrix4 m1, Matrix4 m2);
|
||||||
Vector3 m4MultPoint(Matrix4 m, Vector3 v);
|
Vector3 m4MultPoint(Matrix4 m, Vector3 v);
|
||||||
|
|
|
@ -34,37 +34,37 @@ void lightingQuit()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void lightingSave(FILE* f, LightingDefinition* definition)
|
void lightingSave(PackStream* stream, LightingDefinition* definition)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
toolsSaveInt(f, &definition->autosetfromsky);
|
packWriteInt(stream, &definition->autosetfromsky);
|
||||||
toolsSaveInt(f, &definition->nblights);
|
packWriteInt(stream, &definition->nblights);
|
||||||
for (i = 0; i < definition->nblights; i++)
|
for (i = 0; i < definition->nblights; i++)
|
||||||
{
|
{
|
||||||
v3Save(f, &definition->lights[i].direction);
|
v3Save(stream, &definition->lights[i].direction);
|
||||||
colorSave(f, &definition->lights[i].color);
|
colorSave(stream, &definition->lights[i].color);
|
||||||
toolsSaveDouble(f, &definition->lights[i].reflection);
|
packWriteDouble(stream, &definition->lights[i].reflection);
|
||||||
toolsSaveInt(f, &definition->lights[i].filtered);
|
packWriteInt(stream, &definition->lights[i].filtered);
|
||||||
toolsSaveInt(f, &definition->lights[i].masked);
|
packWriteInt(stream, &definition->lights[i].masked);
|
||||||
toolsSaveDouble(f, &definition->lights[i].amplitude);
|
packWriteDouble(stream, &definition->lights[i].amplitude);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void lightingLoad(FILE* f, LightingDefinition* definition)
|
void lightingLoad(PackStream* stream, LightingDefinition* definition)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
toolsLoadInt(f, &definition->autosetfromsky);
|
packReadInt(stream, &definition->autosetfromsky);
|
||||||
toolsLoadInt(f, &definition->nblights);
|
packReadInt(stream, &definition->nblights);
|
||||||
for (i = 0; i < definition->nblights; i++)
|
for (i = 0; i < definition->nblights; i++)
|
||||||
{
|
{
|
||||||
v3Load(f, &definition->lights[i].direction);
|
v3Load(stream, &definition->lights[i].direction);
|
||||||
colorLoad(f, &definition->lights[i].color);
|
colorLoad(stream, &definition->lights[i].color);
|
||||||
toolsLoadDouble(f, &definition->lights[i].reflection);
|
packReadDouble(stream, &definition->lights[i].reflection);
|
||||||
toolsLoadInt(f, &definition->lights[i].filtered);
|
packReadInt(stream, &definition->lights[i].filtered);
|
||||||
toolsLoadInt(f, &definition->lights[i].masked);
|
packReadInt(stream, &definition->lights[i].masked);
|
||||||
toolsLoadDouble(f, &definition->lights[i].amplitude);
|
packReadDouble(stream, &definition->lights[i].amplitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
lightingValidateDefinition(definition);
|
lightingValidateDefinition(definition);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "shared/types.h"
|
#include "shared/types.h"
|
||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
#include <stdio.h>
|
#include "pack.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -32,8 +32,8 @@ typedef struct
|
||||||
|
|
||||||
void lightingInit();
|
void lightingInit();
|
||||||
void lightingQuit();
|
void lightingQuit();
|
||||||
void lightingSave(FILE* f, LightingDefinition* definition);
|
void lightingSave(PackStream* stream, LightingDefinition* definition);
|
||||||
void lightingLoad(FILE* f, LightingDefinition* definition);
|
void lightingLoad(PackStream* stream, LightingDefinition* definition);
|
||||||
|
|
||||||
LightingDefinition lightingCreateDefinition();
|
LightingDefinition lightingCreateDefinition();
|
||||||
void lightingDeleteDefinition(LightingDefinition* definition);
|
void lightingDeleteDefinition(LightingDefinition* definition);
|
||||||
|
|
|
@ -46,18 +46,18 @@ void modifierDelete(HeightModifier* modifier)
|
||||||
free(modifier);
|
free(modifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
void modifierSave(FILE* f, HeightModifier* modifier)
|
void modifierSave(PackStream* stream, HeightModifier* modifier)
|
||||||
{
|
{
|
||||||
toolsSaveInt(f, &modifier->mode);
|
packWriteInt(stream, &modifier->mode);
|
||||||
toolsSaveDouble(f, &modifier->value);
|
packWriteDouble(stream, &modifier->value);
|
||||||
zoneSave(f, modifier->zone);
|
zoneSave(stream, modifier->zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
void modifierLoad(FILE* f, HeightModifier* modifier)
|
void modifierLoad(PackStream* stream, HeightModifier* modifier)
|
||||||
{
|
{
|
||||||
toolsLoadInt(f, &modifier->mode);
|
packReadInt(stream, &modifier->mode);
|
||||||
toolsLoadDouble(f, &modifier->value);
|
packReadDouble(stream, &modifier->value);
|
||||||
zoneLoad(f, modifier->zone);
|
zoneLoad(stream, modifier->zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
Zone* modifierGetZone(HeightModifier* modifier)
|
Zone* modifierGetZone(HeightModifier* modifier)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef _PAYSAGES_MODIFIERS_H_
|
#ifndef _PAYSAGES_MODIFIERS_H_
|
||||||
#define _PAYSAGES_MODIFIERS_H_
|
#define _PAYSAGES_MODIFIERS_H_
|
||||||
|
|
||||||
#include <stdio.h>
|
#include "pack.h"
|
||||||
#include "zone.h"
|
#include "zone.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -13,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(FILE* f, HeightModifier* modifier);
|
void modifierSave(PackStream* stream, HeightModifier* modifier);
|
||||||
void modifierLoad(FILE* f, HeightModifier* modifier);
|
void modifierLoad(PackStream* stream, 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);
|
||||||
|
|
|
@ -46,26 +46,26 @@ void noiseQuit()
|
||||||
free(_noise_pool);
|
free(_noise_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
void noiseSave(FILE* f)
|
void noiseSave(PackStream* stream)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
toolsSaveInt(f, &_noise_pool_size);
|
packWriteInt(stream, &_noise_pool_size);
|
||||||
for (i = 0; i < _noise_pool_size; i++)
|
for (i = 0; i < _noise_pool_size; i++)
|
||||||
{
|
{
|
||||||
toolsSaveDouble(f, _noise_pool + i);
|
packWriteDouble(stream, _noise_pool + i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void noiseLoad(FILE* f)
|
void noiseLoad(PackStream* stream)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
toolsLoadInt(f, &_noise_pool_size);
|
packReadInt(stream, &_noise_pool_size);
|
||||||
_noise_pool = realloc(_noise_pool, sizeof(double) * _noise_pool_size);
|
_noise_pool = realloc(_noise_pool, sizeof(double) * _noise_pool_size);
|
||||||
for (i = 0; i < _noise_pool_size; i++)
|
for (i = 0; i < _noise_pool_size; i++)
|
||||||
{
|
{
|
||||||
toolsLoadDouble(f, _noise_pool + i);
|
packReadDouble(stream, _noise_pool + i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,47 +89,47 @@ void noiseDeleteGenerator(NoiseGenerator* generator)
|
||||||
free(generator);
|
free(generator);
|
||||||
}
|
}
|
||||||
|
|
||||||
void noiseSaveGenerator(FILE* f, NoiseGenerator* perlin)
|
void noiseSaveGenerator(PackStream* stream, NoiseGenerator* perlin)
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
toolsSaveInt(f, &perlin->size1);
|
packWriteInt(stream, &perlin->size1);
|
||||||
toolsSaveInt(f, &perlin->size2);
|
packWriteInt(stream, &perlin->size2);
|
||||||
toolsSaveInt(f, &perlin->size3);
|
packWriteInt(stream, &perlin->size3);
|
||||||
toolsSaveDouble(f, &perlin->height_offset);
|
packWriteDouble(stream, &perlin->height_offset);
|
||||||
toolsSaveInt(f, &perlin->level_count);
|
packWriteInt(stream, &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;
|
||||||
|
|
||||||
toolsSaveDouble(f, &level->scaling);
|
packWriteDouble(stream, &level->scaling);
|
||||||
toolsSaveDouble(f, &level->height);
|
packWriteDouble(stream, &level->height);
|
||||||
toolsSaveDouble(f, &level->xoffset);
|
packWriteDouble(stream, &level->xoffset);
|
||||||
toolsSaveDouble(f, &level->yoffset);
|
packWriteDouble(stream, &level->yoffset);
|
||||||
toolsSaveDouble(f, &level->zoffset);
|
packWriteDouble(stream, &level->zoffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void noiseLoadGenerator(FILE* f, NoiseGenerator* perlin)
|
void noiseLoadGenerator(PackStream* stream, NoiseGenerator* perlin)
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
toolsLoadInt(f, &perlin->size1);
|
packReadInt(stream, &perlin->size1);
|
||||||
toolsLoadInt(f, &perlin->size2);
|
packReadInt(stream, &perlin->size2);
|
||||||
toolsLoadInt(f, &perlin->size3);
|
packReadInt(stream, &perlin->size3);
|
||||||
toolsLoadDouble(f, &perlin->height_offset);
|
packReadDouble(stream, &perlin->height_offset);
|
||||||
toolsLoadInt(f, &perlin->level_count);
|
packReadInt(stream, &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;
|
||||||
|
|
||||||
toolsLoadDouble(f, &level->scaling);
|
packReadDouble(stream, &level->scaling);
|
||||||
toolsLoadDouble(f, &level->height);
|
packReadDouble(stream, &level->height);
|
||||||
toolsLoadDouble(f, &level->xoffset);
|
packReadDouble(stream, &level->xoffset);
|
||||||
toolsLoadDouble(f, &level->yoffset);
|
packReadDouble(stream, &level->yoffset);
|
||||||
toolsLoadDouble(f, &level->zoffset);
|
packReadDouble(stream, &level->zoffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef _PAYSAGES_NOISE_H_
|
#ifndef _PAYSAGES_NOISE_H_
|
||||||
#define _PAYSAGES_NOISE_H_
|
#define _PAYSAGES_NOISE_H_
|
||||||
|
|
||||||
#include <stdio.h>
|
#include "pack.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -20,13 +20,13 @@ typedef struct NoiseGenerator NoiseGenerator;
|
||||||
|
|
||||||
void noiseInit();
|
void noiseInit();
|
||||||
void noiseQuit();
|
void noiseQuit();
|
||||||
void noiseSave(FILE* f);
|
void noiseSave(PackStream* stream);
|
||||||
void noiseLoad(FILE* f);
|
void noiseLoad(PackStream* stream);
|
||||||
|
|
||||||
NoiseGenerator* noiseCreateGenerator();
|
NoiseGenerator* noiseCreateGenerator();
|
||||||
void noiseDeleteGenerator(NoiseGenerator* generator);
|
void noiseDeleteGenerator(NoiseGenerator* generator);
|
||||||
void noiseSaveGenerator(FILE* f, NoiseGenerator* perlin);
|
void noiseSaveGenerator(PackStream* stream, NoiseGenerator* perlin);
|
||||||
void noiseLoadGenerator(FILE* f, NoiseGenerator* perlin);
|
void noiseLoadGenerator(PackStream* stream, 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);
|
||||||
|
|
139
lib_paysages/pack.c
Normal file
139
lib_paysages/pack.c
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
#include "pack.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "color.h"
|
||||||
|
#include "euclid.h"
|
||||||
|
|
||||||
|
struct PackStream
|
||||||
|
{
|
||||||
|
FILE* fd;
|
||||||
|
int write;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define pack754_32(f) (pack754((f), 32, 8))
|
||||||
|
#define pack754_64(f) (pack754((f), 64, 11))
|
||||||
|
#define unpack754_32(i) (unpack754((i), 32, 8))
|
||||||
|
#define unpack754_64(i) (unpack754((i), 64, 11))
|
||||||
|
|
||||||
|
static uint64_t pack754(double f, unsigned bits, unsigned expbits)
|
||||||
|
{
|
||||||
|
double fnorm;
|
||||||
|
int shift;
|
||||||
|
long long sign, exp, significand;
|
||||||
|
unsigned significandbits = bits - expbits - 1; // -1 for sign bit
|
||||||
|
|
||||||
|
if (f == 0.0) return 0; // get this special case out of the way
|
||||||
|
|
||||||
|
// check sign and begin normalization
|
||||||
|
if (f < 0) { sign = 1; fnorm = -f; }
|
||||||
|
else { sign = 0; fnorm = f; }
|
||||||
|
|
||||||
|
// get the normalized form of f and track the exponent
|
||||||
|
shift = 0;
|
||||||
|
while(fnorm >= 2.0) { fnorm /= 2.0; shift++; }
|
||||||
|
while(fnorm < 1.0) { fnorm *= 2.0; shift--; }
|
||||||
|
fnorm = fnorm - 1.0;
|
||||||
|
|
||||||
|
// calculate the binary form (non-float) of the significand data
|
||||||
|
significand = fnorm * ((1LL<<significandbits) + 0.5f);
|
||||||
|
|
||||||
|
// get the biased exponent
|
||||||
|
exp = shift + ((1<<(expbits-1)) - 1); // shift + bias
|
||||||
|
|
||||||
|
// return the final answer
|
||||||
|
return (sign<<(bits-1)) | (exp<<(bits-expbits-1)) | significand;
|
||||||
|
}
|
||||||
|
|
||||||
|
static double unpack754(uint64_t i, unsigned bits, unsigned expbits)
|
||||||
|
{
|
||||||
|
double result;
|
||||||
|
long long shift;
|
||||||
|
unsigned bias;
|
||||||
|
unsigned significandbits = bits - expbits - 1; // -1 for sign bit
|
||||||
|
|
||||||
|
if (i == 0) return 0.0;
|
||||||
|
|
||||||
|
// pull the significand
|
||||||
|
result = (i&((1LL<<significandbits)-1)); // mask
|
||||||
|
result /= (1LL<<significandbits); // convert back to float
|
||||||
|
result += 1.0f; // add the one back on
|
||||||
|
|
||||||
|
// deal with the exponent
|
||||||
|
bias = (1<<(expbits-1)) - 1;
|
||||||
|
shift = ((i>>significandbits)&((1LL<<expbits)-1)) - bias;
|
||||||
|
while(shift > 0) { result *= 2.0; shift--; }
|
||||||
|
while(shift < 0) { result /= 2.0; shift++; }
|
||||||
|
|
||||||
|
// sign it
|
||||||
|
result *= (i>>(bits-1))&1? -1.0: 1.0;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
PackStream* packReadFile(char* filepath)
|
||||||
|
{
|
||||||
|
PackStream* result;
|
||||||
|
|
||||||
|
result = malloc(sizeof(PackStream));
|
||||||
|
result->fd = fopen(filepath, "rb");
|
||||||
|
result->write = 0;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
PackStream* packWriteFile(char* filepath)
|
||||||
|
{
|
||||||
|
PackStream* result;
|
||||||
|
|
||||||
|
result = malloc(sizeof(PackStream));
|
||||||
|
result->fd = fopen(filepath, "wb");
|
||||||
|
result->write = 1;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void packCloseStream(PackStream* stream)
|
||||||
|
{
|
||||||
|
if (stream->write)
|
||||||
|
{
|
||||||
|
fflush(stream->fd);
|
||||||
|
}
|
||||||
|
fclose(stream->fd);
|
||||||
|
free(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
void packWriteDouble(PackStream* stream, double* value)
|
||||||
|
{
|
||||||
|
uint64_t servalue;
|
||||||
|
|
||||||
|
servalue = pack754_64(*value);
|
||||||
|
fwrite(&servalue, sizeof(uint64_t), 1, stream->fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void packReadDouble(PackStream* stream, double* value)
|
||||||
|
{
|
||||||
|
int read;
|
||||||
|
uint64_t servalue;
|
||||||
|
|
||||||
|
read = fread(&servalue, sizeof(uint64_t), 1, stream->fd);
|
||||||
|
assert(read == 1);
|
||||||
|
|
||||||
|
*value = unpack754_64(servalue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void packWriteInt(PackStream* stream, int* value)
|
||||||
|
{
|
||||||
|
fprintf(stream->fd, "%d;", *value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void packReadInt(PackStream* stream, int* value)
|
||||||
|
{
|
||||||
|
int read;
|
||||||
|
|
||||||
|
read = fscanf(stream->fd, "%d;", value);
|
||||||
|
assert(read == 1);
|
||||||
|
}
|
26
lib_paysages/pack.h
Normal file
26
lib_paysages/pack.h
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef _PAYSAGES_PACK_H_
|
||||||
|
#define _PAYSAGES_PACK_H_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "shared/types.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct PackStream PackStream;
|
||||||
|
|
||||||
|
PackStream* packReadFile(char* filepath);
|
||||||
|
PackStream* packWriteFile(char* filepath);
|
||||||
|
void packCloseStream(PackStream* stream);
|
||||||
|
|
||||||
|
void packWriteDouble(PackStream* stream, double* value);
|
||||||
|
void packReadDouble(PackStream* stream, double* value);
|
||||||
|
void packWriteInt(PackStream* stream, int* value);
|
||||||
|
void packReadInt(PackStream* stream, int* value);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -67,39 +67,38 @@ void sceneryQuit()
|
||||||
|
|
||||||
void scenerySaveToFile(char* filepath)
|
void scenerySaveToFile(char* filepath)
|
||||||
{
|
{
|
||||||
FILE* f = fopen(filepath, "wb");
|
PackStream* stream = packWriteFile(filepath);
|
||||||
|
|
||||||
noiseSave(f);
|
noiseSave(stream);
|
||||||
atmosphereSave(f, &_atmosphere);
|
atmosphereSave(stream, &_atmosphere);
|
||||||
cameraSave(f, &_camera);
|
cameraSave(stream, &_camera);
|
||||||
cloudsSave(f, &_clouds);
|
cloudsSave(stream, &_clouds);
|
||||||
lightingSave(f, &_lighting);
|
lightingSave(stream, &_lighting);
|
||||||
skySave(f, &_sky);
|
skySave(stream, &_sky);
|
||||||
terrainSave(f, &_terrain);
|
terrainSave(stream, &_terrain);
|
||||||
texturesSave(f, &_textures);
|
texturesSave(stream, &_textures);
|
||||||
vegetationSave(f, _vegetation);
|
vegetationSave(stream, _vegetation);
|
||||||
waterSave(f, &_water);
|
waterSave(stream, &_water);
|
||||||
|
|
||||||
fflush(f);
|
packCloseStream(stream);
|
||||||
fclose(f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void sceneryLoadFromFile(char* filepath)
|
void sceneryLoadFromFile(char* filepath)
|
||||||
{
|
{
|
||||||
FILE* f = fopen(filepath, "rb");
|
PackStream* stream = packReadFile(filepath);
|
||||||
|
|
||||||
/* TODO Use intermediary definitions ? */
|
/* TODO Use intermediary definitions ? */
|
||||||
|
|
||||||
noiseLoad(f);
|
noiseLoad(stream);
|
||||||
atmosphereLoad(f, &_atmosphere);
|
atmosphereLoad(stream, &_atmosphere);
|
||||||
cameraLoad(f, &_camera);
|
cameraLoad(stream, &_camera);
|
||||||
cloudsLoad(f, &_clouds);
|
cloudsLoad(stream, &_clouds);
|
||||||
lightingLoad(f, &_lighting);
|
lightingLoad(stream, &_lighting);
|
||||||
skyLoad(f, &_sky);
|
skyLoad(stream, &_sky);
|
||||||
terrainLoad(f, &_terrain);
|
terrainLoad(stream, &_terrain);
|
||||||
texturesLoad(f, &_textures);
|
texturesLoad(stream, &_textures);
|
||||||
vegetationLoad(f, _vegetation);
|
vegetationLoad(stream, _vegetation);
|
||||||
waterLoad(f, &_water);
|
waterLoad(stream, &_water);
|
||||||
|
|
||||||
atmosphereValidateDefinition(&_atmosphere);
|
atmosphereValidateDefinition(&_atmosphere);
|
||||||
cameraValidateDefinition(&_camera, 0);
|
cameraValidateDefinition(&_camera, 0);
|
||||||
|
@ -111,7 +110,7 @@ void sceneryLoadFromFile(char* filepath)
|
||||||
vegetationValidateDefinition(_vegetation);
|
vegetationValidateDefinition(_vegetation);
|
||||||
waterValidateDefinition(&_water);
|
waterValidateDefinition(&_water);
|
||||||
|
|
||||||
fclose(f);
|
packCloseStream(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
void scenerySetAtmosphere(AtmosphereDefinition* atmosphere)
|
void scenerySetAtmosphere(AtmosphereDefinition* atmosphere)
|
||||||
|
|
|
@ -22,26 +22,26 @@ void skyQuit()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void skySave(FILE* f, SkyDefinition* definition)
|
void skySave(PackStream* stream, SkyDefinition* definition)
|
||||||
{
|
{
|
||||||
toolsSaveDouble(f, &definition->daytime);
|
packWriteDouble(stream, &definition->daytime);
|
||||||
colorGradationSave(f, definition->sun_color);
|
colorGradationSave(stream, definition->sun_color);
|
||||||
toolsSaveDouble(f, &definition->sun_radius);
|
packWriteDouble(stream, &definition->sun_radius);
|
||||||
colorGradationSave(f, definition->zenith_color);
|
colorGradationSave(stream, definition->zenith_color);
|
||||||
colorGradationSave(f, definition->haze_color);
|
colorGradationSave(stream, definition->haze_color);
|
||||||
toolsSaveDouble(f, &definition->haze_height);
|
packWriteDouble(stream, &definition->haze_height);
|
||||||
toolsSaveDouble(f, &definition->haze_smoothing);
|
packWriteDouble(stream, &definition->haze_smoothing);
|
||||||
}
|
}
|
||||||
|
|
||||||
void skyLoad(FILE* f, SkyDefinition* definition)
|
void skyLoad(PackStream* stream, SkyDefinition* definition)
|
||||||
{
|
{
|
||||||
toolsLoadDouble(f, &definition->daytime);
|
packReadDouble(stream, &definition->daytime);
|
||||||
colorGradationLoad(f, definition->sun_color);
|
colorGradationLoad(stream, definition->sun_color);
|
||||||
toolsLoadDouble(f, &definition->sun_radius);
|
packReadDouble(stream, &definition->sun_radius);
|
||||||
colorGradationLoad(f, definition->zenith_color);
|
colorGradationLoad(stream, definition->zenith_color);
|
||||||
colorGradationLoad(f, definition->haze_color);
|
colorGradationLoad(stream, definition->haze_color);
|
||||||
toolsLoadDouble(f, &definition->haze_height);
|
packReadDouble(stream, &definition->haze_height);
|
||||||
toolsLoadDouble(f, &definition->haze_smoothing);
|
packReadDouble(stream, &definition->haze_smoothing);
|
||||||
|
|
||||||
skyValidateDefinition(definition);
|
skyValidateDefinition(definition);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "shared/types.h"
|
#include "shared/types.h"
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
#include "lighting.h"
|
#include "lighting.h"
|
||||||
#include <stdio.h>
|
#include "pack.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -24,8 +24,8 @@ typedef struct
|
||||||
|
|
||||||
void skyInit();
|
void skyInit();
|
||||||
void skyQuit();
|
void skyQuit();
|
||||||
void skySave(FILE* f, SkyDefinition* definition);
|
void skySave(PackStream* stream, SkyDefinition* definition);
|
||||||
void skyLoad(FILE* f, SkyDefinition* definition);
|
void skyLoad(PackStream* stream, SkyDefinition* definition);
|
||||||
|
|
||||||
SkyDefinition skyCreateDefinition();
|
SkyDefinition skyCreateDefinition();
|
||||||
void skyDeleteDefinition(SkyDefinition* definition);
|
void skyDeleteDefinition(SkyDefinition* definition);
|
||||||
|
|
|
@ -21,39 +21,39 @@ void terrainQuit()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void terrainSave(FILE* f, TerrainDefinition* definition)
|
void terrainSave(PackStream* stream, TerrainDefinition* definition)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
noiseSaveGenerator(f, definition->height_noise);
|
noiseSaveGenerator(stream, definition->height_noise);
|
||||||
toolsSaveDouble(f, &definition->height_factor);
|
packWriteDouble(stream, &definition->height_factor);
|
||||||
toolsSaveDouble(f, &definition->scaling);
|
packWriteDouble(stream, &definition->scaling);
|
||||||
|
|
||||||
toolsSaveInt(f, &definition->height_modifiers_count);
|
packWriteInt(stream, &definition->height_modifiers_count);
|
||||||
for (i = 0; i < definition->height_modifiers_count; i++)
|
for (i = 0; i < definition->height_modifiers_count; i++)
|
||||||
{
|
{
|
||||||
modifierSave(f, definition->height_modifiers[i]);
|
modifierSave(stream, definition->height_modifiers[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void terrainLoad(FILE* f, TerrainDefinition* definition)
|
void terrainLoad(PackStream* stream, TerrainDefinition* definition)
|
||||||
{
|
{
|
||||||
int i, n;
|
int i, n;
|
||||||
HeightModifier* modifier;
|
HeightModifier* modifier;
|
||||||
|
|
||||||
noiseLoadGenerator(f, definition->height_noise);
|
noiseLoadGenerator(stream, definition->height_noise);
|
||||||
toolsLoadDouble(f, &definition->height_factor);
|
packReadDouble(stream, &definition->height_factor);
|
||||||
toolsLoadDouble(f, &definition->scaling);
|
packReadDouble(stream, &definition->scaling);
|
||||||
|
|
||||||
while (definition->height_modifiers_count > 0)
|
while (definition->height_modifiers_count > 0)
|
||||||
{
|
{
|
||||||
terrainDelModifier(definition, 0);
|
terrainDelModifier(definition, 0);
|
||||||
}
|
}
|
||||||
toolsLoadInt(f, &n);
|
packReadInt(stream, &n);
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
modifier = modifierCreate();
|
modifier = modifierCreate();
|
||||||
modifierLoad(f, modifier);
|
modifierLoad(stream, modifier);
|
||||||
terrainAddModifier(definition, modifier);
|
terrainAddModifier(definition, modifier);
|
||||||
modifierDelete(modifier);
|
modifierDelete(modifier);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "modifiers.h"
|
#include "modifiers.h"
|
||||||
#include "noise.h"
|
#include "noise.h"
|
||||||
#include "lighting.h"
|
#include "lighting.h"
|
||||||
#include <stdio.h>
|
#include "pack.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -26,8 +26,8 @@ typedef struct
|
||||||
|
|
||||||
void terrainInit();
|
void terrainInit();
|
||||||
void terrainQuit();
|
void terrainQuit();
|
||||||
void terrainSave(FILE* f, TerrainDefinition* definition);
|
void terrainSave(PackStream* stream, TerrainDefinition* definition);
|
||||||
void terrainLoad(FILE* f, TerrainDefinition* definition);
|
void terrainLoad(PackStream* stream, TerrainDefinition* definition);
|
||||||
|
|
||||||
TerrainDefinition terrainCreateDefinition();
|
TerrainDefinition terrainCreateDefinition();
|
||||||
void terrainDeleteDefinition(TerrainDefinition* definition);
|
void terrainDeleteDefinition(TerrainDefinition* definition);
|
||||||
|
|
|
@ -25,22 +25,22 @@ void texturesQuit()
|
||||||
texturesLayerDeleteDefinition(&_NULL_LAYER);
|
texturesLayerDeleteDefinition(&_NULL_LAYER);
|
||||||
}
|
}
|
||||||
|
|
||||||
void texturesSave(FILE* f, TexturesDefinition* definition)
|
void texturesSave(PackStream* stream, TexturesDefinition* definition)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
toolsSaveInt(f, &definition->nbtextures);
|
packWriteInt(stream, &definition->nbtextures);
|
||||||
for (i = 0; i < definition->nbtextures; i++)
|
for (i = 0; i < definition->nbtextures; i++)
|
||||||
{
|
{
|
||||||
zoneSave(f, definition->textures[i].zone);
|
zoneSave(stream, definition->textures[i].zone);
|
||||||
noiseSaveGenerator(f, definition->textures[i].bump_noise);
|
noiseSaveGenerator(stream, definition->textures[i].bump_noise);
|
||||||
toolsSaveDouble(f, &definition->textures[i].bump_height);
|
packWriteDouble(stream, &definition->textures[i].bump_height);
|
||||||
toolsSaveDouble(f, &definition->textures[i].bump_scaling);
|
packWriteDouble(stream, &definition->textures[i].bump_scaling);
|
||||||
materialSave(f, &definition->textures[i].material);
|
materialSave(stream, &definition->textures[i].material);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void texturesLoad(FILE* f, TexturesDefinition* definition)
|
void texturesLoad(PackStream* stream, TexturesDefinition* definition)
|
||||||
{
|
{
|
||||||
TextureLayerDefinition* layer;
|
TextureLayerDefinition* layer;
|
||||||
int i, n;
|
int i, n;
|
||||||
|
@ -50,16 +50,16 @@ void texturesLoad(FILE* f, TexturesDefinition* definition)
|
||||||
texturesDeleteLayer(definition, 0);
|
texturesDeleteLayer(definition, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
toolsLoadInt(f, &n);
|
packReadInt(stream, &n);
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
layer = definition->textures + texturesAddLayer(definition);
|
layer = definition->textures + texturesAddLayer(definition);
|
||||||
|
|
||||||
zoneLoad(f, layer->zone);
|
zoneLoad(stream, layer->zone);
|
||||||
noiseLoadGenerator(f, layer->bump_noise);
|
noiseLoadGenerator(stream, layer->bump_noise);
|
||||||
toolsLoadDouble(f, &layer->bump_height);
|
packReadDouble(stream, &layer->bump_height);
|
||||||
toolsLoadDouble(f, &layer->bump_scaling);
|
packReadDouble(stream, &layer->bump_scaling);
|
||||||
materialLoad(f, &layer->material);
|
materialLoad(stream, &layer->material);
|
||||||
}
|
}
|
||||||
|
|
||||||
texturesValidateDefinition(definition);
|
texturesValidateDefinition(definition);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "shared/types.h"
|
#include "shared/types.h"
|
||||||
#include "noise.h"
|
#include "noise.h"
|
||||||
#include "lighting.h"
|
#include "lighting.h"
|
||||||
#include <stdio.h>
|
#include "pack.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -29,8 +29,8 @@ typedef struct
|
||||||
|
|
||||||
void texturesInit();
|
void texturesInit();
|
||||||
void texturesQuit();
|
void texturesQuit();
|
||||||
void texturesSave(FILE* f, TexturesDefinition* definition);
|
void texturesSave(PackStream* stream, TexturesDefinition* definition);
|
||||||
void texturesLoad(FILE* f, TexturesDefinition* definition);
|
void texturesLoad(PackStream* stream, TexturesDefinition* definition);
|
||||||
|
|
||||||
TexturesDefinition texturesCreateDefinition();
|
TexturesDefinition texturesCreateDefinition();
|
||||||
void texturesDeleteDefinition(TexturesDefinition* definition);
|
void texturesDeleteDefinition(TexturesDefinition* definition);
|
||||||
|
|
|
@ -8,66 +8,6 @@
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
#include "euclid.h"
|
#include "euclid.h"
|
||||||
|
|
||||||
#define pack754_32(f) (pack754((f), 32, 8))
|
|
||||||
#define pack754_64(f) (pack754((f), 64, 11))
|
|
||||||
#define unpack754_32(i) (unpack754((i), 32, 8))
|
|
||||||
#define unpack754_64(i) (unpack754((i), 64, 11))
|
|
||||||
|
|
||||||
static uint64_t pack754(double f, unsigned bits, unsigned expbits)
|
|
||||||
{
|
|
||||||
double fnorm;
|
|
||||||
int shift;
|
|
||||||
long long sign, exp, significand;
|
|
||||||
unsigned significandbits = bits - expbits - 1; // -1 for sign bit
|
|
||||||
|
|
||||||
if (f == 0.0) return 0; // get this special case out of the way
|
|
||||||
|
|
||||||
// check sign and begin normalization
|
|
||||||
if (f < 0) { sign = 1; fnorm = -f; }
|
|
||||||
else { sign = 0; fnorm = f; }
|
|
||||||
|
|
||||||
// get the normalized form of f and track the exponent
|
|
||||||
shift = 0;
|
|
||||||
while(fnorm >= 2.0) { fnorm /= 2.0; shift++; }
|
|
||||||
while(fnorm < 1.0) { fnorm *= 2.0; shift--; }
|
|
||||||
fnorm = fnorm - 1.0;
|
|
||||||
|
|
||||||
// calculate the binary form (non-float) of the significand data
|
|
||||||
significand = fnorm * ((1LL<<significandbits) + 0.5f);
|
|
||||||
|
|
||||||
// get the biased exponent
|
|
||||||
exp = shift + ((1<<(expbits-1)) - 1); // shift + bias
|
|
||||||
|
|
||||||
// return the final answer
|
|
||||||
return (sign<<(bits-1)) | (exp<<(bits-expbits-1)) | significand;
|
|
||||||
}
|
|
||||||
|
|
||||||
static double unpack754(uint64_t i, unsigned bits, unsigned expbits)
|
|
||||||
{
|
|
||||||
double result;
|
|
||||||
long long shift;
|
|
||||||
unsigned bias;
|
|
||||||
unsigned significandbits = bits - expbits - 1; // -1 for sign bit
|
|
||||||
|
|
||||||
if (i == 0) return 0.0;
|
|
||||||
|
|
||||||
// pull the significand
|
|
||||||
result = (i&((1LL<<significandbits)-1)); // mask
|
|
||||||
result /= (1LL<<significandbits); // convert back to float
|
|
||||||
result += 1.0f; // add the one back on
|
|
||||||
|
|
||||||
// deal with the exponent
|
|
||||||
bias = (1<<(expbits-1)) - 1;
|
|
||||||
shift = ((i>>significandbits)&((1LL<<expbits)-1)) - bias;
|
|
||||||
while(shift > 0) { result *= 2.0; shift--; }
|
|
||||||
while(shift < 0) { result /= 2.0; shift++; }
|
|
||||||
|
|
||||||
// sign it
|
|
||||||
result *= (i>>(bits-1))&1? -1.0: 1.0;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
double toolsRandom()
|
double toolsRandom()
|
||||||
{
|
{
|
||||||
return (double)rand() / (double)RAND_MAX;
|
return (double)rand() / (double)RAND_MAX;
|
||||||
|
@ -127,48 +67,16 @@ double toolsGetDistance2D(double x1, double y1, double x2, double y2)
|
||||||
return sqrt(dx * dx + dy * dy);
|
return sqrt(dx * dx + dy * dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void toolsSaveDouble(FILE* f, double* value)
|
void materialSave(PackStream* stream, SurfaceMaterial* material)
|
||||||
{
|
{
|
||||||
uint64_t servalue;
|
colorSave(stream, &material->base);
|
||||||
|
packWriteDouble(stream, &material->reflection);
|
||||||
servalue = pack754_64(*value);
|
packWriteDouble(stream, &material->shininess);
|
||||||
fwrite(&servalue, sizeof(uint64_t), 1, f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void toolsLoadDouble(FILE* f, double* value)
|
void materialLoad(PackStream* stream, SurfaceMaterial* material)
|
||||||
{
|
{
|
||||||
int read;
|
colorLoad(stream, &material->base);
|
||||||
uint64_t servalue;
|
packReadDouble(stream, &material->reflection);
|
||||||
|
packReadDouble(stream, &material->shininess);
|
||||||
read = fread(&servalue, sizeof(uint64_t), 1, f);
|
|
||||||
assert(read == 1);
|
|
||||||
|
|
||||||
*value = unpack754_64(servalue);
|
|
||||||
}
|
|
||||||
|
|
||||||
void toolsSaveInt(FILE* f, int* value)
|
|
||||||
{
|
|
||||||
fprintf(f, "%d;", *value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void toolsLoadInt(FILE* f, int* value)
|
|
||||||
{
|
|
||||||
int read;
|
|
||||||
|
|
||||||
read = fscanf(f, "%d;", value);
|
|
||||||
assert(read == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void materialSave(FILE* f, SurfaceMaterial* material)
|
|
||||||
{
|
|
||||||
colorSave(f, &material->base);
|
|
||||||
toolsSaveDouble(f, &material->reflection);
|
|
||||||
toolsSaveDouble(f, &material->shininess);
|
|
||||||
}
|
|
||||||
|
|
||||||
void materialLoad(FILE* f, SurfaceMaterial* material)
|
|
||||||
{
|
|
||||||
colorLoad(f, &material->base);
|
|
||||||
toolsLoadDouble(f, &material->reflection);
|
|
||||||
toolsLoadDouble(f, &material->shininess);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef _PAYSAGES_TOOLS_H_
|
#ifndef _PAYSAGES_TOOLS_H_
|
||||||
#define _PAYSAGES_TOOLS_H_
|
#define _PAYSAGES_TOOLS_H_
|
||||||
|
|
||||||
#include <stdio.h>
|
#include "pack.h"
|
||||||
#include "shared/types.h"
|
#include "shared/types.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -13,12 +13,8 @@ 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);
|
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);
|
Vector3 toolsGetNormalFromTriangle(Vector3 center, Vector3 bottom, Vector3 right);
|
||||||
double toolsGetDistance2D(double x1, double y1, double x2, double y2);
|
double toolsGetDistance2D(double x1, double y1, double x2, double y2);
|
||||||
void toolsSaveDouble(FILE* f, double* value);
|
void materialSave(PackStream* stream, SurfaceMaterial* material);
|
||||||
void toolsLoadDouble(FILE* f, double* value);
|
void materialLoad(PackStream* stream, SurfaceMaterial* material);
|
||||||
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,11 @@ void vegetationQuit()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void vegetationSave(FILE* f, VegetationDefinition* definition)
|
void vegetationSave(PackStream* stream, VegetationDefinition* definition)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void vegetationLoad(FILE* f, VegetationDefinition* definition)
|
void vegetationLoad(PackStream* stream, VegetationDefinition* definition)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef _PAYSAGES_VEGETATION_H_
|
#ifndef _PAYSAGES_VEGETATION_H_
|
||||||
#define _PAYSAGES_VEGETATION_H_
|
#define _PAYSAGES_VEGETATION_H_
|
||||||
|
|
||||||
#include <stdio.h>
|
#include "pack.h"
|
||||||
#include "zone.h"
|
#include "zone.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -20,8 +20,8 @@ typedef struct VegetationDefinition VegetationDefinition;
|
||||||
|
|
||||||
void vegetationInit();
|
void vegetationInit();
|
||||||
void vegetationQuit();
|
void vegetationQuit();
|
||||||
void vegetationSave(FILE* f, VegetationDefinition* definition);
|
void vegetationSave(PackStream* stream, VegetationDefinition* definition);
|
||||||
void vegetationLoad(FILE* f, VegetationDefinition* definition);
|
void vegetationLoad(PackStream* stream, VegetationDefinition* definition);
|
||||||
|
|
||||||
VegetationDefinition* vegetationCreateDefinition();
|
VegetationDefinition* vegetationCreateDefinition();
|
||||||
void vegetationDeleteDefinition(VegetationDefinition* definition);
|
void vegetationDeleteDefinition(VegetationDefinition* definition);
|
||||||
|
|
|
@ -19,32 +19,32 @@ void waterQuit()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void waterSave(FILE* f, WaterDefinition* definition)
|
void waterSave(PackStream* stream, WaterDefinition* definition)
|
||||||
{
|
{
|
||||||
toolsSaveDouble(f, &definition->height);
|
packWriteDouble(stream, &definition->height);
|
||||||
materialSave(f, &definition->material);
|
materialSave(stream, &definition->material);
|
||||||
colorSave(f, &definition->depth_color);
|
colorSave(stream, &definition->depth_color);
|
||||||
toolsSaveDouble(f, &definition->transparency_depth);
|
packWriteDouble(stream, &definition->transparency_depth);
|
||||||
toolsSaveDouble(f, &definition->transparency);
|
packWriteDouble(stream, &definition->transparency);
|
||||||
toolsSaveDouble(f, &definition->reflection);
|
packWriteDouble(stream, &definition->reflection);
|
||||||
toolsSaveDouble(f, &definition->lighting_depth);
|
packWriteDouble(stream, &definition->lighting_depth);
|
||||||
noiseSaveGenerator(f, definition->waves_noise);
|
noiseSaveGenerator(stream, definition->waves_noise);
|
||||||
toolsSaveDouble(f, &definition->waves_noise_height);
|
packWriteDouble(stream, &definition->waves_noise_height);
|
||||||
toolsSaveDouble(f, &definition->waves_noise_scale);
|
packWriteDouble(stream, &definition->waves_noise_scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void waterLoad(FILE* f, WaterDefinition* definition)
|
void waterLoad(PackStream* stream, WaterDefinition* definition)
|
||||||
{
|
{
|
||||||
toolsLoadDouble(f, &definition->height);
|
packReadDouble(stream, &definition->height);
|
||||||
materialLoad(f, &definition->material);
|
materialLoad(stream, &definition->material);
|
||||||
colorLoad(f, &definition->depth_color);
|
colorLoad(stream, &definition->depth_color);
|
||||||
toolsLoadDouble(f, &definition->transparency_depth);
|
packReadDouble(stream, &definition->transparency_depth);
|
||||||
toolsLoadDouble(f, &definition->transparency);
|
packReadDouble(stream, &definition->transparency);
|
||||||
toolsLoadDouble(f, &definition->reflection);
|
packReadDouble(stream, &definition->reflection);
|
||||||
toolsLoadDouble(f, &definition->lighting_depth);
|
packReadDouble(stream, &definition->lighting_depth);
|
||||||
noiseLoadGenerator(f, definition->waves_noise);
|
noiseLoadGenerator(stream, definition->waves_noise);
|
||||||
toolsLoadDouble(f, &definition->waves_noise_height);
|
packReadDouble(stream, &definition->waves_noise_height);
|
||||||
toolsLoadDouble(f, &definition->waves_noise_scale);
|
packReadDouble(stream, &definition->waves_noise_scale);
|
||||||
|
|
||||||
waterValidateDefinition(definition);
|
waterValidateDefinition(definition);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
#include "lighting.h"
|
#include "lighting.h"
|
||||||
#include "noise.h"
|
#include "noise.h"
|
||||||
#include <stdio.h>
|
#include "pack.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -36,8 +36,8 @@ typedef struct
|
||||||
|
|
||||||
void waterInit();
|
void waterInit();
|
||||||
void waterQuit();
|
void waterQuit();
|
||||||
void waterSave(FILE* f, WaterDefinition* definition);
|
void waterSave(PackStream* stream, WaterDefinition* definition);
|
||||||
void waterLoad(FILE* f, WaterDefinition* definition);
|
void waterLoad(PackStream* stream, WaterDefinition* definition);
|
||||||
|
|
||||||
WaterDefinition waterCreateDefinition();
|
WaterDefinition waterCreateDefinition();
|
||||||
void waterDeleteDefinition(WaterDefinition* definition);
|
void waterDeleteDefinition(WaterDefinition* definition);
|
||||||
|
|
|
@ -48,93 +48,93 @@ void zoneDelete(Zone* zone)
|
||||||
free(zone);
|
free(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
void zoneSave(FILE* f, Zone* zone)
|
void zoneSave(PackStream* stream, Zone* zone)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
toolsSaveInt(f, &zone->height_ranges_count);
|
packWriteInt(stream, &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);
|
packWriteDouble(stream, &zone->height_ranges[i].value);
|
||||||
toolsSaveDouble(f, &zone->height_ranges[i].hardmin);
|
packWriteDouble(stream, &zone->height_ranges[i].hardmin);
|
||||||
toolsSaveDouble(f, &zone->height_ranges[i].softmin);
|
packWriteDouble(stream, &zone->height_ranges[i].softmin);
|
||||||
toolsSaveDouble(f, &zone->height_ranges[i].softmax);
|
packWriteDouble(stream, &zone->height_ranges[i].softmax);
|
||||||
toolsSaveDouble(f, &zone->height_ranges[i].hardmax);
|
packWriteDouble(stream, &zone->height_ranges[i].hardmax);
|
||||||
}
|
}
|
||||||
|
|
||||||
toolsSaveInt(f, &zone->slope_ranges_count);
|
packWriteInt(stream, &zone->slope_ranges_count);
|
||||||
for (i = 0; i < zone->slope_ranges_count; i++)
|
for (i = 0; i < zone->slope_ranges_count; i++)
|
||||||
{
|
{
|
||||||
toolsSaveDouble(f, &zone->slope_ranges[i].value);
|
packWriteDouble(stream, &zone->slope_ranges[i].value);
|
||||||
toolsSaveDouble(f, &zone->slope_ranges[i].hardmin);
|
packWriteDouble(stream, &zone->slope_ranges[i].hardmin);
|
||||||
toolsSaveDouble(f, &zone->slope_ranges[i].softmin);
|
packWriteDouble(stream, &zone->slope_ranges[i].softmin);
|
||||||
toolsSaveDouble(f, &zone->slope_ranges[i].softmax);
|
packWriteDouble(stream, &zone->slope_ranges[i].softmax);
|
||||||
toolsSaveDouble(f, &zone->slope_ranges[i].hardmax);
|
packWriteDouble(stream, &zone->slope_ranges[i].hardmax);
|
||||||
}
|
}
|
||||||
|
|
||||||
toolsSaveInt(f, &zone->circles_included_count);
|
packWriteInt(stream, &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);
|
packWriteDouble(stream, &zone->circles_included[i].value);
|
||||||
toolsSaveDouble(f, &zone->circles_included[i].centerx);
|
packWriteDouble(stream, &zone->circles_included[i].centerx);
|
||||||
toolsSaveDouble(f, &zone->circles_included[i].centerz);
|
packWriteDouble(stream, &zone->circles_included[i].centerz);
|
||||||
toolsSaveDouble(f, &zone->circles_included[i].softradius);
|
packWriteDouble(stream, &zone->circles_included[i].softradius);
|
||||||
toolsSaveDouble(f, &zone->circles_included[i].hardradius);
|
packWriteDouble(stream, &zone->circles_included[i].hardradius);
|
||||||
}
|
}
|
||||||
|
|
||||||
toolsSaveInt(f, &zone->circles_excluded_count);
|
packWriteInt(stream, &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);
|
packWriteDouble(stream, &zone->circles_excluded[i].value);
|
||||||
toolsSaveDouble(f, &zone->circles_excluded[i].centerx);
|
packWriteDouble(stream, &zone->circles_excluded[i].centerx);
|
||||||
toolsSaveDouble(f, &zone->circles_excluded[i].centerz);
|
packWriteDouble(stream, &zone->circles_excluded[i].centerz);
|
||||||
toolsSaveDouble(f, &zone->circles_excluded[i].softradius);
|
packWriteDouble(stream, &zone->circles_excluded[i].softradius);
|
||||||
toolsSaveDouble(f, &zone->circles_excluded[i].hardradius);
|
packWriteDouble(stream, &zone->circles_excluded[i].hardradius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void zoneLoad(FILE* f, Zone* zone)
|
void zoneLoad(PackStream* stream, Zone* zone)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
toolsLoadInt(f, &zone->height_ranges_count);
|
packReadInt(stream, &zone->height_ranges_count);
|
||||||
for (i = 0; i < zone->height_ranges_count; i++)
|
for (i = 0; i < zone->height_ranges_count; i++)
|
||||||
{
|
{
|
||||||
toolsLoadDouble(f, &zone->height_ranges[i].value);
|
packReadDouble(stream, &zone->height_ranges[i].value);
|
||||||
toolsLoadDouble(f, &zone->height_ranges[i].hardmin);
|
packReadDouble(stream, &zone->height_ranges[i].hardmin);
|
||||||
toolsLoadDouble(f, &zone->height_ranges[i].softmin);
|
packReadDouble(stream, &zone->height_ranges[i].softmin);
|
||||||
toolsLoadDouble(f, &zone->height_ranges[i].softmax);
|
packReadDouble(stream, &zone->height_ranges[i].softmax);
|
||||||
toolsLoadDouble(f, &zone->height_ranges[i].hardmax);
|
packReadDouble(stream, &zone->height_ranges[i].hardmax);
|
||||||
}
|
}
|
||||||
|
|
||||||
toolsLoadInt(f, &zone->slope_ranges_count);
|
packReadInt(stream, &zone->slope_ranges_count);
|
||||||
for (i = 0; i < zone->slope_ranges_count; i++)
|
for (i = 0; i < zone->slope_ranges_count; i++)
|
||||||
{
|
{
|
||||||
toolsLoadDouble(f, &zone->slope_ranges[i].value);
|
packReadDouble(stream, &zone->slope_ranges[i].value);
|
||||||
toolsLoadDouble(f, &zone->slope_ranges[i].hardmin);
|
packReadDouble(stream, &zone->slope_ranges[i].hardmin);
|
||||||
toolsLoadDouble(f, &zone->slope_ranges[i].softmin);
|
packReadDouble(stream, &zone->slope_ranges[i].softmin);
|
||||||
toolsLoadDouble(f, &zone->slope_ranges[i].softmax);
|
packReadDouble(stream, &zone->slope_ranges[i].softmax);
|
||||||
toolsLoadDouble(f, &zone->slope_ranges[i].hardmax);
|
packReadDouble(stream, &zone->slope_ranges[i].hardmax);
|
||||||
}
|
}
|
||||||
|
|
||||||
toolsLoadInt(f, &zone->circles_included_count);
|
packReadInt(stream, &zone->circles_included_count);
|
||||||
for (i = 0; i < zone->circles_included_count; i++)
|
for (i = 0; i < zone->circles_included_count; i++)
|
||||||
{
|
{
|
||||||
toolsLoadDouble(f, &zone->circles_included[i].value);
|
packReadDouble(stream, &zone->circles_included[i].value);
|
||||||
toolsLoadDouble(f, &zone->circles_included[i].centerx);
|
packReadDouble(stream, &zone->circles_included[i].centerx);
|
||||||
toolsLoadDouble(f, &zone->circles_included[i].centerz);
|
packReadDouble(stream, &zone->circles_included[i].centerz);
|
||||||
toolsLoadDouble(f, &zone->circles_included[i].softradius);
|
packReadDouble(stream, &zone->circles_included[i].softradius);
|
||||||
toolsLoadDouble(f, &zone->circles_included[i].hardradius);
|
packReadDouble(stream, &zone->circles_included[i].hardradius);
|
||||||
}
|
}
|
||||||
|
|
||||||
toolsLoadInt(f, &zone->circles_excluded_count);
|
packReadInt(stream, &zone->circles_excluded_count);
|
||||||
for (i = 0; i < zone->circles_excluded_count; i++)
|
for (i = 0; i < zone->circles_excluded_count; i++)
|
||||||
{
|
{
|
||||||
toolsLoadDouble(f, &zone->circles_excluded[i].value);
|
packReadDouble(stream, &zone->circles_excluded[i].value);
|
||||||
toolsLoadDouble(f, &zone->circles_excluded[i].centerx);
|
packReadDouble(stream, &zone->circles_excluded[i].centerx);
|
||||||
toolsLoadDouble(f, &zone->circles_excluded[i].centerz);
|
packReadDouble(stream, &zone->circles_excluded[i].centerz);
|
||||||
toolsLoadDouble(f, &zone->circles_excluded[i].softradius);
|
packReadDouble(stream, &zone->circles_excluded[i].softradius);
|
||||||
toolsLoadDouble(f, &zone->circles_excluded[i].hardradius);
|
packReadDouble(stream, &zone->circles_excluded[i].hardradius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define _PAYSAGES_ZONE_H_
|
#define _PAYSAGES_ZONE_H_
|
||||||
|
|
||||||
#include "shared/types.h"
|
#include "shared/types.h"
|
||||||
|
#include "pack.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -18,8 +19,8 @@ typedef struct
|
||||||
|
|
||||||
Zone* zoneCreate();
|
Zone* zoneCreate();
|
||||||
void zoneDelete(Zone* zone);
|
void zoneDelete(Zone* zone);
|
||||||
void zoneSave(FILE* f, Zone* zone);
|
void zoneSave(PackStream* stream, Zone* zone);
|
||||||
void zoneLoad(FILE* f, Zone* zone);
|
void zoneLoad(PackStream* stream, Zone* zone);
|
||||||
void zoneCopy(Zone* source, Zone* destination);
|
void zoneCopy(Zone* source, Zone* destination);
|
||||||
void zoneIncludeCircleArea(Zone* zone, double value, double centerx, double centerz, double softradius, double hardradius);
|
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 zoneExcludeCircleArea(Zone* zone, double centerx, double centerz, double softradius, double hardradius);
|
||||||
|
|
Loading…
Reference in a new issue