Refactored TexturesDefinition, getting rid of legacy layers
This commit is contained in:
parent
5506158363
commit
fa5c0041af
39 changed files with 823 additions and 1180 deletions
|
@ -1,16 +1,8 @@
|
|||
#include "Layers.h"
|
||||
|
||||
Layers::Layers(BaseDefinition* parent, LayerConstructor layer_constructor, LayerType* legacy_type):
|
||||
Layers::Layers(BaseDefinition* parent, LayerConstructor layer_constructor):
|
||||
BaseDefinition(parent), layer_constructor(layer_constructor)
|
||||
{
|
||||
if (legacy_type)
|
||||
{
|
||||
this->legacy_type = *legacy_type;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->legacy_type.callback_create = NULL;
|
||||
}
|
||||
max_layer_count = 100;
|
||||
null_layer = layer_constructor(this);
|
||||
}
|
||||
|
@ -31,7 +23,6 @@ void Layers::copy(BaseDefinition* destination_) const
|
|||
destination->clear();
|
||||
|
||||
destination->max_layer_count = max_layer_count;
|
||||
destination->legacy_type = legacy_type;
|
||||
|
||||
null_layer->copy(destination->null_layer);
|
||||
|
||||
|
@ -44,6 +35,13 @@ void Layers::copy(BaseDefinition* destination_) const
|
|||
}
|
||||
}
|
||||
|
||||
Layers* Layers::newCopy() const
|
||||
{
|
||||
Layers* result = new Layers(NULL, layer_constructor);
|
||||
copy(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void Layers::setMaxLayerCount(int max_layer_count)
|
||||
{
|
||||
this->max_layer_count = max_layer_count;
|
||||
|
@ -133,129 +131,3 @@ void Layers::clear()
|
|||
removeLayer(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Transitional C-API
|
||||
|
||||
BaseDefinition* _legacyLayerConstructor(Layers* layers)
|
||||
{
|
||||
return new LegacyLayer(layers, &layers->legacy_type);
|
||||
}
|
||||
|
||||
Layers* layersCreate(LayerType type, int max_layer_count)
|
||||
{
|
||||
Layers* result = new Layers(NULL, _legacyLayerConstructor, &type);
|
||||
result->setMaxLayerCount(max_layer_count);
|
||||
return result;
|
||||
}
|
||||
|
||||
Layers* layersCreateCopy(Layers* original)
|
||||
{
|
||||
if (original->legacy_type.callback_create)
|
||||
{
|
||||
Layers* result = new Layers(NULL, _legacyLayerConstructor, &original->legacy_type);
|
||||
original->copy(result);
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
Layers* result = new Layers(NULL, original->layer_constructor, NULL);
|
||||
original->copy(result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
void layersDelete(Layers* layers)
|
||||
{
|
||||
delete layers;
|
||||
}
|
||||
|
||||
void layersCopy(Layers* source, Layers* destination)
|
||||
{
|
||||
source->copy(destination);
|
||||
}
|
||||
|
||||
void layersValidate(Layers* layers)
|
||||
{
|
||||
layers->validate();
|
||||
}
|
||||
|
||||
void layersSave(PackStream* stream, Layers* layers)
|
||||
{
|
||||
layers->save(stream);
|
||||
}
|
||||
|
||||
void layersLoad(PackStream* stream, Layers* layers)
|
||||
{
|
||||
layers->load(stream);
|
||||
}
|
||||
|
||||
const char* layersGetName(Layers* layers, int layer)
|
||||
{
|
||||
if (layers->legacy_type.callback_create)
|
||||
{
|
||||
return ((LegacyLayer*)(layers->getLayer(layer)))->getLegacyName();
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
void layersSetName(Layers* layers, int layer, const char* name)
|
||||
{
|
||||
layers->getLayer(layer)->setName(name);
|
||||
}
|
||||
|
||||
void layersClear(Layers* layers)
|
||||
{
|
||||
layers->clear();
|
||||
}
|
||||
|
||||
int layersCount(Layers* layers)
|
||||
{
|
||||
return layers->count();
|
||||
}
|
||||
|
||||
void* layersGetLayer(Layers* layers, int layer)
|
||||
{
|
||||
if (layers->legacy_type.callback_create)
|
||||
{
|
||||
LegacyLayer* legacy = (LegacyLayer*)(layers->getLayer(layer));
|
||||
return legacy->getLegacyDefinition();
|
||||
}
|
||||
else
|
||||
{
|
||||
return layers->getLayer(layer);
|
||||
}
|
||||
}
|
||||
|
||||
int layersAddLayer(Layers* layers, void* definition)
|
||||
{
|
||||
if (layers->legacy_type.callback_create)
|
||||
{
|
||||
int position;
|
||||
LegacyLayer* legacy = new LegacyLayer(layers, &layers->legacy_type);
|
||||
if (definition)
|
||||
{
|
||||
layers->legacy_type.callback_copy(definition, legacy->getLegacyDefinition());
|
||||
}
|
||||
position = layers->addLayer(legacy);
|
||||
return position;
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseDefinition* copied = layers->layer_constructor(layers);
|
||||
((BaseDefinition*)definition)->copy(copied);
|
||||
return layers->addLayer(copied);
|
||||
}
|
||||
}
|
||||
|
||||
void layersDeleteLayer(Layers* layers, int layer)
|
||||
{
|
||||
layers->removeLayer(layer);
|
||||
}
|
||||
|
||||
void layersMove(Layers* layers, int layer, int new_position)
|
||||
{
|
||||
layers->moveLayer(layer, new_position);
|
||||
}
|
||||
|
|
|
@ -2,15 +2,12 @@
|
|||
#define LAYERS_H
|
||||
|
||||
#include "definition_global.h"
|
||||
|
||||
#include "BaseDefinition.h"
|
||||
#include "LegacyLayer.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace system {class PackStream;}
|
||||
namespace definition {
|
||||
|
||||
class Layers;
|
||||
|
||||
typedef BaseDefinition* (*LayerConstructor)(Layers* parent);
|
||||
|
||||
/**
|
||||
|
@ -19,10 +16,11 @@ typedef BaseDefinition* (*LayerConstructor)(Layers* parent);
|
|||
class DEFINITIONSHARED_EXPORT Layers:public BaseDefinition
|
||||
{
|
||||
public:
|
||||
Layers(BaseDefinition* parent, LayerConstructor layer_constructor, LayerType* legacy_type=0);
|
||||
Layers(BaseDefinition* parent, LayerConstructor layer_constructor);
|
||||
virtual ~Layers();
|
||||
|
||||
virtual void copy(BaseDefinition* destination) const override;
|
||||
Layers* newCopy() const;
|
||||
|
||||
void setMaxLayerCount(int max_layer_count);
|
||||
|
||||
|
@ -45,12 +43,8 @@ public:
|
|||
void moveLayer(BaseDefinition* layer, int new_position);
|
||||
void clear();
|
||||
|
||||
// Transitional data storage
|
||||
LayerType legacy_type;
|
||||
// TODO make private when there is no more legacy layer
|
||||
LayerConstructor layer_constructor;
|
||||
|
||||
public:
|
||||
LayerConstructor layer_constructor;
|
||||
int max_layer_count;
|
||||
QList<BaseDefinition*> layers;
|
||||
BaseDefinition* null_layer;
|
||||
|
@ -59,24 +53,4 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
DEFINITIONSHARED_EXPORT Layers* layersCreate(LayerType type, int max_layer_count);
|
||||
DEFINITIONSHARED_EXPORT Layers* layersCreateCopy(Layers* original);
|
||||
DEFINITIONSHARED_EXPORT void layersDelete(Layers* layers);
|
||||
|
||||
DEFINITIONSHARED_EXPORT void layersCopy(Layers* source, Layers* destination);
|
||||
DEFINITIONSHARED_EXPORT void layersValidate(Layers* layers);
|
||||
|
||||
DEFINITIONSHARED_EXPORT void layersSave(PackStream* stream, Layers* layers);
|
||||
DEFINITIONSHARED_EXPORT void layersLoad(PackStream* stream, Layers* layers);
|
||||
|
||||
DEFINITIONSHARED_EXPORT const char* layersGetName(Layers* layers, int layer);
|
||||
DEFINITIONSHARED_EXPORT void layersSetName(Layers* layers, int layer, const char* name);
|
||||
|
||||
DEFINITIONSHARED_EXPORT void layersClear(Layers* layers);
|
||||
DEFINITIONSHARED_EXPORT int layersCount(Layers* layers);
|
||||
DEFINITIONSHARED_EXPORT void* layersGetLayer(Layers* layers, int layer);
|
||||
DEFINITIONSHARED_EXPORT int layersAddLayer(Layers* layers, void* definition);
|
||||
DEFINITIONSHARED_EXPORT void layersDeleteLayer(Layers* layers, int layer);
|
||||
DEFINITIONSHARED_EXPORT void layersMove(Layers* layers, int layer, int new_position);
|
||||
|
||||
#endif // LAYERS_H
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
#include "LegacyLayer.h"
|
||||
|
||||
LegacyLayer::LegacyLayer(BaseDefinition* parent, LayerType* type):
|
||||
BaseDefinition(parent), type(*type)
|
||||
{
|
||||
legacy = type->callback_create();
|
||||
setName(getName());
|
||||
}
|
||||
|
||||
LegacyLayer::~LegacyLayer()
|
||||
{
|
||||
type.callback_delete(legacy);
|
||||
}
|
||||
|
||||
void LegacyLayer::save(PackStream* pack) const
|
||||
{
|
||||
BaseDefinition::save(pack);
|
||||
type.callback_save(pack, legacy);
|
||||
}
|
||||
|
||||
void LegacyLayer::load(PackStream* pack)
|
||||
{
|
||||
BaseDefinition::load(pack);
|
||||
type.callback_load(pack, legacy);
|
||||
}
|
||||
|
||||
void LegacyLayer::copy(BaseDefinition* destination) const
|
||||
{
|
||||
BaseDefinition::copy(destination);
|
||||
type.callback_copy(legacy, ((LegacyLayer*)destination)->legacy);
|
||||
}
|
||||
|
||||
void LegacyLayer::validate()
|
||||
{
|
||||
BaseDefinition::validate();
|
||||
type.callback_validate(legacy);
|
||||
}
|
||||
|
||||
void LegacyLayer::setName(QString name)
|
||||
{
|
||||
BaseDefinition::setName(name);
|
||||
qstrncpy(legacy_name, name.toUtf8().constData(), 99);
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
#ifndef LEGACYLAYER_H
|
||||
#define LEGACYLAYER_H
|
||||
|
||||
#include <BaseDefinition.h>
|
||||
|
||||
namespace paysages {
|
||||
namespace system {class PackStream;}
|
||||
namespace definition {
|
||||
|
||||
typedef void* (*LayerCallbackCreate)();
|
||||
typedef void (*LayerCallbackDelete)(void* layer);
|
||||
typedef void (*LayerCallbackCopy)(void* source, void* definition);
|
||||
typedef void (*LayerCallbackValidate)(void* layer);
|
||||
typedef void (*LayerCallbackSave)(PackStream* stream, void* layer);
|
||||
typedef void (*LayerCallbackLoad)(PackStream* stream, void* layer);
|
||||
|
||||
typedef struct {
|
||||
LayerCallbackCreate callback_create;
|
||||
LayerCallbackDelete callback_delete;
|
||||
LayerCallbackCopy callback_copy;
|
||||
LayerCallbackValidate callback_validate;
|
||||
LayerCallbackSave callback_save;
|
||||
LayerCallbackLoad callback_load;
|
||||
} LayerType;
|
||||
|
||||
/**
|
||||
* @brief Wrapper around the old LayerType, used by C code.
|
||||
*/
|
||||
class LegacyLayer:public BaseDefinition
|
||||
{
|
||||
public:
|
||||
LegacyLayer(BaseDefinition* parent, LayerType* type);
|
||||
virtual ~LegacyLayer();
|
||||
|
||||
virtual void save(PackStream* pack) const;
|
||||
virtual void load(PackStream* pack);
|
||||
|
||||
virtual void copy(BaseDefinition* destination) const;
|
||||
virtual void validate();
|
||||
|
||||
virtual void setName(QString name);
|
||||
|
||||
inline void* getLegacyDefinition() { return legacy; }
|
||||
inline char* getLegacyName() {return legacy_name;}
|
||||
|
||||
private:
|
||||
LayerType type;
|
||||
void* legacy;
|
||||
char legacy_name[100];
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // LEGACYLAYER_H
|
154
src/definition/TextureLayerDefinition.cpp
Normal file
154
src/definition/TextureLayerDefinition.cpp
Normal file
|
@ -0,0 +1,154 @@
|
|||
#include "TextureLayerDefinition.h"
|
||||
|
||||
#include "Zone.h"
|
||||
#include "NoiseGenerator.h"
|
||||
#include "SurfaceMaterial.h"
|
||||
#include "PackStream.h"
|
||||
|
||||
TextureLayerDefinition::TextureLayerDefinition(BaseDefinition* parent):
|
||||
BaseDefinition(parent)
|
||||
{
|
||||
terrain_zone = new Zone;
|
||||
_displacement_noise = new NoiseGenerator;
|
||||
_detail_noise = new NoiseGenerator;
|
||||
material = new SurfaceMaterial;
|
||||
}
|
||||
|
||||
TextureLayerDefinition::~TextureLayerDefinition()
|
||||
{
|
||||
delete terrain_zone;
|
||||
delete _displacement_noise;
|
||||
delete _detail_noise;
|
||||
delete material;
|
||||
}
|
||||
|
||||
void TextureLayerDefinition::validate()
|
||||
{
|
||||
if (displacement_scaling < 0.000001)
|
||||
{
|
||||
displacement_scaling = 0.000001;
|
||||
}
|
||||
|
||||
_displacement_noise->clearLevels();
|
||||
_displacement_noise->addLevelsSimple(9, 1.0, -1.0, 1.0, 0.0);
|
||||
_displacement_noise->normalizeAmplitude(-1.0, 1.0, 0);
|
||||
_displacement_noise->validate();
|
||||
|
||||
_detail_noise->clearLevels();
|
||||
_detail_noise->addLevelsSimple(7, 0.01, -1.0, 1.0, 0.0);
|
||||
_detail_noise->normalizeAmplitude(-0.008, 0.008, 0);
|
||||
_detail_noise->validate();
|
||||
|
||||
materialValidate(material);
|
||||
|
||||
/* Update zone height range */
|
||||
// TODO
|
||||
/*TerrainDefinition* terrain = Scenery::getCurrent()->getTerrain();
|
||||
if (terrain)
|
||||
{
|
||||
HeightInfo height_info = terrainGetHeightInfo(terrain);
|
||||
zoneSetRelativeHeight(terrain_zone, height_info.min_height, height_info.base_height, height_info.max_height);
|
||||
}*/
|
||||
}
|
||||
|
||||
void TextureLayerDefinition::copy(BaseDefinition *_destination) const
|
||||
{
|
||||
TextureLayerDefinition* destination = (TextureLayerDefinition*)_destination;
|
||||
|
||||
terrain_zone->copy(destination->terrain_zone);
|
||||
|
||||
destination->displacement_scaling = displacement_scaling;
|
||||
destination->displacement_height = displacement_height;
|
||||
destination->displacement_offset = displacement_offset;
|
||||
*destination->material = *material;
|
||||
|
||||
_displacement_noise->copy(destination->_displacement_noise);
|
||||
_detail_noise->copy(destination->_detail_noise);
|
||||
}
|
||||
|
||||
void TextureLayerDefinition::save(PackStream* stream) const
|
||||
{
|
||||
terrain_zone->save(stream);
|
||||
stream->write(&displacement_scaling);
|
||||
stream->write(&displacement_height);
|
||||
stream->write(&displacement_offset);
|
||||
materialSave(stream, material);
|
||||
|
||||
_displacement_noise->save(stream);
|
||||
_detail_noise->save(stream);
|
||||
}
|
||||
|
||||
void TextureLayerDefinition::load(PackStream* stream)
|
||||
{
|
||||
terrain_zone->load(stream);
|
||||
stream->read(&displacement_scaling);
|
||||
stream->read(&displacement_height);
|
||||
stream->read(&displacement_offset);
|
||||
materialLoad(stream, material);
|
||||
|
||||
_displacement_noise->load(stream);
|
||||
_detail_noise->load(stream);
|
||||
}
|
||||
|
||||
void TextureLayerDefinition::applyPreset(TextureLayerPreset preset)
|
||||
{
|
||||
_displacement_noise->randomizeOffsets();
|
||||
_detail_noise->randomizeOffsets();
|
||||
|
||||
terrain_zone->clear();
|
||||
|
||||
switch (preset)
|
||||
{
|
||||
case TEXTURES_LAYER_PRESET_MUD:
|
||||
displacement_height = 0.05;
|
||||
displacement_scaling = 3.0;
|
||||
displacement_offset = 0.0;
|
||||
material->base = colorToHSL(colorFromValues(0.4, 0.38, 0.35, 1.0));
|
||||
material->reflection = 0.003;
|
||||
material->shininess = 4.0;
|
||||
break;
|
||||
case TEXTURES_LAYER_PRESET_ROCK:
|
||||
terrain_zone->addHeightRangeQuick(1.0, 0.5, 0.55, 1.0, 1.0);
|
||||
displacement_height = 0.3;
|
||||
displacement_scaling = 2.0;
|
||||
displacement_offset = 0.0;
|
||||
material->base = colorToHSL(colorFromValues(0.6, 0.55, 0.57, 1.0));
|
||||
material->reflection = 0.006;
|
||||
material->shininess = 6.0;
|
||||
break;
|
||||
case TEXTURES_LAYER_PRESET_GRASS:
|
||||
terrain_zone->addHeightRangeQuick(1.0, 0.45, 0.5, 0.8, 1.0);
|
||||
terrain_zone->addSlopeRangeQuick(1.0, 0.0, 0.0, 0.05, 0.4);
|
||||
displacement_height = 0.0;
|
||||
displacement_scaling = 1.0;
|
||||
displacement_offset = 0.0;
|
||||
material->base = colorToHSL(colorFromValues(0.12, 0.19, 0.035, 1.0));
|
||||
material->reflection = 0.001;
|
||||
material->shininess = 4.0;
|
||||
break;
|
||||
case TEXTURES_LAYER_PRESET_SAND:
|
||||
terrain_zone->addHeightRangeQuick(1.0, 0.498, 0.502, 0.505, 0.51);
|
||||
terrain_zone->addSlopeRangeQuick(1.0, 0.0, 0.0, 0.7, 0.1);
|
||||
displacement_height = 0.02;
|
||||
displacement_scaling = 5.0;
|
||||
displacement_offset = 0.0;
|
||||
material->base = colorToHSL(colorFromValues(0.93, 0.9, 0.8, 1.0));
|
||||
material->reflection = 0.008;
|
||||
material->shininess = 1.0;
|
||||
break;
|
||||
case TEXTURES_LAYER_PRESET_SNOW:
|
||||
terrain_zone->addHeightRangeQuick(1.0, 0.77, 0.85, 1.0, 1.0);
|
||||
terrain_zone->addSlopeRangeQuick(1.0, 0.0, 0.0, 0.2, 1.0);
|
||||
displacement_height = 0.1;
|
||||
displacement_scaling = 1.0;
|
||||
displacement_offset = 0.0;
|
||||
material->base = colorToHSL(colorFromValues(1.0, 1.0, 1.0, 1.0));
|
||||
material->reflection = 0.25;
|
||||
material->shininess = 0.6;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
validate();
|
||||
}
|
60
src/definition/TextureLayerDefinition.h
Normal file
60
src/definition/TextureLayerDefinition.h
Normal file
|
@ -0,0 +1,60 @@
|
|||
#ifndef TEXTURELAYERDEFINITION_H
|
||||
#define TEXTURELAYERDEFINITION_H
|
||||
|
||||
#include "definition_global.h"
|
||||
|
||||
#include "BaseDefinition.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace definition {
|
||||
|
||||
class DEFINITIONSHARED_EXPORT TextureLayerDefinition : public BaseDefinition
|
||||
{
|
||||
public:
|
||||
typedef enum
|
||||
{
|
||||
TEXTURES_MERGE_FADE,
|
||||
TEXTURES_MERGE_DISSOLVE,
|
||||
TEXTURES_MERGE_DISPLACEMENT_VALUE
|
||||
} TextureMergeMode;
|
||||
typedef enum
|
||||
{
|
||||
TEXTURES_LAYER_PRESET_MUD,
|
||||
TEXTURES_LAYER_PRESET_ROCK,
|
||||
TEXTURES_LAYER_PRESET_GRASS,
|
||||
TEXTURES_LAYER_PRESET_SAND,
|
||||
TEXTURES_LAYER_PRESET_SNOW
|
||||
} TextureLayerPreset;
|
||||
|
||||
public:
|
||||
TextureLayerDefinition(BaseDefinition* parent);
|
||||
virtual ~TextureLayerDefinition();
|
||||
|
||||
virtual void save(PackStream* stream) const override;
|
||||
virtual void load(PackStream* stream) override;
|
||||
|
||||
virtual void copy(BaseDefinition* destination) const override;
|
||||
virtual void validate() override;
|
||||
|
||||
void applyPreset(TextureLayerPreset preset);
|
||||
|
||||
public:
|
||||
Zone* terrain_zone;
|
||||
double displacement_scaling;
|
||||
double displacement_height;
|
||||
double displacement_offset;
|
||||
/*double detail_scaling;
|
||||
double detail_height;*/
|
||||
SurfaceMaterial* material;
|
||||
/*double cancel_displacement_factor;
|
||||
TexturesMergeMode merge_mode;*/
|
||||
|
||||
NoiseGenerator* _displacement_noise;
|
||||
NoiseGenerator* _detail_noise;
|
||||
/*Curve* _local_slope_condition;*/
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // TEXTURELAYERDEFINITION_H
|
66
src/definition/TexturesDefinition.cpp
Normal file
66
src/definition/TexturesDefinition.cpp
Normal file
|
@ -0,0 +1,66 @@
|
|||
#include "TexturesDefinition.h"
|
||||
|
||||
#include "TextureLayerDefinition.h"
|
||||
|
||||
static BaseDefinition* _layer_constructor(Layers* parent)
|
||||
{
|
||||
return new TextureLayerDefinition(parent);
|
||||
}
|
||||
|
||||
TexturesDefinition::TexturesDefinition(BaseDefinition *parent)
|
||||
: Layers(parent, _layer_constructor)
|
||||
{
|
||||
}
|
||||
|
||||
void TexturesDefinition::applyPreset(TexturesPreset preset)
|
||||
{
|
||||
TextureLayerDefinition* layer;
|
||||
clear();
|
||||
|
||||
layer = getTextureLayer(addLayer());
|
||||
layer->applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_MUD);
|
||||
layer->setName("Mud");
|
||||
|
||||
if (preset == TEXTURES_PRESET_FULL)
|
||||
{
|
||||
layer = getTextureLayer(addLayer());
|
||||
layer->applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_ROCK);
|
||||
layer->setName("Ground");
|
||||
|
||||
layer = getTextureLayer(addLayer());
|
||||
layer->applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_GRASS);
|
||||
layer->setName("Grass");
|
||||
|
||||
layer = getTextureLayer(addLayer());
|
||||
layer->applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_SAND);
|
||||
layer->setName("Sand");
|
||||
|
||||
layer = getTextureLayer(addLayer());
|
||||
layer->applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_SNOW);
|
||||
layer->setName("Snow");
|
||||
}
|
||||
else if (preset == TEXTURES_PRESET_IRELAND)
|
||||
{
|
||||
layer = getTextureLayer(addLayer());
|
||||
layer->applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_ROCK);
|
||||
layer->setName("Ground");
|
||||
|
||||
layer = getTextureLayer(addLayer());
|
||||
layer->applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_GRASS);
|
||||
layer->setName("Grass");
|
||||
}
|
||||
else if (preset == TEXTURES_PRESET_ALPS)
|
||||
{
|
||||
layer = getTextureLayer(addLayer());
|
||||
layer->applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_ROCK);
|
||||
layer->setName("Ground");
|
||||
|
||||
layer = getTextureLayer(addLayer());
|
||||
layer->applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_SNOW);
|
||||
layer->setName("Snow");
|
||||
}
|
||||
else if (preset == TEXTURES_PRESET_CANYON)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
}
|
31
src/definition/TexturesDefinition.h
Normal file
31
src/definition/TexturesDefinition.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
#ifndef TEXTURESDEFINITION_H
|
||||
#define TEXTURESDEFINITION_H
|
||||
|
||||
#include "definition_global.h"
|
||||
|
||||
#include "Layers.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace definition {
|
||||
|
||||
class DEFINITIONSHARED_EXPORT TexturesDefinition : public Layers
|
||||
{
|
||||
public:
|
||||
TexturesDefinition(BaseDefinition *parent);
|
||||
|
||||
inline TextureLayerDefinition* getTextureLayer(int position) const {return (TextureLayerDefinition*)getLayer(position);}
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TEXTURES_PRESET_FULL,
|
||||
TEXTURES_PRESET_IRELAND,
|
||||
TEXTURES_PRESET_ALPS,
|
||||
TEXTURES_PRESET_CANYON
|
||||
} TexturesPreset;
|
||||
void applyPreset(TexturesPreset preset);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // TEXTURESDEFINITION_H
|
278
src/definition/Zone.cpp
Normal file
278
src/definition/Zone.cpp
Normal file
|
@ -0,0 +1,278 @@
|
|||
#include "Zone.h"
|
||||
|
||||
#include "Curve.h"
|
||||
#include "PackStream.h"
|
||||
#include "Vector3.h"
|
||||
|
||||
#define MAX_CIRCLES 10
|
||||
|
||||
namespace paysages {
|
||||
namespace definition {
|
||||
class Circle
|
||||
{
|
||||
public:
|
||||
double value;
|
||||
double centerx;
|
||||
double centerz;
|
||||
double softradius;
|
||||
double hardradius;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Zone::Zone(BaseDefinition *parent):
|
||||
BaseDefinition(parent)
|
||||
{
|
||||
value_by_height = new Curve;
|
||||
absolute_height = 1;
|
||||
value_by_height->setDefault(1.0);
|
||||
value_by_slope = new Curve;
|
||||
value_by_slope->setDefault(1.0);
|
||||
circles_included_count = 0;
|
||||
circles_included = new Circle[MAX_CIRCLES];
|
||||
}
|
||||
|
||||
Zone::~Zone()
|
||||
{
|
||||
delete value_by_height;
|
||||
delete value_by_slope;
|
||||
delete circles_included;
|
||||
}
|
||||
|
||||
void Zone::save(PackStream* stream) const
|
||||
{
|
||||
int i;
|
||||
|
||||
stream->write(&absolute_height);
|
||||
stream->write(&relative_height_min);
|
||||
stream->write(&relative_height_middle);
|
||||
stream->write(&relative_height_max);
|
||||
|
||||
value_by_height->save(stream);
|
||||
value_by_slope->save(stream);
|
||||
|
||||
stream->write(&circles_included_count);
|
||||
for (i = 0; i < circles_included_count; i++)
|
||||
{
|
||||
stream->write(&circles_included[i].value);
|
||||
stream->write(&circles_included[i].centerx);
|
||||
stream->write(&circles_included[i].centerz);
|
||||
stream->write(&circles_included[i].softradius);
|
||||
stream->write(&circles_included[i].hardradius);
|
||||
}
|
||||
}
|
||||
|
||||
void Zone::load(PackStream* stream)
|
||||
{
|
||||
int i;
|
||||
|
||||
stream->read(&absolute_height);
|
||||
stream->read(&relative_height_min);
|
||||
stream->read(&relative_height_middle);
|
||||
stream->read(&relative_height_max);
|
||||
|
||||
value_by_height->load(stream);
|
||||
value_by_slope->load(stream);
|
||||
|
||||
stream->read(&circles_included_count);
|
||||
for (i = 0; i < circles_included_count; i++)
|
||||
{
|
||||
stream->read(&circles_included[i].value);
|
||||
stream->read(&circles_included[i].centerx);
|
||||
stream->read(&circles_included[i].centerz);
|
||||
stream->read(&circles_included[i].softradius);
|
||||
stream->read(&circles_included[i].hardradius);
|
||||
}
|
||||
}
|
||||
|
||||
void Zone::copy(BaseDefinition* _destination) const
|
||||
{
|
||||
Zone* destination = (Zone*)_destination;
|
||||
|
||||
destination->absolute_height = absolute_height;
|
||||
destination->relative_height_min = relative_height_min;
|
||||
destination->relative_height_middle = relative_height_middle;
|
||||
destination->relative_height_max = relative_height_max;
|
||||
|
||||
value_by_height->copy(destination->value_by_height);
|
||||
value_by_slope->copy(destination->value_by_slope);
|
||||
|
||||
memcpy(destination->circles_included, circles_included, sizeof(Circle) * circles_included_count);
|
||||
destination->circles_included_count = circles_included_count;
|
||||
}
|
||||
|
||||
void Zone::clear()
|
||||
{
|
||||
value_by_height->clear();
|
||||
value_by_slope->clear();
|
||||
circles_included_count = 0;
|
||||
}
|
||||
|
||||
void Zone::setAbsoluteHeight()
|
||||
{
|
||||
absolute_height = 1;
|
||||
}
|
||||
|
||||
void Zone::setRelativeHeight(double min, double middle, double max)
|
||||
{
|
||||
if (max < min)
|
||||
{
|
||||
max = min;
|
||||
}
|
||||
if (middle < min)
|
||||
{
|
||||
middle = min;
|
||||
}
|
||||
if (middle > max)
|
||||
{
|
||||
middle = max;
|
||||
}
|
||||
|
||||
absolute_height = 0;
|
||||
relative_height_min = min;
|
||||
relative_height_middle = middle;
|
||||
relative_height_max = max;
|
||||
}
|
||||
|
||||
void Zone::includeCircleArea(double value, double centerx, double centerz, double softradius, double hardradius)
|
||||
{
|
||||
Circle circle = {value, centerx, centerz, softradius, hardradius};
|
||||
|
||||
if (circles_included_count < MAX_CIRCLES)
|
||||
{
|
||||
circles_included[circles_included_count++] = circle;
|
||||
}
|
||||
}
|
||||
|
||||
void Zone::getHeightCurve(Curve* curve) const
|
||||
{
|
||||
value_by_height->copy(curve);
|
||||
}
|
||||
|
||||
void Zone::setHeightCurve(Curve* curve)
|
||||
{
|
||||
curve->copy(value_by_height);
|
||||
}
|
||||
|
||||
void Zone::addHeightRangeQuick(double value, double hardmin, double softmin, double softmax, double hardmax)
|
||||
{
|
||||
value_by_height->addPoint(hardmin, 0.0);
|
||||
value_by_height->addPoint(softmin, value);
|
||||
value_by_height->addPoint(softmax, value);
|
||||
value_by_height->addPoint(hardmax, 0.0);
|
||||
}
|
||||
|
||||
void Zone::getSlopeCurve(Curve* curve) const
|
||||
{
|
||||
value_by_slope->copy(curve);
|
||||
}
|
||||
|
||||
void Zone::setSlopeCurve(Curve* curve)
|
||||
{
|
||||
curve->copy(value_by_slope);
|
||||
}
|
||||
|
||||
void Zone::addSlopeRangeQuick(double value, double hardmin, double softmin, double softmax, double hardmax)
|
||||
{
|
||||
value_by_slope->addPoint(hardmin, 0.0);
|
||||
value_by_slope->addPoint(softmin, value);
|
||||
value_by_slope->addPoint(softmax, value);
|
||||
value_by_slope->addPoint(hardmax, 0.0);
|
||||
}
|
||||
|
||||
static inline double _getCircleInfluence(const Circle &circle, const Vector3 &position)
|
||||
{
|
||||
double radius, dx, dz;
|
||||
|
||||
dx = position.x - circle.centerx;
|
||||
dz = position.z - circle.centerz;
|
||||
radius = sqrt(dx * dx + dz * dz);
|
||||
|
||||
if (radius > circle.hardradius)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
else if (radius < circle.softradius)
|
||||
{
|
||||
return circle.value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return circle.value * (circle.hardradius - radius) / (circle.hardradius - circle.softradius);
|
||||
}
|
||||
}
|
||||
|
||||
double Zone::getValue(const Vector3 &location, const Vector3 &normal) const
|
||||
{
|
||||
int i;
|
||||
double final_height;
|
||||
double value, value_height, value_steepness, value_circle;
|
||||
|
||||
if (circles_included_count > 0)
|
||||
{
|
||||
value_circle = 0.0;
|
||||
for (i = 0; i < circles_included_count; i++)
|
||||
{
|
||||
value = _getCircleInfluence(circles_included[i], location);
|
||||
if (value > value_circle)
|
||||
{
|
||||
value_circle = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value_circle = 1.0;
|
||||
}
|
||||
|
||||
if (absolute_height)
|
||||
{
|
||||
final_height = location.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (location.y >= relative_height_max)
|
||||
{
|
||||
final_height = 1.0;
|
||||
}
|
||||
else if (location.y <= relative_height_min)
|
||||
{
|
||||
final_height = 0.0;
|
||||
}
|
||||
else if (location.y <= relative_height_middle)
|
||||
{
|
||||
final_height = 0.5 * (location.y - relative_height_min) / (relative_height_middle - relative_height_min);
|
||||
}
|
||||
else
|
||||
{
|
||||
final_height = 0.5 + 0.5 * (location.y - relative_height_middle) / (relative_height_max - relative_height_middle);
|
||||
}
|
||||
}
|
||||
|
||||
value_height = value_by_height->getValue(final_height);
|
||||
value_steepness = value_by_slope->getValue(1.0 - normal.y);
|
||||
|
||||
if (value_steepness < value_height)
|
||||
{
|
||||
if (value_circle < value_steepness)
|
||||
{
|
||||
return value_circle;
|
||||
}
|
||||
else
|
||||
{
|
||||
return value_steepness;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value_circle < value_height)
|
||||
{
|
||||
return value_circle;
|
||||
}
|
||||
else
|
||||
{
|
||||
return value_height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
58
src/definition/Zone.h
Normal file
58
src/definition/Zone.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
#ifndef ZONE_H
|
||||
#define ZONE_H
|
||||
|
||||
#include "definition_global.h"
|
||||
|
||||
#include "BaseDefinition.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace definition {
|
||||
|
||||
class Circle;
|
||||
|
||||
class DEFINITIONSHARED_EXPORT Zone : public BaseDefinition
|
||||
{
|
||||
public:
|
||||
Zone(BaseDefinition *parent = 0);
|
||||
virtual ~Zone();
|
||||
|
||||
virtual void save(PackStream* stream) const override;
|
||||
virtual void load(PackStream* stream) override;
|
||||
|
||||
virtual void copy(BaseDefinition* destination) const override;
|
||||
|
||||
void clear();
|
||||
|
||||
void setAbsoluteHeight();
|
||||
void setRelativeHeight(double min, double middle, double max);
|
||||
|
||||
void includeCircleArea(double value, double centerx, double centerz, double softradius, double hardradius);
|
||||
void excludeCircleArea(double centerx, double centerz, double softradius, double hardradius);
|
||||
|
||||
void getHeightCurve(Curve* curve) const;
|
||||
void setHeightCurve(Curve* curve);
|
||||
void addHeightRangeQuick(double value, double hardmin, double softmin, double softmax, double hardmax);
|
||||
|
||||
void getSlopeCurve(Curve* curve) const;
|
||||
void setSlopeCurve(Curve* curve);
|
||||
void addSlopeRangeQuick(double value, double hardmin, double softmin, double softmax, double hardmax);
|
||||
|
||||
double getValue(const Vector3 &location, const Vector3 &normal) const;
|
||||
|
||||
private:
|
||||
int absolute_height;
|
||||
double relative_height_min;
|
||||
double relative_height_middle;
|
||||
double relative_height_max;
|
||||
|
||||
Curve* value_by_height;
|
||||
Curve* value_by_slope;
|
||||
|
||||
Circle* circles_included;
|
||||
int circles_included_count;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ZONE_H
|
|
@ -16,25 +16,29 @@ include(../common.pri)
|
|||
SOURCES += \
|
||||
BaseDefinition.cpp \
|
||||
Layers.cpp \
|
||||
LegacyLayer.cpp \
|
||||
WaterDefinition.cpp \
|
||||
SurfaceMaterial.cpp \
|
||||
CameraDefinition.cpp \
|
||||
CloudsDefinition.cpp \
|
||||
CloudLayerDefinition.cpp \
|
||||
AtmosphereDefinition.cpp
|
||||
AtmosphereDefinition.cpp \
|
||||
TexturesDefinition.cpp \
|
||||
TextureLayerDefinition.cpp \
|
||||
Zone.cpp
|
||||
|
||||
HEADERS +=\
|
||||
definition_global.h \
|
||||
BaseDefinition.h \
|
||||
Layers.h \
|
||||
LegacyLayer.h \
|
||||
WaterDefinition.h \
|
||||
SurfaceMaterial.h \
|
||||
CameraDefinition.h \
|
||||
CloudsDefinition.h \
|
||||
CloudLayerDefinition.h \
|
||||
AtmosphereDefinition.h
|
||||
AtmosphereDefinition.h \
|
||||
TexturesDefinition.h \
|
||||
TextureLayerDefinition.h \
|
||||
Zone.h
|
||||
|
||||
unix:!symbian {
|
||||
maemo5 {
|
||||
|
|
|
@ -15,11 +15,14 @@ namespace definition {
|
|||
class BaseDefinition;
|
||||
class CameraDefinition;
|
||||
class SurfaceMaterial;
|
||||
class Zone;
|
||||
class WaterDefinition;
|
||||
class Layers;
|
||||
class CloudsDefinition;
|
||||
class CloudLayerDefinition;
|
||||
class AtmosphereDefinition;
|
||||
class TexturesDefinition;
|
||||
class TextureLayerDefinition;
|
||||
}
|
||||
}
|
||||
using namespace paysages::definition;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "baseformlayer.h"
|
||||
|
||||
#include <QInputDialog>
|
||||
#include "Layers.h"
|
||||
|
||||
BaseFormLayer::BaseFormLayer(QWidget* parent, Layers* layers) : BaseForm(parent, false, true)
|
||||
{
|
||||
|
@ -9,7 +10,7 @@ BaseFormLayer::BaseFormLayer(QWidget* parent, Layers* layers) : BaseForm(parent,
|
|||
if (layers)
|
||||
{
|
||||
_layers_original = layers;
|
||||
_layers_modified = layersCreateCopy(_layers_original);
|
||||
_layers_modified = _layers_original->newCopy();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +18,7 @@ BaseFormLayer::~BaseFormLayer()
|
|||
{
|
||||
if (_layers_modified)
|
||||
{
|
||||
layersDelete(_layers_modified);
|
||||
delete _layers_modified;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +26,7 @@ void BaseFormLayer::revertConfig()
|
|||
{
|
||||
if (_layers_original && _layers_modified)
|
||||
{
|
||||
layersCopy(_layers_original, _layers_modified);
|
||||
_layers_original->copy(_layers_modified);
|
||||
layerSelectedEvent(currentLayer());
|
||||
}
|
||||
|
||||
|
@ -36,7 +37,7 @@ void BaseFormLayer::applyConfig()
|
|||
{
|
||||
if (_layers_original && _layers_modified)
|
||||
{
|
||||
layersCopy(_layers_modified, _layers_original);
|
||||
_layers_modified->copy(_layers_original);
|
||||
}
|
||||
|
||||
BaseForm::applyConfig();
|
||||
|
@ -47,9 +48,9 @@ void BaseFormLayer::setLayers(Layers* layers)
|
|||
_layers_original = layers;
|
||||
if (_layers_modified)
|
||||
{
|
||||
layersDelete(_layers_modified);
|
||||
delete _layers_modified;
|
||||
}
|
||||
_layers_modified = layersCreateCopy(_layers_original);
|
||||
_layers_modified = _layers_original->newCopy();
|
||||
revertConfig();
|
||||
}
|
||||
|
||||
|
@ -61,8 +62,8 @@ void BaseFormLayer::configChangeEvent()
|
|||
{
|
||||
if (_layers_modified)
|
||||
{
|
||||
layerWriteCurrentTo(layersGetLayer(_layers_modified, currentLayer()));
|
||||
layersValidate(_layers_modified);
|
||||
layerWriteCurrentTo(_layers_modified->getLayer(currentLayer()));
|
||||
_layers_modified->validate();
|
||||
}
|
||||
|
||||
BaseForm::configChangeEvent();
|
||||
|
@ -74,9 +75,9 @@ QStringList BaseFormLayer::getLayers()
|
|||
|
||||
if (_layers_modified)
|
||||
{
|
||||
for (int i = 0; i < layersCount(_layers_modified); i++)
|
||||
for (int i = 0; i < _layers_modified->count(); i++)
|
||||
{
|
||||
result << QString::fromUtf8(layersGetName(_layers_modified, i));
|
||||
result << _layers_modified->getLayer(i)->getName();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,14 +91,14 @@ void BaseFormLayer::layerAddedEvent()
|
|||
QString layer_name = QInputDialog::getText(this, tr("Create layer"), tr("Layer name :"), QLineEdit::Normal, tr("Unnamed layer"));
|
||||
if (not layer_name.isEmpty())
|
||||
{
|
||||
int layer = layersAddLayer(_layers_modified, NULL);
|
||||
int layer = _layers_modified->addLayer();
|
||||
if (layer >= 0)
|
||||
{
|
||||
layersSetName(_layers_modified, layer, layer_name.toUtf8().data());
|
||||
_layers_modified->getLayer(layer)->setName(layer_name);
|
||||
|
||||
BaseForm::layerAddedEvent();
|
||||
|
||||
afterLayerAdded(layersGetLayer(_layers_modified, layer));
|
||||
afterLayerAdded(_layers_modified->getLayer(layer));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +108,7 @@ void BaseFormLayer::layerDeletedEvent(int layer)
|
|||
{
|
||||
if (_layers_modified)
|
||||
{
|
||||
layersDeleteLayer(_layers_modified, layer);
|
||||
_layers_modified->removeLayer(layer);
|
||||
}
|
||||
|
||||
BaseForm::layerDeletedEvent(layer);
|
||||
|
@ -117,7 +118,7 @@ void BaseFormLayer::layerMovedEvent(int layer, int new_position)
|
|||
{
|
||||
if (_layers_modified)
|
||||
{
|
||||
layersMove(_layers_modified, layer, new_position);
|
||||
_layers_modified->moveLayer(layer, new_position);
|
||||
}
|
||||
|
||||
BaseForm::layerMovedEvent(layer, new_position);
|
||||
|
@ -127,7 +128,7 @@ void BaseFormLayer::layerRenamedEvent(int layer, QString new_name)
|
|||
{
|
||||
if (_layers_modified)
|
||||
{
|
||||
layersSetName(_layers_modified, layer, new_name.toUtf8().data());
|
||||
_layers_modified->getLayer(layer)->setName(new_name);
|
||||
}
|
||||
|
||||
BaseForm::layerRenamedEvent(layer, new_name);
|
||||
|
@ -137,7 +138,7 @@ void BaseFormLayer::layerSelectedEvent(int layer)
|
|||
{
|
||||
if (_layers_modified && layer >= 0)
|
||||
{
|
||||
layerReadCurrentFrom(layersGetLayer(_layers_modified, layer));
|
||||
layerReadCurrentFrom(_layers_modified->getLayer(layer));
|
||||
}
|
||||
|
||||
BaseForm::layerSelectedEvent(layer);
|
||||
|
|
|
@ -23,7 +23,7 @@ void FreeLayerHelper::refreshLayers()
|
|||
|
||||
emit tableUpdateNeeded();
|
||||
|
||||
int n = layersCount(_layers);
|
||||
int n = _layers->count();
|
||||
if (n == 0)
|
||||
{
|
||||
_selected = -1;
|
||||
|
@ -96,7 +96,7 @@ void FreeLayerHelper::setEditButton(QPushButton* button)
|
|||
|
||||
void FreeLayerHelper::addLayer()
|
||||
{
|
||||
_selected = layersAddLayer(_layers, NULL);
|
||||
_selected = _layers->addLayer(NULL);
|
||||
emit(layersChanged());
|
||||
refreshLayers();
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ void FreeLayerHelper::deleteLayer()
|
|||
{
|
||||
if (_selected >= 0)
|
||||
{
|
||||
layersDeleteLayer(_layers, _selected);
|
||||
_layers->removeLayer(_selected);
|
||||
emit(layersChanged());
|
||||
refreshLayers();
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ void FreeLayerHelper::moveLayerDown()
|
|||
{
|
||||
if (_selected > 0)
|
||||
{
|
||||
layersMove(_layers, _selected, _selected - 1);
|
||||
_layers->moveLayer(_selected, _selected - 1);
|
||||
_selected--;
|
||||
emit(layersChanged());
|
||||
refreshLayers();
|
||||
|
@ -124,9 +124,9 @@ void FreeLayerHelper::moveLayerDown()
|
|||
|
||||
void FreeLayerHelper::moveLayerUp()
|
||||
{
|
||||
if (_selected >= 0 && _selected < layersCount(_layers) - 1)
|
||||
if (_selected >= 0 && _selected < _layers->count() - 1)
|
||||
{
|
||||
layersMove(_layers, _selected, _selected + 1);
|
||||
_layers->moveLayer(_selected, _selected + 1);
|
||||
_selected++;
|
||||
emit(layersChanged());
|
||||
refreshLayers();
|
||||
|
@ -135,7 +135,7 @@ void FreeLayerHelper::moveLayerUp()
|
|||
|
||||
void FreeLayerHelper::startEditing()
|
||||
{
|
||||
if (_selected >= 0 && _selected < layersCount(_layers))
|
||||
if (_selected >= 0 && _selected < _layers->count())
|
||||
{
|
||||
emit(editRequired(_selected));
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ void FreeLayerHelper::startEditing()
|
|||
|
||||
void FreeLayerHelper::tableSelectionChanged(int row, int)
|
||||
{
|
||||
int n = layersCount(_layers);
|
||||
int n = _layers->count();
|
||||
|
||||
if (n == 0 or row >= n)
|
||||
{
|
||||
|
|
|
@ -5,13 +5,16 @@
|
|||
#include "renderer.h"
|
||||
#include "tools.h"
|
||||
#include "CameraDefinition.h"
|
||||
#include "TexturesDefinition.h"
|
||||
#include "TextureLayerDefinition.h"
|
||||
#include "terrain/public.h"
|
||||
|
||||
/**************** Previews ****************/
|
||||
class PreviewTexturesCoverage : public BasePreview
|
||||
{
|
||||
public:
|
||||
|
||||
PreviewTexturesCoverage(QWidget* parent, TexturesLayerDefinition* layer) : BasePreview(parent)
|
||||
PreviewTexturesCoverage(QWidget* parent, TextureLayerDefinition* layer) : BasePreview(parent)
|
||||
{
|
||||
_renderer = rendererCreate();
|
||||
_renderer->render_quality = 3;
|
||||
|
@ -51,7 +54,7 @@ protected:
|
|||
|
||||
private:
|
||||
Renderer* _renderer;
|
||||
TexturesLayerDefinition* _original_layer;
|
||||
TextureLayerDefinition* _original_layer;
|
||||
TexturesDefinition* _preview_definition;
|
||||
};
|
||||
|
||||
|
@ -59,7 +62,7 @@ class PreviewTexturesColor : public BasePreview
|
|||
{
|
||||
public:
|
||||
|
||||
PreviewTexturesColor(QWidget* parent, TexturesLayerDefinition* layer) : BasePreview(parent)
|
||||
PreviewTexturesColor(QWidget* parent, TextureLayerDefinition* layer) : BasePreview(parent)
|
||||
{
|
||||
_original_layer = layer;
|
||||
//_preview_layer = (TexturesLayerDefinition*)TexturesDefinitionClass.create();
|
||||
|
@ -95,8 +98,8 @@ protected:
|
|||
}
|
||||
private:
|
||||
Renderer* _renderer;
|
||||
TexturesLayerDefinition* _original_layer;
|
||||
TexturesLayerDefinition* _preview_layer;
|
||||
TextureLayerDefinition* _original_layer;
|
||||
TextureLayerDefinition* _preview_layer;
|
||||
};
|
||||
|
||||
/**************** Form ****************/
|
||||
|
@ -108,8 +111,8 @@ BaseFormLayer(parent)
|
|||
addAutoPreset(tr("Sand"));
|
||||
addAutoPreset(tr("Snow"));
|
||||
|
||||
_definition = (TexturesDefinition*) TexturesDefinitionClass.create();
|
||||
_layer = (TexturesLayerDefinition*) texturesGetLayerType().callback_create();
|
||||
_definition = new TexturesDefinition(NULL);
|
||||
_layer = new TextureLayerDefinition(NULL);
|
||||
|
||||
_previewCoverage = new PreviewTexturesCoverage(this, _layer);
|
||||
_previewColor = new PreviewTexturesColor(this, _layer);
|
||||
|
@ -118,7 +121,7 @@ BaseFormLayer(parent)
|
|||
|
||||
addInputDouble(tr("Displacement height"), &_layer->displacement_height, 0.0, 0.1, 0.001, 0.01);
|
||||
addInputDouble(tr("Displacement scaling"), &_layer->displacement_scaling, 0.003, 0.3, 0.003, 0.03);
|
||||
addInputMaterial(tr("Material"), &_layer->material);
|
||||
addInputMaterial(tr("Material"), _layer->material);
|
||||
/*addInputCurve(tr("Coverage by altitude"), _layer->terrain_zone->value_by_height, -20.0, 20.0, 0.0, 1.0, tr("Terrain altitude"), tr("Texture coverage"));
|
||||
addInputCurve(tr("Coverage by slope"), _layer->terrain_zone->value_by_slope, 0.0, 5.0, 0.0, 1.0, tr("Terrain slope"), tr("Texture coverage"));*/
|
||||
|
||||
|
@ -126,13 +129,13 @@ BaseFormLayer(parent)
|
|||
addInputDouble(tr("Layer thickness"), &_layer->thickness, 0.0, 0.1, 0.001, 0.01);
|
||||
addInputDouble(tr("Transparency thickness"), &_layer->thickness_transparency, 0.0, 0.1, 0.001, 0.01);*/
|
||||
|
||||
setLayers(_definition->layers);
|
||||
setLayers(_definition);
|
||||
}
|
||||
|
||||
FormTextures::~FormTextures()
|
||||
{
|
||||
TexturesDefinitionClass.destroy(_definition);
|
||||
texturesGetLayerType().callback_delete(_layer);
|
||||
delete _definition;
|
||||
delete _layer;
|
||||
}
|
||||
|
||||
void FormTextures::revertConfig()
|
||||
|
@ -149,16 +152,16 @@ void FormTextures::applyConfig()
|
|||
|
||||
void FormTextures::layerReadCurrentFrom(void* layer_definition)
|
||||
{
|
||||
texturesGetLayerType().callback_copy((TexturesLayerDefinition*) layer_definition, _layer);
|
||||
((TextureLayerDefinition*)layer_definition)->copy(_layer);
|
||||
}
|
||||
|
||||
void FormTextures::layerWriteCurrentTo(void* layer_definition)
|
||||
{
|
||||
texturesGetLayerType().callback_copy(_layer, (TexturesLayerDefinition*) layer_definition);
|
||||
_layer->copy((TextureLayerDefinition*)layer_definition);
|
||||
}
|
||||
|
||||
void FormTextures::autoPresetSelected(int preset)
|
||||
{
|
||||
texturesLayerAutoPreset(_layer, (TexturesLayerPreset) preset);
|
||||
_layer->applyPreset((TextureLayerDefinition::TextureLayerPreset)preset);
|
||||
BaseForm::autoPresetSelected(preset);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "desktop_global.h"
|
||||
|
||||
#include "baseformlayer.h"
|
||||
#include "textures/public.h"
|
||||
|
||||
class QWidget;
|
||||
|
||||
class FormTextures : public BaseFormLayer
|
||||
|
@ -26,7 +26,7 @@ protected:
|
|||
|
||||
private:
|
||||
TexturesDefinition* _definition;
|
||||
TexturesLayerDefinition* _layer;
|
||||
TextureLayerDefinition* _layer;
|
||||
BasePreview* _previewCoverage;
|
||||
BasePreview* _previewColor;
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@ InputLayers::InputLayers(QWidget* form, QString label, Layers* value, FormLayerB
|
|||
|
||||
void InputLayers::updatePreview()
|
||||
{
|
||||
((QLabel*)_preview)->setText(tr("%1 layers").arg(layersCount(_value)));
|
||||
((QLabel*)_preview)->setText(tr("%1 layers").arg(_value->count()));
|
||||
|
||||
BaseInput::updatePreview();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "DialogTexturesLayer.h"
|
||||
#include "ui_DialogTexturesLayer.h"
|
||||
|
||||
#include "TexturesDefinition.h"
|
||||
|
||||
DialogTexturesLayer::DialogTexturesLayer(QWidget* parent, TexturesDefinition* textures, int layer) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DialogTexturesLayer)
|
||||
|
@ -9,12 +11,12 @@ DialogTexturesLayer::DialogTexturesLayer(QWidget* parent, TexturesDefinition* te
|
|||
|
||||
this->layer = layer;
|
||||
original = textures;
|
||||
modified = (TexturesDefinition*)TexturesDefinitionClass.create();
|
||||
modified = new TexturesDefinition(NULL);
|
||||
}
|
||||
|
||||
DialogTexturesLayer::~DialogTexturesLayer()
|
||||
{
|
||||
delete ui;
|
||||
|
||||
TexturesDefinitionClass.destroy(modified);
|
||||
delete modified;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#ifndef DIALOGTEXTURESLAYER_H
|
||||
#define DIALOGTEXTURESLAYER_H
|
||||
|
||||
#include "desktop_global.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include "textures/public.h"
|
||||
|
||||
namespace Ui {
|
||||
class DialogTexturesLayer;
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
|
||||
#include "Base2dPreviewRenderer.h"
|
||||
|
||||
class TexturesDefinition;
|
||||
|
||||
class PreviewCumul : public Base2dPreviewRenderer
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
|
||||
#include "Base2dPreviewRenderer.h"
|
||||
|
||||
class TexturesDefinition;
|
||||
|
||||
class PreviewLayerCoverage : public Base2dPreviewRenderer
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
|
||||
#include "Base2dPreviewRenderer.h"
|
||||
|
||||
class TexturesDefinition;
|
||||
|
||||
class PreviewLayerLook : public Base2dPreviewRenderer
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -4,19 +4,22 @@
|
|||
#include "../common/freeformhelper.h"
|
||||
#include "../common/freelayerhelper.h"
|
||||
#include "Scenery.h"
|
||||
#include "TexturesDefinition.h"
|
||||
#include "TextureLayerDefinition.h"
|
||||
#include "previewmaterial.h"
|
||||
#include "textures/PreviewLayerCoverage.h"
|
||||
#include "textures/PreviewLayerLook.h"
|
||||
#include "textures/PreviewCumul.h"
|
||||
#include "textures/DialogTexturesLayer.h"
|
||||
#include "textures/public.h"
|
||||
|
||||
MainTexturesForm::MainTexturesForm(QWidget *parent) : QWidget(parent), ui(new Ui::MainTexturesForm)
|
||||
{
|
||||
textures = (TexturesDefinition*) TexturesDefinitionClass.create();
|
||||
textures = new TexturesDefinition(NULL);
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
layer_helper = new FreeLayerHelper(textures->layers, true);
|
||||
layer_helper = new FreeLayerHelper(textures, true);
|
||||
layer_helper->setLayerTable(ui->layersGrid);
|
||||
layer_helper->setAddButton(ui->layer_add);
|
||||
layer_helper->setDelButton(ui->layer_del);
|
||||
|
@ -69,23 +72,23 @@ void MainTexturesForm::updateLayers()
|
|||
|
||||
ui->layersGrid->clearContents();
|
||||
|
||||
n = layersCount(textures->layers);
|
||||
n = textures->count();
|
||||
ui->layersGrid->setRowCount(n);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
QTableWidgetItem* item;
|
||||
TexturesLayerDefinition* layer = (TexturesLayerDefinition*) layersGetLayer(textures->layers, i);
|
||||
TextureLayerDefinition* layer = textures->getTextureLayer(i);
|
||||
|
||||
item = new QTableWidgetItem(QString("%1").arg(i + 1));
|
||||
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
ui->layersGrid->setItem(n - 1 - i, 0, item);
|
||||
|
||||
item = new QTableWidgetItem(QString(layersGetName(textures->layers, i)));
|
||||
item = new QTableWidgetItem(layer->getName());
|
||||
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
ui->layersGrid->setItem(n - 1 - i, 1, item);
|
||||
|
||||
QWidget* widget = new SmallMaterialPreview(ui->layersGrid, &layer->material);
|
||||
QWidget* widget = new SmallMaterialPreview(ui->layersGrid, layer->material);
|
||||
//widget->setMinimumSize(50, 50);
|
||||
ui->layersGrid->setCellWidget(n - 1 - i, 2, widget);
|
||||
|
||||
|
@ -125,7 +128,7 @@ void MainTexturesForm::editLayer(int layer)
|
|||
|
||||
void MainTexturesForm::selectPreset(int preset)
|
||||
{
|
||||
texturesAutoPreset(textures, (TexturesPreset)preset);
|
||||
textures->applyPreset((TexturesDefinition::TexturesPreset)preset);
|
||||
}
|
||||
|
||||
void MainTexturesForm::updateLocalDataFromScenery()
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#ifndef MAINTEXTURESFORM_H
|
||||
#define MAINTEXTURESFORM_H
|
||||
|
||||
#include "desktop_global.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include "textures/public.h"
|
||||
|
||||
namespace Ui {
|
||||
class MainTexturesForm;
|
||||
|
@ -13,6 +14,7 @@ class FreeLayerHelper;
|
|||
class PreviewLayerCoverage;
|
||||
class PreviewLayerLook;
|
||||
class PreviewCumul;
|
||||
class Renderer;
|
||||
|
||||
class MainTexturesForm : public QWidget
|
||||
{
|
||||
|
|
|
@ -5,14 +5,15 @@
|
|||
#include "NoiseGenerator.h"
|
||||
#include "PackStream.h"
|
||||
#include "atmosphere/public.h"
|
||||
#include "CameraDefinition.h"
|
||||
#include "CloudsDefinition.h"
|
||||
#include "terrain/public.h"
|
||||
#include "textures/public.h"
|
||||
#include "renderer.h"
|
||||
#include "terrain/ter_raster.h"
|
||||
#include "WaterDefinition.h"
|
||||
#include "AtmosphereDefinition.h"
|
||||
#include "CameraDefinition.h"
|
||||
#include "CloudsDefinition.h"
|
||||
#include "TexturesDefinition.h"
|
||||
#include "WaterDefinition.h"
|
||||
|
||||
static Scenery _main_scenery;
|
||||
|
||||
|
@ -23,13 +24,14 @@ Scenery::Scenery():
|
|||
camera = new CameraDefinition;
|
||||
clouds = new CloudsDefinition(this);
|
||||
terrain = (TerrainDefinition*)TerrainDefinitionClass.create();
|
||||
textures = (TexturesDefinition*)TexturesDefinitionClass.create();
|
||||
textures = new TexturesDefinition(this);
|
||||
water = new WaterDefinition(this);
|
||||
|
||||
addChild(camera);
|
||||
addChild(atmosphere);
|
||||
addChild(water);
|
||||
addChild(camera);
|
||||
addChild(clouds);
|
||||
addChild(textures);
|
||||
addChild(water);
|
||||
|
||||
_custom_load = NULL;
|
||||
_custom_save = NULL;
|
||||
|
@ -39,7 +41,6 @@ Scenery::Scenery():
|
|||
Scenery::~Scenery()
|
||||
{
|
||||
TerrainDefinitionClass.destroy(terrain);
|
||||
TexturesDefinitionClass.destroy(textures);
|
||||
}
|
||||
|
||||
Scenery* Scenery::getCurrent()
|
||||
|
@ -61,7 +62,6 @@ void Scenery::save(PackStream* stream) const
|
|||
noiseSave(stream);
|
||||
|
||||
TerrainDefinitionClass.save(stream, terrain);
|
||||
TexturesDefinitionClass.save(stream, textures);
|
||||
|
||||
if (_custom_save)
|
||||
{
|
||||
|
@ -76,7 +76,6 @@ void Scenery::load(PackStream* stream)
|
|||
noiseLoad(stream);
|
||||
|
||||
TerrainDefinitionClass.load(stream, terrain);
|
||||
TexturesDefinitionClass.load(stream, textures);
|
||||
|
||||
if (_custom_load)
|
||||
{
|
||||
|
@ -102,7 +101,7 @@ void Scenery::autoPreset(int seed)
|
|||
srand(seed);
|
||||
|
||||
terrainAutoPreset(terrain, TERRAIN_PRESET_STANDARD);
|
||||
texturesAutoPreset(textures, TEXTURES_PRESET_FULL);
|
||||
textures->applyPreset(TexturesDefinition::TEXTURES_PRESET_FULL);
|
||||
atmosphere->applyPreset(AtmosphereDefinition::ATMOSPHERE_PRESET_CLEAR_DAY);
|
||||
water->applyPreset(WATER_PRESET_LAKE);
|
||||
clouds->applyPreset(CloudsDefinition::CLOUDS_PRESET_PARTLY_CLOUDY);
|
||||
|
@ -156,12 +155,12 @@ void Scenery::getTerrain(TerrainDefinition* terrain)
|
|||
|
||||
void Scenery::setTextures(TexturesDefinition* textures)
|
||||
{
|
||||
TexturesDefinitionClass.copy(textures, this->textures);
|
||||
textures->copy(this->textures);
|
||||
}
|
||||
|
||||
void Scenery::getTextures(TexturesDefinition* textures)
|
||||
{
|
||||
TexturesDefinitionClass.copy(this->textures, textures);
|
||||
this->textures->copy(textures);
|
||||
}
|
||||
|
||||
void Scenery::setWater(WaterDefinition* water)
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include "BaseDefinition.h"
|
||||
|
||||
class TerrainDefinition;
|
||||
class TexturesDefinition;
|
||||
class Renderer;
|
||||
|
||||
typedef void (*SceneryCustomDataCallback)(PackStream* stream, void* data);
|
||||
|
|
|
@ -30,9 +30,6 @@ SOURCES += main.cpp \
|
|||
textures/tex_tools.cpp \
|
||||
textures/tex_rendering.cpp \
|
||||
textures/tex_preview.cpp \
|
||||
textures/tex_presets.cpp \
|
||||
textures/tex_definition.cpp \
|
||||
tools/zone.cpp \
|
||||
tools/texture.cpp \
|
||||
tools/parallel.cpp \
|
||||
tools/memory.cpp \
|
||||
|
@ -68,7 +65,6 @@ HEADERS += \
|
|||
textures/tex_preview.h \
|
||||
textures/public.h \
|
||||
textures/private.h \
|
||||
tools/zone.h \
|
||||
tools/texture.h \
|
||||
tools/parallel.h \
|
||||
tools/memory.h \
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
#include "NoiseGenerator.h"
|
||||
#include "atmosphere/public.h"
|
||||
#include "textures/public.h"
|
||||
#include "TextureLayerDefinition.h"
|
||||
#include "TexturesDefinition.h"
|
||||
#include "Zone.h"
|
||||
|
||||
/*
|
||||
* Terrain previews.
|
||||
|
@ -57,21 +60,17 @@ void terrainAlterPreviewRenderer(Renderer* renderer)
|
|||
renderer->getCameraLocation = _getCameraLocation;
|
||||
renderer->atmosphere->getLightingStatus = _getLightingStatus;
|
||||
|
||||
TexturesDefinition* textures;
|
||||
textures = (TexturesDefinition*)TexturesDefinitionClass.create();
|
||||
layersClear(textures->layers);
|
||||
TexturesLayerDefinition* layer = (TexturesLayerDefinition*)layersGetLayer(textures->layers, layersAddLayer(textures->layers, NULL));
|
||||
zoneClear(layer->terrain_zone);
|
||||
TexturesDefinition textures(NULL);
|
||||
TextureLayerDefinition* layer = textures.getTextureLayer(textures.addLayer());
|
||||
layer->terrain_zone->clear();
|
||||
layer->displacement_height = 0.0;
|
||||
layer->material.base = colorToHSL(COLOR_WHITE);
|
||||
layer->material.reflection = 0.05;
|
||||
layer->material.shininess = 2.0;
|
||||
TexturesDefinitionClass.validate(textures);
|
||||
layer->material->base = colorToHSL(COLOR_WHITE);
|
||||
layer->material->reflection = 0.05;
|
||||
layer->material->shininess = 2.0;
|
||||
layer->validate();
|
||||
layer->_detail_noise->clearLevels();
|
||||
|
||||
TexturesRendererClass.bind(renderer, textures);
|
||||
|
||||
TexturesDefinitionClass.destroy(textures);
|
||||
TexturesRendererClass.bind(renderer, &textures);
|
||||
}
|
||||
|
||||
Color terrainGetPreviewColor(Renderer* renderer, double x, double z, double detail)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/*
|
||||
* Get the base presence factor of a layer, not accounting for other layers.
|
||||
*/
|
||||
double texturesGetLayerBasePresence(TexturesLayerDefinition* layer, TerrainResult terrain);
|
||||
double texturesGetLayerBasePresence(TextureLayerDefinition* layer, TerrainResult terrain);
|
||||
|
||||
/*
|
||||
* Get triplanar noise value, depending on the normal direction.
|
||||
|
|
|
@ -3,63 +3,15 @@
|
|||
|
||||
#include "../rendering_global.h"
|
||||
#include "Layers.h"
|
||||
#include "tools/zone.h"
|
||||
#include "tools/lighting.h"
|
||||
#include "terrain/public.h"
|
||||
#include "SurfaceMaterial.h"
|
||||
|
||||
#define TEXTURES_MAX_LAYERS 50
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TEXTURES_PRESET_FULL,
|
||||
TEXTURES_PRESET_IRELAND,
|
||||
TEXTURES_PRESET_ALPS,
|
||||
TEXTURES_PRESET_CANYON
|
||||
} TexturesPreset;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TEXTURES_LAYER_PRESET_MUD,
|
||||
TEXTURES_LAYER_PRESET_ROCK,
|
||||
TEXTURES_LAYER_PRESET_GRASS,
|
||||
TEXTURES_LAYER_PRESET_SAND,
|
||||
TEXTURES_LAYER_PRESET_SNOW
|
||||
} TexturesLayerPreset;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TEXTURES_MERGE_FADE,
|
||||
TEXTURES_MERGE_DISSOLVE,
|
||||
TEXTURES_MERGE_DISPLACEMENT_VALUE
|
||||
} TexturesMergeMode;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Zone* terrain_zone;
|
||||
double displacement_scaling;
|
||||
double displacement_height;
|
||||
double displacement_offset;
|
||||
/*double detail_scaling;
|
||||
double detail_height;*/
|
||||
SurfaceMaterial material;
|
||||
/*double cancel_displacement_factor;
|
||||
TexturesMergeMode merge_mode;*/
|
||||
|
||||
NoiseGenerator* _displacement_noise;
|
||||
NoiseGenerator* _detail_noise;
|
||||
/*Curve* _local_slope_condition;*/
|
||||
} TexturesLayerDefinition;
|
||||
|
||||
class TexturesDefinition
|
||||
{
|
||||
public:
|
||||
Layers* layers;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
TexturesLayerDefinition* layer;
|
||||
TextureLayerDefinition* layer;
|
||||
double presence;
|
||||
Color color;
|
||||
} TexturesLayerResult;
|
||||
|
@ -89,14 +41,8 @@ public:
|
|||
};
|
||||
|
||||
|
||||
RENDERINGSHARED_EXPORT extern StandardDefinition TexturesDefinitionClass;
|
||||
RENDERINGSHARED_EXPORT extern StandardRenderer TexturesRendererClass;
|
||||
|
||||
|
||||
RENDERINGSHARED_EXPORT LayerType texturesGetLayerType();
|
||||
RENDERINGSHARED_EXPORT void texturesAutoPreset(TexturesDefinition* definition, TexturesPreset preset);
|
||||
RENDERINGSHARED_EXPORT void texturesLayerAutoPreset(TexturesLayerDefinition* definition, TexturesLayerPreset preset);
|
||||
|
||||
RENDERINGSHARED_EXPORT double texturesGetMaximalDisplacement(TexturesDefinition* textures);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,155 +0,0 @@
|
|||
#include "private.h"
|
||||
|
||||
#include "Scenery.h"
|
||||
#include "NoiseGenerator.h"
|
||||
#include "PackStream.h"
|
||||
|
||||
/******************** Global definition ********************/
|
||||
static void _validateDefinition(TexturesDefinition* definition)
|
||||
{
|
||||
layersValidate(definition->layers);
|
||||
}
|
||||
|
||||
static TexturesDefinition* _createDefinition()
|
||||
{
|
||||
TexturesDefinition* definition = new TexturesDefinition;
|
||||
|
||||
definition->layers = layersCreate(texturesGetLayerType(), TEXTURES_MAX_LAYERS);
|
||||
|
||||
return definition;
|
||||
}
|
||||
|
||||
static void _deleteDefinition(TexturesDefinition* definition)
|
||||
{
|
||||
layersDelete(definition->layers);
|
||||
delete definition;
|
||||
}
|
||||
|
||||
static void _copyDefinition(TexturesDefinition* source, TexturesDefinition* destination)
|
||||
{
|
||||
layersCopy(source->layers, destination->layers);
|
||||
}
|
||||
|
||||
static void _saveDefinition(PackStream* stream, TexturesDefinition* definition)
|
||||
{
|
||||
layersSave(stream, definition->layers);
|
||||
}
|
||||
|
||||
static void _loadDefinition(PackStream* stream, TexturesDefinition* definition)
|
||||
{
|
||||
layersLoad(stream, definition->layers);
|
||||
}
|
||||
|
||||
StandardDefinition TexturesDefinitionClass = {
|
||||
(FuncObjectCreate)_createDefinition,
|
||||
(FuncObjectDelete)_deleteDefinition,
|
||||
(FuncObjectCopy)_copyDefinition,
|
||||
(FuncObjectValidate)_validateDefinition,
|
||||
(FuncObjectSave)_saveDefinition,
|
||||
(FuncObjectLoad)_loadDefinition
|
||||
};
|
||||
|
||||
/*** Layer definition ***/
|
||||
|
||||
static void _layerValidateDefinition(TexturesLayerDefinition* definition)
|
||||
{
|
||||
if (definition->displacement_scaling < 0.000001)
|
||||
{
|
||||
definition->displacement_scaling = 0.000001;
|
||||
}
|
||||
|
||||
definition->_displacement_noise->clearLevels();
|
||||
definition->_displacement_noise->addLevelsSimple(9, 1.0, -1.0, 1.0, 0.0);
|
||||
definition->_displacement_noise->normalizeAmplitude(-1.0, 1.0, 0);
|
||||
definition->_displacement_noise->validate();
|
||||
|
||||
definition->_detail_noise->clearLevels();
|
||||
definition->_detail_noise->addLevelsSimple(7, 0.01, -1.0, 1.0, 0.0);
|
||||
definition->_detail_noise->normalizeAmplitude(-0.008, 0.008, 0);
|
||||
definition->_detail_noise->validate();
|
||||
|
||||
materialValidate(&definition->material);
|
||||
|
||||
/* Update zone height range */
|
||||
TerrainDefinition* terrain = Scenery::getCurrent()->getTerrain();
|
||||
if (terrain)
|
||||
{
|
||||
HeightInfo height_info = terrainGetHeightInfo(terrain);
|
||||
zoneSetRelativeHeight(definition->terrain_zone, height_info.min_height, height_info.base_height, height_info.max_height);
|
||||
}
|
||||
}
|
||||
|
||||
static TexturesLayerDefinition* _layerCreateDefinition()
|
||||
{
|
||||
TexturesLayerDefinition* result;
|
||||
|
||||
result = new TexturesLayerDefinition;
|
||||
|
||||
result->terrain_zone = zoneCreate();
|
||||
result->_displacement_noise = new NoiseGenerator();
|
||||
result->_detail_noise = new NoiseGenerator();
|
||||
|
||||
texturesLayerAutoPreset(result, TEXTURES_LAYER_PRESET_ROCK);
|
||||
|
||||
_layerValidateDefinition(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void _layerDeleteDefinition(TexturesLayerDefinition* definition)
|
||||
{
|
||||
zoneDelete(definition->terrain_zone);
|
||||
delete definition->_displacement_noise;
|
||||
delete definition->_detail_noise;
|
||||
delete definition;
|
||||
}
|
||||
|
||||
static void _layerCopyDefinition(TexturesLayerDefinition* source, TexturesLayerDefinition* destination)
|
||||
{
|
||||
zoneCopy(source->terrain_zone, destination->terrain_zone);
|
||||
destination->displacement_scaling = source->displacement_scaling;
|
||||
destination->displacement_height = source->displacement_height;
|
||||
destination->displacement_offset = source->displacement_offset;
|
||||
destination->material = source->material;
|
||||
|
||||
source->_displacement_noise->copy(destination->_displacement_noise);
|
||||
source->_detail_noise->copy(destination->_detail_noise);
|
||||
}
|
||||
|
||||
static void _layerSave(PackStream* stream, TexturesLayerDefinition* layer)
|
||||
{
|
||||
zoneSave(stream, layer->terrain_zone);
|
||||
stream->write(&layer->displacement_scaling);
|
||||
stream->write(&layer->displacement_height);
|
||||
stream->write(&layer->displacement_offset);
|
||||
materialSave(stream, &layer->material);
|
||||
|
||||
layer->_displacement_noise->save(stream);
|
||||
layer->_detail_noise->save(stream);
|
||||
}
|
||||
|
||||
static void _layerLoad(PackStream* stream, TexturesLayerDefinition* layer)
|
||||
{
|
||||
zoneLoad(stream, layer->terrain_zone);
|
||||
stream->read(&layer->displacement_scaling);
|
||||
stream->read(&layer->displacement_height);
|
||||
stream->read(&layer->displacement_offset);
|
||||
materialLoad(stream, &layer->material);
|
||||
|
||||
layer->_displacement_noise->load(stream);
|
||||
layer->_detail_noise->load(stream);
|
||||
}
|
||||
|
||||
LayerType texturesGetLayerType()
|
||||
{
|
||||
LayerType result;
|
||||
|
||||
result.callback_create = (LayerCallbackCreate)_layerCreateDefinition;
|
||||
result.callback_delete = (LayerCallbackDelete)_layerDeleteDefinition;
|
||||
result.callback_copy = (LayerCallbackCopy)_layerCopyDefinition;
|
||||
result.callback_validate = (LayerCallbackValidate)_layerValidateDefinition;
|
||||
result.callback_save = (LayerCallbackSave)_layerSave;
|
||||
result.callback_load = (LayerCallbackLoad)_layerLoad;
|
||||
|
||||
return result;
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
#include "private.h"
|
||||
|
||||
#include "NoiseGenerator.h"
|
||||
|
||||
void texturesAutoPreset(TexturesDefinition* definition, TexturesPreset preset)
|
||||
{
|
||||
TexturesLayerDefinition* layer;
|
||||
layersClear(definition->layers);
|
||||
|
||||
layer = (TexturesLayerDefinition*)layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
||||
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_MUD);
|
||||
layersSetName(definition->layers, 0, "Mud");
|
||||
|
||||
if (preset == TEXTURES_PRESET_FULL)
|
||||
{
|
||||
layer = (TexturesLayerDefinition*)layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
||||
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_ROCK);
|
||||
layersSetName(definition->layers, 1, "Ground");
|
||||
|
||||
layer = (TexturesLayerDefinition*)layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
||||
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_GRASS);
|
||||
layersSetName(definition->layers, 2, "Grass");
|
||||
|
||||
layer = (TexturesLayerDefinition*)layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
||||
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_SAND);
|
||||
layersSetName(definition->layers, 3, "Sand");
|
||||
|
||||
layer = (TexturesLayerDefinition*)layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
||||
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_SNOW);
|
||||
layersSetName(definition->layers, 4, "Snow");
|
||||
}
|
||||
else if (preset == TEXTURES_PRESET_IRELAND)
|
||||
{
|
||||
layer = (TexturesLayerDefinition*)layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
||||
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_ROCK);
|
||||
layersSetName(definition->layers, 1, "Ground");
|
||||
|
||||
layer = (TexturesLayerDefinition*)layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
||||
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_GRASS);
|
||||
layersSetName(definition->layers, 2, "Grass");
|
||||
}
|
||||
else if (preset == TEXTURES_PRESET_ALPS)
|
||||
{
|
||||
layer = (TexturesLayerDefinition*)layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
||||
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_ROCK);
|
||||
layersSetName(definition->layers, 1, "Ground");
|
||||
|
||||
layer = (TexturesLayerDefinition*)layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
||||
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_SNOW);
|
||||
layersSetName(definition->layers, 2, "Snow");
|
||||
}
|
||||
else if (preset == TEXTURES_PRESET_CANYON)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
}
|
||||
|
||||
void texturesLayerAutoPreset(TexturesLayerDefinition* definition, TexturesLayerPreset preset)
|
||||
{
|
||||
definition->_displacement_noise->randomizeOffsets();
|
||||
definition->_detail_noise->randomizeOffsets();
|
||||
|
||||
zoneClear(definition->terrain_zone);
|
||||
|
||||
switch (preset)
|
||||
{
|
||||
case TEXTURES_LAYER_PRESET_MUD:
|
||||
definition->displacement_height = 0.05;
|
||||
definition->displacement_scaling = 3.0;
|
||||
definition->displacement_offset = 0.0;
|
||||
definition->material.base = colorToHSL(colorFromValues(0.4, 0.38, 0.35, 1.0));
|
||||
definition->material.reflection = 0.003;
|
||||
definition->material.shininess = 4.0;
|
||||
break;
|
||||
case TEXTURES_LAYER_PRESET_ROCK:
|
||||
zoneAddHeightRangeQuick(definition->terrain_zone, 1.0, 0.5, 0.55, 1.0, 1.0);
|
||||
definition->displacement_height = 0.3;
|
||||
definition->displacement_scaling = 2.0;
|
||||
definition->displacement_offset = 0.0;
|
||||
definition->material.base = colorToHSL(colorFromValues(0.6, 0.55, 0.57, 1.0));
|
||||
definition->material.reflection = 0.006;
|
||||
definition->material.shininess = 6.0;
|
||||
break;
|
||||
case TEXTURES_LAYER_PRESET_GRASS:
|
||||
zoneAddHeightRangeQuick(definition->terrain_zone, 1.0, 0.45, 0.5, 0.8, 1.0);
|
||||
zoneAddSlopeRangeQuick(definition->terrain_zone, 1.0, 0.0, 0.0, 0.05, 0.4);
|
||||
definition->displacement_height = 0.0;
|
||||
definition->displacement_scaling = 1.0;
|
||||
definition->displacement_offset = 0.0;
|
||||
definition->material.base = colorToHSL(colorFromValues(0.12, 0.19, 0.035, 1.0));
|
||||
definition->material.reflection = 0.001;
|
||||
definition->material.shininess = 4.0;
|
||||
break;
|
||||
case TEXTURES_LAYER_PRESET_SAND:
|
||||
zoneAddHeightRangeQuick(definition->terrain_zone, 1.0, 0.498, 0.502, 0.505, 0.51);
|
||||
zoneAddSlopeRangeQuick(definition->terrain_zone, 1.0, 0.0, 0.0, 0.7, 0.1);
|
||||
definition->displacement_height = 0.02;
|
||||
definition->displacement_scaling = 5.0;
|
||||
definition->displacement_offset = 0.0;
|
||||
definition->material.base = colorToHSL(colorFromValues(0.93, 0.9, 0.8, 1.0));
|
||||
definition->material.reflection = 0.008;
|
||||
definition->material.shininess = 1.0;
|
||||
break;
|
||||
case TEXTURES_LAYER_PRESET_SNOW:
|
||||
zoneAddHeightRangeQuick(definition->terrain_zone, 1.0, 0.77, 0.85, 1.0, 1.0);
|
||||
zoneAddSlopeRangeQuick(definition->terrain_zone, 1.0, 0.0, 0.0, 0.2, 1.0);
|
||||
definition->displacement_height = 0.1;
|
||||
definition->displacement_scaling = 1.0;
|
||||
definition->displacement_offset = 0.0;
|
||||
definition->material.base = colorToHSL(colorFromValues(1.0, 1.0, 1.0, 1.0));
|
||||
definition->material.reflection = 0.25;
|
||||
definition->material.shininess = 0.6;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
texturesGetLayerType().callback_validate(definition);
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
#include "private.h"
|
||||
|
||||
#include "Scenery.h"
|
||||
#include "tools.h"
|
||||
#include "TexturesDefinition.h"
|
||||
|
||||
void TexturesPreviewLayerCoverage_bind(Renderer* renderer, TexturesDefinition* definition)
|
||||
{
|
||||
|
@ -10,16 +10,14 @@ void TexturesPreviewLayerCoverage_bind(Renderer* renderer, TexturesDefinition* d
|
|||
TexturesRendererClass.bind(renderer, definition);
|
||||
}
|
||||
|
||||
Color TexturesPreviewLayerCoverage_getColor(Renderer* renderer, double x, double y, double scaling, int layer)
|
||||
Color TexturesPreviewLayerCoverage_getColor(Renderer* renderer, double x, double y, double, int layer)
|
||||
{
|
||||
UNUSED(scaling);
|
||||
|
||||
TexturesLayerDefinition* layerdef;
|
||||
TextureLayerDefinition* layerdef;
|
||||
TerrainResult terrain;
|
||||
double presence;
|
||||
Color result;
|
||||
|
||||
layerdef = (TexturesLayerDefinition*)layersGetLayer(renderer->textures->definition->layers, layer);
|
||||
layerdef = renderer->textures->definition->getTextureLayer(layer);
|
||||
if (layerdef)
|
||||
{
|
||||
terrain = renderer->terrain->getResult(renderer, x, y, 1, 1);
|
||||
|
@ -36,12 +34,8 @@ Color TexturesPreviewLayerCoverage_getColor(Renderer* renderer, double x, double
|
|||
return result;
|
||||
}
|
||||
|
||||
static double _getPresenceFull(Renderer* renderer, int layer, TerrainResult terrain)
|
||||
static double _getPresenceFull(Renderer*, int, TerrainResult)
|
||||
{
|
||||
UNUSED(renderer);
|
||||
UNUSED(layer);
|
||||
UNUSED(terrain);
|
||||
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
|
@ -51,11 +45,8 @@ void TexturesPreviewLayerLook_bind(Renderer* renderer, TexturesDefinition* defin
|
|||
renderer->textures->getBasePresence = _getPresenceFull;
|
||||
}
|
||||
|
||||
Color TexturesPreviewLayerLook_getColor(Renderer* renderer, double x, double y, double scaling, int layer)
|
||||
Color TexturesPreviewLayerLook_getColor(Renderer* renderer, double x, double y, double, int layer)
|
||||
{
|
||||
UNUSED(scaling);
|
||||
UNUSED(layer);
|
||||
|
||||
TexturesResult result = renderer->textures->applyToTerrain(renderer, x, y);
|
||||
if (layer >= 0 && layer < result.layer_count)
|
||||
{
|
||||
|
@ -74,10 +65,7 @@ void TexturesPreviewCumul_bind(Renderer* renderer, TexturesDefinition* definitio
|
|||
TexturesRendererClass.bind(renderer, definition);
|
||||
}
|
||||
|
||||
Color TexturesPreviewCumul_getColor(Renderer* renderer, double x, double y, double scaling, int layer)
|
||||
Color TexturesPreviewCumul_getColor(Renderer* renderer, double x, double y, double, int)
|
||||
{
|
||||
UNUSED(scaling);
|
||||
UNUSED(layer);
|
||||
|
||||
return renderer->textures->applyToTerrain(renderer, x, y).final_color;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "private.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "../tools.h"
|
||||
#include <cstdlib>
|
||||
#include "TexturesDefinition.h"
|
||||
#include "TextureLayerDefinition.h"
|
||||
#include "../renderer.h"
|
||||
|
||||
/******************** Tools ********************/
|
||||
|
@ -29,7 +30,7 @@ static inline Vector3 _getNormal2(Vector3 center, Vector3 east, Vector3 south)
|
|||
return v3Normalize(v3Cross(v3Sub(south, center), v3Sub(east, center)));
|
||||
}
|
||||
|
||||
static Vector3 _getDetailNormal(Renderer* renderer, Vector3 base_location, Vector3 base_normal, TexturesLayerDefinition* layer)
|
||||
static Vector3 _getDetailNormal(Renderer* renderer, Vector3 base_location, Vector3 base_normal, TextureLayerDefinition* layer)
|
||||
{
|
||||
Vector3 result;
|
||||
double offset = 0.01;
|
||||
|
@ -88,10 +89,10 @@ static Vector3 _realDisplaceTerrain(Renderer* renderer, TerrainResult terrain)
|
|||
double offset = 0.0;
|
||||
int i, n;
|
||||
|
||||
n = layersCount(textures->layers);
|
||||
n = textures->count();
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
TexturesLayerDefinition* layer = (TexturesLayerDefinition*)layersGetLayer(textures->layers, i);
|
||||
TextureLayerDefinition* layer = textures->getTextureLayer(i);
|
||||
|
||||
if (layer->displacement_height > 0.0)
|
||||
{
|
||||
|
@ -106,7 +107,7 @@ static Vector3 _realDisplaceTerrain(Renderer* renderer, TerrainResult terrain)
|
|||
|
||||
static double _realGetBasePresence(Renderer* renderer, int layer, TerrainResult terrain)
|
||||
{
|
||||
TexturesLayerDefinition* layerdef = (TexturesLayerDefinition*)layersGetLayer(renderer->textures->definition->layers, layer);
|
||||
TextureLayerDefinition* layerdef = renderer->textures->definition->getTextureLayer(layer);
|
||||
return texturesGetLayerBasePresence(layerdef, terrain);
|
||||
}
|
||||
|
||||
|
@ -122,16 +123,16 @@ static TexturesResult _realApplyToTerrain(Renderer* renderer, double x, double z
|
|||
|
||||
/* Find presence of each layer */
|
||||
int i, n;
|
||||
n = layersCount(textures->layers);
|
||||
n = textures->count();
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
TexturesLayerResult* info = result.layers + i;
|
||||
info->layer = (TexturesLayerDefinition*)layersGetLayer(textures->layers, i);
|
||||
info->layer = textures->getTextureLayer(i);
|
||||
info->presence = renderer->textures->getBasePresence(renderer, i, terrain);
|
||||
if (info->presence > 0.0)
|
||||
{
|
||||
Vector3 normal = _getDetailNormal(renderer, terrain.location, terrain.normal, info->layer);
|
||||
info->color = renderer->applyLightingToSurface(renderer, terrain.location, normal, &info->layer->material);
|
||||
info->color = renderer->applyLightingToSurface(renderer, terrain.location, normal, info->layer->material);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -157,26 +158,18 @@ static TexturesResult _realApplyToTerrain(Renderer* renderer, double x, double z
|
|||
}
|
||||
|
||||
/******************** Fake ********************/
|
||||
static Vector3 _fakeDisplaceTerrain(Renderer* renderer, TerrainResult terrain)
|
||||
static Vector3 _fakeDisplaceTerrain(Renderer*, TerrainResult terrain)
|
||||
{
|
||||
UNUSED(renderer);
|
||||
|
||||
return terrain.location;
|
||||
}
|
||||
|
||||
static double _fakeGetBasePresence(Renderer* renderer, int layer, TerrainResult terrain)
|
||||
static double _fakeGetBasePresence(Renderer*, int, TerrainResult)
|
||||
{
|
||||
UNUSED(renderer);
|
||||
UNUSED(layer);
|
||||
UNUSED(terrain);
|
||||
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
static TexturesResult _fakeApplyToTerrain(Renderer* renderer, double x, double z)
|
||||
static TexturesResult _fakeApplyToTerrain(Renderer*, double x, double z)
|
||||
{
|
||||
UNUSED(renderer);
|
||||
|
||||
TexturesResult result;
|
||||
|
||||
result.base_location.x = x;
|
||||
|
@ -196,7 +189,7 @@ static TexturesRenderer* _createRenderer()
|
|||
TexturesRenderer* result;
|
||||
|
||||
result = new TexturesRenderer;
|
||||
result->definition = (TexturesDefinition*)TexturesDefinitionClass.create();
|
||||
result->definition = new TexturesDefinition(NULL);
|
||||
|
||||
result->displaceTerrain = _fakeDisplaceTerrain;
|
||||
result->getBasePresence = _fakeGetBasePresence;
|
||||
|
@ -207,13 +200,13 @@ static TexturesRenderer* _createRenderer()
|
|||
|
||||
static void _deleteRenderer(TexturesRenderer* renderer)
|
||||
{
|
||||
TexturesDefinitionClass.destroy(renderer->definition);
|
||||
delete renderer->definition;
|
||||
delete renderer;
|
||||
}
|
||||
|
||||
static void _bindRenderer(Renderer* renderer, TexturesDefinition* definition)
|
||||
{
|
||||
TexturesDefinitionClass.copy(definition, renderer->textures->definition);
|
||||
definition->copy(renderer->textures->definition);
|
||||
|
||||
renderer->textures->displaceTerrain = _realDisplaceTerrain;
|
||||
renderer->textures->getBasePresence = _realGetBasePresence;
|
||||
|
|
|
@ -2,13 +2,16 @@
|
|||
|
||||
#include <cmath>
|
||||
#include "NoiseGenerator.h"
|
||||
#include "TexturesDefinition.h"
|
||||
#include "TextureLayerDefinition.h"
|
||||
#include "Zone.h"
|
||||
|
||||
/*
|
||||
* Get the base presence factor of a layer, not accounting for other layers.
|
||||
*/
|
||||
double texturesGetLayerBasePresence(TexturesLayerDefinition* layer, TerrainResult terrain)
|
||||
double texturesGetLayerBasePresence(TextureLayerDefinition* layer, TerrainResult terrain)
|
||||
{
|
||||
return zoneGetValue(layer->terrain_zone, terrain.location, terrain.normal);
|
||||
return layer->terrain_zone->getValue(terrain.location, terrain.normal);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -35,10 +38,10 @@ double texturesGetMaximalDisplacement(TexturesDefinition* textures)
|
|||
{
|
||||
int i, n;
|
||||
double disp = 0.0;
|
||||
n = layersCount(textures->layers);
|
||||
n = textures->count();
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
TexturesLayerDefinition* layer = (TexturesLayerDefinition*)layersGetLayer(textures->layers, i);
|
||||
TextureLayerDefinition* layer = textures->getTextureLayer(i);
|
||||
|
||||
if (layer->displacement_height > 0.0)
|
||||
{
|
||||
|
|
|
@ -1,290 +0,0 @@
|
|||
#include "zone.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
#include "PackStream.h"
|
||||
#include "Curve.h"
|
||||
#include "tools.h"
|
||||
|
||||
#define MAX_CIRCLES 20
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double value;
|
||||
double centerx;
|
||||
double centerz;
|
||||
double softradius;
|
||||
double hardradius;
|
||||
} Circle;
|
||||
|
||||
struct Zone {
|
||||
int absolute_height;
|
||||
double relative_height_min;
|
||||
double relative_height_middle;
|
||||
double relative_height_max;
|
||||
|
||||
Curve* value_by_height;
|
||||
Curve* value_by_slope;
|
||||
|
||||
Circle circles_included[MAX_CIRCLES];
|
||||
int circles_included_count;
|
||||
};
|
||||
|
||||
Zone* zoneCreate()
|
||||
{
|
||||
Zone* result;
|
||||
|
||||
result = (Zone*)malloc(sizeof(Zone));
|
||||
result->value_by_height = new Curve;
|
||||
result->absolute_height = 1;
|
||||
result->value_by_height->setDefault(1.0);
|
||||
result->value_by_slope = new Curve;
|
||||
result->value_by_slope->setDefault(1.0);
|
||||
result->circles_included_count = 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void zoneDelete(Zone* zone)
|
||||
{
|
||||
delete zone->value_by_height;
|
||||
delete zone->value_by_slope;
|
||||
free(zone);
|
||||
}
|
||||
|
||||
void zoneSave(PackStream* stream, Zone* zone)
|
||||
{
|
||||
int i;
|
||||
|
||||
stream->write(&zone->absolute_height);
|
||||
stream->write(&zone->relative_height_min);
|
||||
stream->write(&zone->relative_height_middle);
|
||||
stream->write(&zone->relative_height_max);
|
||||
|
||||
zone->value_by_height->save(stream);
|
||||
zone->value_by_slope->save(stream);
|
||||
|
||||
stream->write(&zone->circles_included_count);
|
||||
for (i = 0; i < zone->circles_included_count; i++)
|
||||
{
|
||||
stream->write(&zone->circles_included[i].value);
|
||||
stream->write(&zone->circles_included[i].centerx);
|
||||
stream->write(&zone->circles_included[i].centerz);
|
||||
stream->write(&zone->circles_included[i].softradius);
|
||||
stream->write(&zone->circles_included[i].hardradius);
|
||||
}
|
||||
}
|
||||
|
||||
void zoneLoad(PackStream* stream, Zone* zone)
|
||||
{
|
||||
int i;
|
||||
|
||||
stream->read(&zone->absolute_height);
|
||||
stream->read(&zone->relative_height_min);
|
||||
stream->read(&zone->relative_height_middle);
|
||||
stream->read(&zone->relative_height_max);
|
||||
|
||||
zone->value_by_height->load(stream);
|
||||
zone->value_by_slope->load(stream);
|
||||
|
||||
stream->read(&zone->circles_included_count);
|
||||
for (i = 0; i < zone->circles_included_count; i++)
|
||||
{
|
||||
stream->read(&zone->circles_included[i].value);
|
||||
stream->read(&zone->circles_included[i].centerx);
|
||||
stream->read(&zone->circles_included[i].centerz);
|
||||
stream->read(&zone->circles_included[i].softradius);
|
||||
stream->read(&zone->circles_included[i].hardradius);
|
||||
}
|
||||
}
|
||||
|
||||
void zoneCopy(Zone* source, Zone* destination)
|
||||
{
|
||||
destination->absolute_height = source->absolute_height;
|
||||
destination->relative_height_min = source->relative_height_min;
|
||||
destination->relative_height_middle = source->relative_height_middle;
|
||||
destination->relative_height_max = source->relative_height_max;
|
||||
|
||||
source->value_by_height->copy(destination->value_by_height);
|
||||
source->value_by_slope->copy(destination->value_by_slope);
|
||||
|
||||
memcpy(destination->circles_included, source->circles_included, sizeof(Circle) * source->circles_included_count);
|
||||
destination->circles_included_count = source->circles_included_count;
|
||||
}
|
||||
|
||||
void zoneClear(Zone* zone)
|
||||
{
|
||||
zone->value_by_height->clear();
|
||||
zone->value_by_slope->clear();
|
||||
zone->circles_included_count = 0;
|
||||
}
|
||||
|
||||
void zoneSetAbsoluteHeight(Zone* zone)
|
||||
{
|
||||
zone->absolute_height = 1;
|
||||
}
|
||||
|
||||
void zoneSetRelativeHeight(Zone* zone, double min, double middle, double max)
|
||||
{
|
||||
if (max < min)
|
||||
{
|
||||
max = min;
|
||||
}
|
||||
if (middle < min)
|
||||
{
|
||||
middle = min;
|
||||
}
|
||||
if (middle > max)
|
||||
{
|
||||
middle = max;
|
||||
}
|
||||
|
||||
zone->absolute_height = 0;
|
||||
zone->relative_height_min = min;
|
||||
zone->relative_height_middle = middle;
|
||||
zone->relative_height_max = max;
|
||||
}
|
||||
|
||||
void zoneIncludeCircleArea(Zone* zone, double value, double centerx, double centerz, double softradius, double hardradius)
|
||||
{
|
||||
Circle circle = {value, centerx, centerz, softradius, hardradius};
|
||||
|
||||
if (zone->circles_included_count < MAX_CIRCLES)
|
||||
{
|
||||
zone->circles_included[zone->circles_included_count++] = circle;
|
||||
}
|
||||
}
|
||||
|
||||
void zoneGetHeightCurve(Zone* zone, Curve* curve)
|
||||
{
|
||||
zone->value_by_height->copy(curve);
|
||||
}
|
||||
|
||||
void zoneSetHeightCurve(Zone* zone, Curve* curve)
|
||||
{
|
||||
curve->copy(zone->value_by_height);
|
||||
}
|
||||
|
||||
void zoneAddHeightRangeQuick(Zone* zone, double value, double hardmin, double softmin, double softmax, double hardmax)
|
||||
{
|
||||
zone->value_by_height->addPoint(hardmin, 0.0);
|
||||
zone->value_by_height->addPoint(softmin, value);
|
||||
zone->value_by_height->addPoint(softmax, value);
|
||||
zone->value_by_height->addPoint(hardmax, 0.0);
|
||||
}
|
||||
|
||||
void zoneGetSlopeCurve(Zone* zone, Curve* curve)
|
||||
{
|
||||
zone->value_by_slope->copy(curve);
|
||||
}
|
||||
|
||||
void zoneSetSlopeCurve(Zone* zone, Curve* curve)
|
||||
{
|
||||
curve->copy(zone->value_by_slope);
|
||||
}
|
||||
|
||||
void zoneAddSlopeRangeQuick(Zone* zone, double value, double hardmin, double softmin, double softmax, double hardmax)
|
||||
{
|
||||
zone->value_by_slope->addPoint(hardmin, 0.0);
|
||||
zone->value_by_slope->addPoint(softmin, value);
|
||||
zone->value_by_slope->addPoint(softmax, value);
|
||||
zone->value_by_slope->addPoint(hardmax, 0.0);
|
||||
}
|
||||
|
||||
static inline double _getCircleInfluence(Circle circle, Vector3 position)
|
||||
{
|
||||
double radius, dx, dz;
|
||||
|
||||
dx = position.x - circle.centerx;
|
||||
dz = position.z - circle.centerz;
|
||||
radius = sqrt(dx * dx + dz * dz);
|
||||
|
||||
if (radius > circle.hardradius)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
else if (radius < circle.softradius)
|
||||
{
|
||||
return circle.value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return circle.value * (circle.hardradius - radius) / (circle.hardradius - circle.softradius);
|
||||
}
|
||||
}
|
||||
|
||||
double zoneGetValue(Zone* zone, Vector3 location, Vector3 normal)
|
||||
{
|
||||
int i;
|
||||
double final_height;
|
||||
double value, value_height, value_steepness, value_circle;
|
||||
|
||||
if (zone->circles_included_count > 0)
|
||||
{
|
||||
value_circle = 0.0;
|
||||
for (i = 0; i < zone->circles_included_count; i++)
|
||||
{
|
||||
value = _getCircleInfluence(zone->circles_included[i], location);
|
||||
if (value > value_circle)
|
||||
{
|
||||
value_circle = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value_circle = 1.0;
|
||||
}
|
||||
|
||||
if (zone->absolute_height)
|
||||
{
|
||||
final_height = location.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (location.y >= zone->relative_height_max)
|
||||
{
|
||||
final_height = 1.0;
|
||||
}
|
||||
else if (location.y <= zone->relative_height_min)
|
||||
{
|
||||
final_height = 0.0;
|
||||
}
|
||||
else if (location.y <= zone->relative_height_middle)
|
||||
{
|
||||
final_height = 0.5 * (location.y - zone->relative_height_min) / (zone->relative_height_middle - zone->relative_height_min);
|
||||
}
|
||||
else
|
||||
{
|
||||
final_height = 0.5 + 0.5 * (location.y - zone->relative_height_middle) / (zone->relative_height_max - zone->relative_height_middle);
|
||||
}
|
||||
}
|
||||
|
||||
value_height = zone->value_by_height->getValue(final_height);
|
||||
value_steepness = zone->value_by_slope->getValue(1.0 - normal.y);
|
||||
|
||||
if (value_steepness < value_height)
|
||||
{
|
||||
if (value_circle < value_steepness)
|
||||
{
|
||||
return value_circle;
|
||||
}
|
||||
else
|
||||
{
|
||||
return value_steepness;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value_circle < value_height)
|
||||
{
|
||||
return value_circle;
|
||||
}
|
||||
else
|
||||
{
|
||||
return value_height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
#ifndef _RENDERING_TOOLS_ZONE_H_
|
||||
#define _RENDERING_TOOLS_ZONE_H_
|
||||
|
||||
/**
|
||||
* Definition of a geographic area.
|
||||
*/
|
||||
|
||||
#include "../rendering_global.h"
|
||||
#include "../tools/euclid.h"
|
||||
|
||||
typedef struct Zone Zone;
|
||||
|
||||
RENDERINGSHARED_EXPORT Zone* zoneCreate();
|
||||
RENDERINGSHARED_EXPORT void zoneDelete(Zone* zone);
|
||||
RENDERINGSHARED_EXPORT void zoneSave(PackStream* stream, Zone* zone);
|
||||
RENDERINGSHARED_EXPORT void zoneLoad(PackStream* stream, Zone* zone);
|
||||
RENDERINGSHARED_EXPORT void zoneCopy(Zone* source, Zone* destination);
|
||||
RENDERINGSHARED_EXPORT void zoneClear(Zone* zone);
|
||||
|
||||
RENDERINGSHARED_EXPORT void zoneSetAbsoluteHeight(Zone* zone);
|
||||
RENDERINGSHARED_EXPORT void zoneSetRelativeHeight(Zone* zone, double min, double middle, double max);
|
||||
|
||||
RENDERINGSHARED_EXPORT void zoneIncludeCircleArea(Zone* zone, double value, double centerx, double centerz, double softradius, double hardradius);
|
||||
RENDERINGSHARED_EXPORT void zoneExcludeCircleArea(Zone* zone, double centerx, double centerz, double softradius, double hardradius);
|
||||
|
||||
RENDERINGSHARED_EXPORT void zoneGetHeightCurve(Zone* zone, Curve* curve);
|
||||
RENDERINGSHARED_EXPORT void zoneSetHeightCurve(Zone* zone, Curve* curve);
|
||||
RENDERINGSHARED_EXPORT void zoneAddHeightRangeQuick(Zone* zone, double value, double hardmin, double softmin, double softmax, double hardmax);
|
||||
|
||||
RENDERINGSHARED_EXPORT void zoneGetSlopeCurve(Zone* zone, Curve* curve);
|
||||
RENDERINGSHARED_EXPORT void zoneSetSlopeCurve(Zone* zone, Curve* curve);
|
||||
RENDERINGSHARED_EXPORT void zoneAddSlopeRangeQuick(Zone* zone, double value, double hardmin, double softmin, double softmax, double hardmax);
|
||||
|
||||
RENDERINGSHARED_EXPORT double zoneGetValue(Zone* zone, Vector3 location, Vector3 normal);
|
||||
|
||||
#endif
|
|
@ -78,92 +78,3 @@ TEST(Layers, maxLayerCount)
|
|||
layers1.addLayer();
|
||||
EXPECT_EQ(2, layers1.count());
|
||||
}
|
||||
|
||||
static int _legacy_instance_count = 0;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int a;
|
||||
} LegacyData;
|
||||
|
||||
static void* _legacy_create()
|
||||
{
|
||||
LegacyData* data = new LegacyData;
|
||||
data->a = 2;
|
||||
_legacy_instance_count++;
|
||||
return data;
|
||||
}
|
||||
|
||||
static void _legacy_delete(void* data)
|
||||
{
|
||||
delete (LegacyData*)data;
|
||||
_legacy_instance_count--;
|
||||
}
|
||||
|
||||
static void _legacy_save(PackStream* stream, void* data)
|
||||
{
|
||||
stream->write(&((LegacyData*)data)->a);
|
||||
}
|
||||
|
||||
static void _legacy_load(PackStream* stream, void* data)
|
||||
{
|
||||
stream->read(&((LegacyData*)data)->a);
|
||||
}
|
||||
|
||||
static void _legacy_validate(void* data)
|
||||
{
|
||||
LegacyData* ldata = (LegacyData*)data;
|
||||
if (ldata->a > 5)
|
||||
{
|
||||
ldata->a = 5;
|
||||
}
|
||||
}
|
||||
|
||||
static void _legacy_copy(void* source, void* destination)
|
||||
{
|
||||
((LegacyData*)destination)->a = ((LegacyData*)source)->a;
|
||||
}
|
||||
|
||||
TEST(Layers, LegacyLayers)
|
||||
{
|
||||
LayerType type;
|
||||
type.callback_create = _legacy_create;
|
||||
type.callback_delete = _legacy_delete;
|
||||
type.callback_save = _legacy_save;
|
||||
type.callback_load = _legacy_load;
|
||||
type.callback_validate = _legacy_validate;
|
||||
type.callback_copy = _legacy_copy;
|
||||
|
||||
Layers* layers1 = layersCreate(type, 3);
|
||||
|
||||
LegacyData* data1;
|
||||
|
||||
// Test the null layer
|
||||
EXPECT_EQ(0, layersCount(layers1));
|
||||
EXPECT_EQ(1, _legacy_instance_count);
|
||||
data1 = (LegacyData*)layersGetLayer(layers1, 0);
|
||||
EXPECT_EQ(2, data1->a);
|
||||
data1->a = 3;
|
||||
data1 = (LegacyData*)layersGetLayer(layers1, 0);
|
||||
EXPECT_EQ(3, data1->a);
|
||||
|
||||
// Add an empty layer
|
||||
layersAddLayer(layers1, NULL);
|
||||
EXPECT_EQ(1, layersCount(layers1));
|
||||
data1 = (LegacyData*)layersGetLayer(layers1, 0);
|
||||
EXPECT_EQ(2, data1->a);
|
||||
EXPECT_EQ(2, _legacy_instance_count);
|
||||
|
||||
// Validation
|
||||
data1->a = 6;
|
||||
layersValidate(layers1);
|
||||
EXPECT_EQ(5, data1->a);
|
||||
|
||||
// Naming
|
||||
layersSetName(layers1, 0, "test1");
|
||||
EXPECT_EQ(QString("test1"), QString(layersGetName(layers1, 0)));
|
||||
|
||||
// Deletion
|
||||
delete layers1;
|
||||
EXPECT_EQ(0, _legacy_instance_count);
|
||||
}
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
#include "BaseTestCase.h"
|
||||
|
||||
#include "tools/zone.h"
|
||||
#include "Zone.h"
|
||||
#include "Vector3.h"
|
||||
|
||||
class Zone_Test : public BaseTestCase {
|
||||
protected:
|
||||
virtual void SetUp() {
|
||||
zone = zoneCreate();
|
||||
zone = new Zone;
|
||||
}
|
||||
|
||||
virtual void TearDown()
|
||||
{
|
||||
zoneDelete(zone);
|
||||
delete zone;
|
||||
}
|
||||
|
||||
Zone* zone;
|
||||
|
@ -18,39 +19,39 @@ protected:
|
|||
|
||||
TEST_F(Zone_Test, absolute_height)
|
||||
{
|
||||
zoneAddHeightRangeQuick(zone, 1.0, -1.0, 2.0, 5.0, 6.0);
|
||||
zone->addHeightRangeQuick(1.0, -1.0, 2.0, 5.0, 6.0);
|
||||
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, -10.0, 0.0), VECTOR_UP), 0.0);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, -2.0, 0.0), VECTOR_UP), 0.0);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, -1.0, 0.0), VECTOR_UP), 0.0);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, -0.5, 0.0), VECTOR_UP), 1.0 / 6.0);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, 0.0, 0.0), VECTOR_UP), 1.0 / 3.0);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, 0.5, 0.0), VECTOR_UP), 0.5);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, 2.0, 0.0), VECTOR_UP), 1.0);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, 2.1, 0.0), VECTOR_UP), 1.0);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, 3.5, 0.0), VECTOR_UP), 1.0);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, 4.9, 0.0), VECTOR_UP), 1.0);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, 5.0, 0.0), VECTOR_UP), 1.0);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, 5.2, 0.0), VECTOR_UP), 0.8);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, 5.7, 0.0), VECTOR_UP), 0.3);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, 6.0, 0.0), VECTOR_UP), 0.0);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, 15.0, 0.0), VECTOR_UP), 0.0);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, 150.0, 0.0), VECTOR_UP), 0.0);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, -10.0, 0.0), VECTOR_UP), 0.0);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, -2.0, 0.0), VECTOR_UP), 0.0);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, -1.0, 0.0), VECTOR_UP), 0.0);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, -0.5, 0.0), VECTOR_UP), 1.0 / 6.0);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 0.0, 0.0), VECTOR_UP), 1.0 / 3.0);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 0.5, 0.0), VECTOR_UP), 0.5);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 2.0, 0.0), VECTOR_UP), 1.0);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 2.1, 0.0), VECTOR_UP), 1.0);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 3.5, 0.0), VECTOR_UP), 1.0);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 4.9, 0.0), VECTOR_UP), 1.0);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 5.0, 0.0), VECTOR_UP), 1.0);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 5.2, 0.0), VECTOR_UP), 0.8);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 5.7, 0.0), VECTOR_UP), 0.3);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 6.0, 0.0), VECTOR_UP), 0.0);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 15.0, 0.0), VECTOR_UP), 0.0);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 150.0, 0.0), VECTOR_UP), 0.0);
|
||||
}
|
||||
|
||||
TEST_F(Zone_Test, relative_height)
|
||||
{
|
||||
zoneAddHeightRangeQuick(zone, 1.0, 0.2, 0.3, 0.6, 0.9);
|
||||
zoneSetRelativeHeight(zone, -2.0, 2.0, 8.0);
|
||||
zone->addHeightRangeQuick(1.0, 0.2, 0.3, 0.6, 0.9);
|
||||
zone->setRelativeHeight(-2.0, 2.0, 8.0);
|
||||
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, -10.0, 0.0), VECTOR_UP), 0.0);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, -2.1, 0.0), VECTOR_UP), 0.0);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, -2.0, 0.0), VECTOR_UP), 0.0);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, -1.0, 0.0), VECTOR_UP), 0.0);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, -0.5, 0.0), VECTOR_UP), 0.0);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, -0.2, 0.0), VECTOR_UP), 0.25);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, 0.0, 0.0), VECTOR_UP), 0.5);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, 0.3, 0.0), VECTOR_UP), 0.875);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, 0.5, 0.0), VECTOR_UP), 1.0);
|
||||
EXPECT_DOUBLE_EQ(zoneGetValue(zone, v3(0.0, 1.0, 0.0), VECTOR_UP), 1.0);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, -10.0, 0.0), VECTOR_UP), 0.0);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, -2.1, 0.0), VECTOR_UP), 0.0);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, -2.0, 0.0), VECTOR_UP), 0.0);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, -1.0, 0.0), VECTOR_UP), 0.0);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, -0.5, 0.0), VECTOR_UP), 0.0);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, -0.2, 0.0), VECTOR_UP), 0.25);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 0.0, 0.0), VECTOR_UP), 0.5);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 0.3, 0.0), VECTOR_UP), 0.875);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 0.5, 0.0), VECTOR_UP), 1.0);
|
||||
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 1.0, 0.0), VECTOR_UP), 1.0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue