paysages : Small improvements.
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@405 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
bca21193c3
commit
7d446591c9
9 changed files with 41 additions and 10 deletions
1
TODO
1
TODO
|
@ -12,7 +12,6 @@ Technology Preview 2 :
|
|||
=> Add areas marking.
|
||||
- Improve terrain canvas editor.
|
||||
=> Add GeoArea editor.
|
||||
=> Apply GeoArea to revertToTerrain.
|
||||
=> Resample map on changing resolution.
|
||||
=> Map loading should not choose arbitrary resolution.
|
||||
- Improve textures (current model is greatly incorrect).
|
||||
|
|
|
@ -28,6 +28,10 @@ void BaseFormLayer::applyConfig()
|
|||
BaseForm::applyConfig();
|
||||
}
|
||||
|
||||
void BaseFormLayer::afterLayerAdded(void*)
|
||||
{
|
||||
}
|
||||
|
||||
void BaseFormLayer::configChangeEvent()
|
||||
{
|
||||
layerApply(layersGetLayer(_layers_modified, currentLayer()));
|
||||
|
@ -57,7 +61,10 @@ void BaseFormLayer::layerAddedEvent()
|
|||
if (layer >= 0)
|
||||
{
|
||||
layersSetName(_layers_modified, layer, layer_name.toUtf8().data());
|
||||
|
||||
BaseForm::layerAddedEvent();
|
||||
|
||||
afterLayerAdded(layersGetLayer(_layers_modified, layer));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ public slots:
|
|||
protected:
|
||||
virtual void layerGetCopy(void* layer_definition) = 0;
|
||||
virtual void layerApply(void* layer_definition) = 0;
|
||||
virtual void afterLayerAdded(void* layer_definition);
|
||||
|
||||
private:
|
||||
virtual QStringList getLayers();
|
||||
|
|
|
@ -241,27 +241,27 @@ void DialogHeightMap::changeResolution()
|
|||
result = QInputDialog::getItem(this, tr("Paysages 3D - Change heightmap resolution"), tr("Choose the new heightmap resolution. Beware that lowering the resolution may imply a loss of accuracy."), items, current, false);
|
||||
if (!result.isEmpty())
|
||||
{
|
||||
int new_res_x, new_res_y;
|
||||
int new_res_x, new_res_z;
|
||||
if (result == QString("64 x 64"))
|
||||
{
|
||||
new_res_x = new_res_y = 64;
|
||||
new_res_x = new_res_z = 64;
|
||||
}
|
||||
else if (result == QString("256 x 256"))
|
||||
{
|
||||
new_res_x = new_res_y = 256;
|
||||
new_res_x = new_res_z = 256;
|
||||
}
|
||||
else if (result == QString("512 x 512"))
|
||||
{
|
||||
new_res_x = new_res_y = 512;
|
||||
new_res_x = new_res_z = 512;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_res_x = new_res_y = 128;
|
||||
new_res_x = new_res_z = 128;
|
||||
}
|
||||
|
||||
if (new_res_x != _value_modified.resolution_x or new_res_y != _value_modified.resolution_z)
|
||||
if (new_res_x != _value_modified.resolution_x or new_res_z != _value_modified.resolution_z)
|
||||
{
|
||||
heightmapChangeResolution(&_value_modified, 64, 64);
|
||||
heightmapChangeResolution(&_value_modified, new_res_x, new_res_z);
|
||||
_3dview->revert();
|
||||
updateResolutionLabel();
|
||||
}
|
||||
|
|
|
@ -72,3 +72,8 @@ void FormTerrainCanvas::layerApply(void* layer_definition)
|
|||
{
|
||||
terrainCanvasCopy(_definition, (TerrainCanvas*)layer_definition);
|
||||
}
|
||||
|
||||
void FormTerrainCanvas::afterLayerAdded(void* layer_definition)
|
||||
{
|
||||
terrainCanvasRevertToTerrain((TerrainCanvas*)layer_definition);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ public:
|
|||
protected:
|
||||
virtual void layerGetCopy(void* layer_definition);
|
||||
virtual void layerApply(void* layer_definition);
|
||||
virtual void afterLayerAdded(void* layer_definition);
|
||||
|
||||
private:
|
||||
TerrainCanvas* _definition;
|
||||
|
|
|
@ -51,3 +51,15 @@ void geoareaLoad(PackStream* stream, GeoArea* geoarea)
|
|||
packReadDouble(stream, &geoarea->size_x);
|
||||
packReadDouble(stream, &geoarea->size_z);
|
||||
}
|
||||
|
||||
void geoareaToLocal(GeoArea* geoarea, double absolute_x, double absolute_z, double* local_x, double* local_z)
|
||||
{
|
||||
*local_x = (absolute_x - geoarea->location_x) / geoarea->size_x;
|
||||
*local_z = (absolute_z - geoarea->location_z) / geoarea->size_z;
|
||||
}
|
||||
|
||||
void geoareaFromLocal(GeoArea* geoarea, double local_x, double local_z, double* absolute_x, double* absolute_z)
|
||||
{
|
||||
*absolute_x = geoarea->location_x + local_x * geoarea->size_x;
|
||||
*absolute_z = geoarea->location_z + local_z * geoarea->size_z;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,9 @@ void geoareaValidate(GeoArea* geoarea);
|
|||
|
||||
void geoareaSave(PackStream* stream, GeoArea* geoarea);
|
||||
void geoareaLoad(PackStream* stream, GeoArea* geoarea);
|
||||
|
||||
void geoareaToLocal(GeoArea* geoarea, double absolute_x, double absolute_z, double* local_x, double* local_z);
|
||||
void geoareaFromLocal(GeoArea* geoarea, double local_x, double local_z, double* absolute_x, double* absolute_z);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -167,6 +167,7 @@ void heightmapRevertToTerrain(HeightMap* heightmap, TerrainDefinition* terrain,
|
|||
{
|
||||
int rx, rz;
|
||||
int x, z;
|
||||
double dx, dz;
|
||||
|
||||
rx = heightmap->resolution_x;
|
||||
rz = heightmap->resolution_z;
|
||||
|
@ -174,8 +175,10 @@ void heightmapRevertToTerrain(HeightMap* heightmap, TerrainDefinition* terrain,
|
|||
{
|
||||
for (z = 0; z < rz; z++)
|
||||
{
|
||||
/* FIXME Apply geoarea */
|
||||
heightmap->data[z * rx + x] = terrainGetHeight(terrain, 80.0 * (double)x / (double)(rx - 1) - 40.0, 80.0 * (double)z / (double)(rz - 1) - 40.0);
|
||||
dx = (double)x / (double)(rx - 1);
|
||||
dz = (double)z / (double)(rz - 1);
|
||||
geoareaFromLocal(area, dx, dz, &dx, &dz);
|
||||
heightmap->data[z * rx + x] = terrainGetHeight(terrain, dx, dz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue