Add texture displacement info in terrain tab

This commit is contained in:
Michaël Lemaire 2013-06-20 22:11:41 +02:00
parent ce4bddad4f
commit 62a956a65f
5 changed files with 34 additions and 4 deletions

View file

@ -7,6 +7,7 @@
#include "previewterrainshape.h" #include "previewterrainshape.h"
#include "tools.h" #include "tools.h"
#include "rendering/scenery.h" #include "rendering/scenery.h"
#include "rendering/textures/public.h"
MainTerrainForm::MainTerrainForm(QWidget *parent) : MainTerrainForm::MainTerrainForm(QWidget *parent) :
QWidget(parent), QWidget(parent),
@ -67,7 +68,19 @@ void MainTerrainForm::refreshFromLocalData()
void MainTerrainForm::refreshFromFellowData() void MainTerrainForm::refreshFromFellowData()
{ {
// TODO Refresh texture info TexturesDefinition* textures = (TexturesDefinition*)TexturesDefinitionClass.create();
sceneryGetTextures(textures);
double disp = texturesGetMaximalDisplacement(textures);
TexturesDefinitionClass.destroy(textures);
if (disp == 0.0)
{
ui->label_info_textures->setText(tr("No displacement textures"));
}
else
{
ui->label_info_textures->setText(tr("Maximal displacement : %1% of total height").arg(100.0 * disp / _terrain->height, 0, 'f', 1));
}
} }
void MainTerrainForm::updateLocalDataFromScenery() void MainTerrainForm::updateLocalDataFromScenery()

View file

@ -298,7 +298,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="label_info_textures">
<property name="text"> <property name="text">
<string notr="true">{ textures info }</string> <string notr="true">{ textures info }</string>
</property> </property>

View file

@ -274,7 +274,6 @@ void WidgetHeightMap::timerEvent(QTimerEvent*)
void WidgetHeightMap::initializeGL() void WidgetHeightMap::initializeGL()
{ {
glClearColor(0.0, 0.0, 0.0, 0.0); glClearColor(0.0, 0.0, 0.0, 0.0);
GLfloat light_diffuse[] = {0.75, 0.74, 0.7, 1.0}; GLfloat light_diffuse[] = {0.75, 0.74, 0.7, 1.0};
@ -312,7 +311,6 @@ void WidgetHeightMap::initializeGL()
void WidgetHeightMap::resizeGL(int w, int h) void WidgetHeightMap::resizeGL(int w, int h)
{ {
glViewport(0, 0, w, h); glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);

View file

@ -96,6 +96,8 @@ LayerType texturesGetLayerType();
void texturesAutoPreset(TexturesDefinition* definition, TexturesPreset preset); void texturesAutoPreset(TexturesDefinition* definition, TexturesPreset preset);
void texturesLayerAutoPreset(TexturesLayerDefinition* definition, TexturesLayerPreset preset); void texturesLayerAutoPreset(TexturesLayerDefinition* definition, TexturesLayerPreset preset);
double texturesGetMaximalDisplacement(TexturesDefinition* textures);
/*Renderer* cloudsCreatePreviewCoverageRenderer(); /*Renderer* cloudsCreatePreviewCoverageRenderer();
Color cloudsGetPreviewCoverage(Renderer* renderer, double x, double y, double scaling, int perspective); Color cloudsGetPreviewCoverage(Renderer* renderer, double x, double y, double scaling, int perspective);

View file

@ -32,3 +32,20 @@ double texturesGetTriplanarNoise(NoiseGenerator* noise, Vector3 location, Vector
return noiseXY * mXY + noiseXZ * mXZ + noiseYZ * mYZ; return noiseXY * mXY + noiseXZ * mXZ + noiseYZ * mYZ;
} }
double texturesGetMaximalDisplacement(TexturesDefinition* textures)
{
int i, n;
double disp = 0.0;
n = layersCount(textures->layers);
for (i = 0; i < n; i++)
{
TexturesLayerDefinition* layer = layersGetLayer(textures->layers, i);
if (layer->displacement_height > 0.0)
{
disp += layer->displacement_height;
}
}
return disp;
}