paysages: Textures form (WIP)

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@286 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-04-05 16:16:32 +00:00 committed by ThunderK
parent b831dd717f
commit c51e9b676a
3 changed files with 43 additions and 16 deletions

View file

@ -2,6 +2,7 @@
#include "../lib_paysages/textures.h" #include "../lib_paysages/textures.h"
#include "../lib_paysages/scenery.h" #include "../lib_paysages/scenery.h"
#include "tools.h"
static TexturesDefinition _definition; static TexturesDefinition _definition;
static TextureLayerDefinition _layer; static TextureLayerDefinition _layer;
@ -37,23 +38,49 @@ class PreviewTexturesColor:public BasePreview
public: public:
PreviewTexturesColor(QWidget* parent):BasePreview(parent) PreviewTexturesColor(QWidget* parent):BasePreview(parent)
{ {
LightDefinition light;
_preview_layer = texturesLayerCreateDefinition();
_lighting = lightingCreateDefinition();
light.color = COLOR_WHITE;
light.amplitude = 0.0;
light.direction.x = 0.0;
light.direction.y = -0.4794;
light.direction.z = 0.8776;
light.filtered = 0;
light.masked = 0;
light.reflection = 1.0;
lightingAddLight(&_lighting, light);
lightingValidateDefinition(&_lighting);
_renderer = rendererCreate(); _renderer = rendererCreate();
_renderer.render_quality = 3; _renderer.render_quality = 3;
_renderer.applyLightingToSurface = _applyLightingToSurface;
_preview_layer = texturesLayerCreateDefinition(); _renderer.customData[0] = &_lighting;
} }
protected: protected:
QColor getColor(double x, double y) QColor getColor(double x, double y)
{ {
return QColor(0, 0, 0); Vector3 location;
location.x = x * 0.01;
location.y = 0.0;
location.z = y * 0.01;
return colorToQColor(texturesGetLayerColor(&_preview_layer, &_renderer, location, this->scaling * 0.01));
} }
void updateData() void updateData()
{ {
texturesLayerCopyDefinition(&_layer, &_preview_layer); texturesLayerCopyDefinition(&_layer, &_preview_layer);
} }
private: private:
static Color _applyLightingToSurface(Renderer* renderer, Vector3 location, Vector3 normal, SurfaceMaterial material)
{
return lightingApplyToSurface((LightingDefinition*)renderer->customData[0], renderer, location, normal, material);
}
Renderer _renderer; Renderer _renderer;
TextureLayerDefinition _preview_layer; TextureLayerDefinition _preview_layer;
LightingDefinition _lighting;
}; };
/**************** Form ****************/ /**************** Form ****************/

View file

@ -477,32 +477,32 @@ Maintenir Ctrl : Plus rapide</translation>
<context> <context>
<name>FormTextures</name> <name>FormTextures</name>
<message> <message>
<location filename="../gui_qt/formtextures.cpp" line="71"/> <location filename="../gui_qt/formtextures.cpp" line="98"/>
<source>Surface noise</source> <source>Surface noise</source>
<translation>Bruit de surface</translation> <translation>Bruit de surface</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formtextures.cpp" line="72"/> <location filename="../gui_qt/formtextures.cpp" line="99"/>
<source>Surface noise height</source> <source>Surface noise height</source>
<translation>Hauteur du bruit</translation> <translation>Hauteur du bruit</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formtextures.cpp" line="73"/> <location filename="../gui_qt/formtextures.cpp" line="100"/>
<source>Surface noise scaling</source> <source>Surface noise scaling</source>
<translation>Echelle du bruit</translation> <translation>Echelle du bruit</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formtextures.cpp" line="74"/> <location filename="../gui_qt/formtextures.cpp" line="101"/>
<source>Base color</source> <source>Base color</source>
<translation>Couleur de base</translation> <translation>Couleur de base</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formtextures.cpp" line="75"/> <location filename="../gui_qt/formtextures.cpp" line="102"/>
<source>Light reflection</source> <source>Light reflection</source>
<translation>Réflexion de lumière</translation> <translation>Réflexion de lumière</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formtextures.cpp" line="76"/> <location filename="../gui_qt/formtextures.cpp" line="103"/>
<source>Light reflection shininess</source> <source>Light reflection shininess</source>
<translation>Concentration de la réflexion de lumière</translation> <translation>Concentration de la réflexion de lumière</translation>
</message> </message>

View file

@ -172,25 +172,25 @@ void autoGenRealisticLandscape(int seed)
texture = texturesGetLayer(&textures, texturesAddLayer(&textures)); texture = texturesGetLayer(&textures, texturesAddLayer(&textures));
noiseGenerateBaseNoise(texture->bump_noise, 102400); noiseGenerateBaseNoise(texture->bump_noise, 102400);
noiseAddLevelsSimple(texture->bump_noise, 6, 1.0, 1.0); noiseAddLevelsSimple(texture->bump_noise, 6, 1.0, 1.0);
texture->bump_height = 0.01; texture->bump_height = 0.1;
texture->bump_scaling = 1.0; texture->bump_scaling = 0.15;
texture->material.base.r = 0.6; texture->material.base.r = 0.6;
texture->material.base.g = 0.55; texture->material.base.g = 0.55;
texture->material.base.b = 0.57; texture->material.base.b = 0.57;
texture->material.reflection = 0.4; texture->material.reflection = 0.2;
texture->material.shininess = 0.1; texture->material.shininess = 3.0;
texture = texturesGetLayer(&textures, texturesAddLayer(&textures)); texture = texturesGetLayer(&textures, texturesAddLayer(&textures));
zoneAddHeightRange(texture->zone, 1.0, -1.0, 0.0, 3.0, 15.0); zoneAddHeightRange(texture->zone, 1.0, -1.0, 0.0, 3.0, 15.0);
zoneAddSteepnessRange(texture->zone, 1.0, 0.0, 0.0, 0.2, 0.3); zoneAddSteepnessRange(texture->zone, 1.0, 0.0, 0.0, 0.2, 0.3);
noiseGenerateBaseNoise(texture->bump_noise, 102400); noiseGenerateBaseNoise(texture->bump_noise, 102400);
noiseAddLevelsSimple(texture->bump_noise, 6, 1.0, 0.4); noiseAddLevelsSimple(texture->bump_noise, 6, 1.0, 0.4);
texture->bump_height = 0.02; texture->bump_height = 0.02;
texture->bump_scaling = 1.0; texture->bump_scaling = 0.1;
texture->material.base.r = 0.2; texture->material.base.r = 0.2;
texture->material.base.g = 0.24; texture->material.base.g = 0.24;
texture->material.base.b = 0.05; texture->material.base.b = 0.05;
texture->material.reflection = 0.2; texture->material.reflection = 0.1;
texture->material.shininess = 0.02; texture->material.shininess = 2.0;
/*texture = texturesGetLayer(&textures, texturesAddLayer(&textures)); /*texture = texturesGetLayer(&textures, texturesAddLayer(&textures));
zoneAddHeightRange(texture->zone, 1.0, 3.0, 4.0, 100.0, 100.0); zoneAddHeightRange(texture->zone, 1.0, 3.0, 4.0, 100.0, 100.0);
noiseGenerateBaseNoise(texture->bump_noise, 102400); noiseGenerateBaseNoise(texture->bump_noise, 102400);