From 3d615227110f76f129386ba1dbe6cbafa9bf5484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Mon, 9 Apr 2012 08:33:13 +0000 Subject: [PATCH] paysages: Fixed terrain ray walking (added backward estimation of true intersection) + fixed textures lighted preview. git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@289 b1fd45b6-86a6-48da-8261-f70d1f35bdcc --- gui_qt/baseform.cpp | 1 - gui_qt/formtextures.cpp | 3 +++ gui_qt/mainwindow.cpp | 2 +- i18n/paysages_fr.ts | 44 ++++++++++++++++++++-------------------- images/logo.ico | Bin 0 -> 4286 bytes lib_paysages/auto.c | 4 ++-- lib_paysages/terrain.c | 14 +++++++++++-- 7 files changed, 40 insertions(+), 28 deletions(-) create mode 100644 images/logo.ico diff --git a/gui_qt/baseform.cpp b/gui_qt/baseform.cpp index 855281a..81276f1 100644 --- a/gui_qt/baseform.cpp +++ b/gui_qt/baseform.cpp @@ -11,7 +11,6 @@ #include #include #include -#include BaseForm::BaseForm(QWidget* parent, bool auto_apply, bool with_layers) : QWidget(parent) { diff --git a/gui_qt/formtextures.cpp b/gui_qt/formtextures.cpp index ed039e6..c1f4dde 100644 --- a/gui_qt/formtextures.cpp +++ b/gui_qt/formtextures.cpp @@ -88,6 +88,9 @@ public: _renderer.render_quality = 3; _renderer.applyLightingToSurface = _applyLightingToSurface; _renderer.customData[0] = &_lighting; + _renderer.camera_location.x = 0.0; + _renderer.camera_location.y = 20.0; + _renderer.camera_location.z = 0.0; } protected: QColor getColor(double x, double y) diff --git a/gui_qt/mainwindow.cpp b/gui_qt/mainwindow.cpp index 733dcf6..b820bdb 100644 --- a/gui_qt/mainwindow.cpp +++ b/gui_qt/mainwindow.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include "formatmosphere.h" #include "formclouds.h" diff --git a/i18n/paysages_fr.ts b/i18n/paysages_fr.ts index 2865165..d15965a 100644 --- a/i18n/paysages_fr.ts +++ b/i18n/paysages_fr.ts @@ -4,32 +4,32 @@ BaseForm - + Layers : Niveaux : - + Add layer Ajouter un niveau - + Delete layer Supprimer un niveau - + Apply Appliquer - + Revert Annuler les modifications - + Layer %1 Niveau %1 @@ -477,7 +477,7 @@ Maintenir Ctrl : Plus rapide FormTextures - + Coverage preview Aperçu de la couverture @@ -486,77 +486,77 @@ Maintenir Ctrl : Plus rapide Rendu en couleur - + Lighted sample Echantillon éclairé - + Surface noise Bruit de surface - + Surface noise height Hauteur du bruit - + Surface noise scaling Echelle du bruit - + Base color Couleur de base - + Light reflection Réflexion de lumière - + Light reflection shininess Concentration de la réflexion de lumière - + Soft minimal height Altitude minimal (adoucie) - + Hard minimal height Altitude minimale - + Hard maximal height Altitude maximale - + Soft maximal height Altitude maximale (adoucie) - + Soft minimal slope Pente minimale (adoucie) - + Hard minimal slope Pente minimale - + Hard maximal slope Pente maximale - + Soft maximal slope Pente maximale (adoucie) diff --git a/images/logo.ico b/images/logo.ico new file mode 100644 index 0000000000000000000000000000000000000000..a6f3850798013bfd6be605db1a54e94534089cd2 GIT binary patch literal 4286 zcmeHJOKeU-6rQ%CMB+^(5}J^-VP(dn-qKpxun>=pO^HZXO+*M$D;tD(#N&>lArX%M&oq64R)Bo3o?sS@S=bSTVzVFPL$6v-O@K;mA=*upT zWo$BItPTPfTLB^eP#dbipj9B@j7d?!5?*03rL`+rB2o&{rKq%$AeQ2tkUx$48;$s> zB~64i9x}o?{Fm|>NDDYjxpmk%S-k{^T|3q-`E&3Ztl8LJiVvvAo;V{B0{$-;{|xyA z>4yCPasqMnHje7Tl%JwjGNyON`Any3R!exLH6`x^Ry%OFLk>Z{!$v;*tQ}AI6!^NV zPl|W&zknduC@l^)^3MamK|bv%U5Om1w%L6S!3m%5xOgu(W>~l69X_XBAq-=OV-AT} z4bC_Oy#xHnLDyuQc{S{r&4cz~PL&Oir~|Fvt#6k1UG(}sHW zZGt~H+Zi&R{YR*WKL@C7BGNM;d9$zoM>{F*omk`eF)!EjD9``cxwYHtT#Pr;Iy8a< zYv)%y=1t@<#YQE3L7JPG5MiWf=*zGD9nh#1odaDPZQg>L2He2t6U-0}@ zzRt8S4G~X@tDe6YeJOU6=ildY(6}o)f4@Vl6f2R(Ibf{={wA#TwXJu;Z%14yaPIBB zc!sg-&|g}c&Pl?L#<-|x{B+V8R5*)zhu6t|2YVkRQ%9V0$$wc+d-g03?m2Iaa8jId zIf-7Ehv-31Iqi)xR#6#KVgK!2oQQrBWHDp|a=3*4HRNCnJ~@9X_~wFR1!O5?oE-~y zRAS#HpACN+5e&CPlG|7twwdZvq``UZY_i|rmPE03WTxfu1(#e})# zXY?IWt$q!_q82dpdC%W$-MLR(|7IV9b3jdH_Q`qr|LS4Dc!Rl}`B=5vW1n_@dW%DD zcl(%UE~cOV9b8a}uO1D&yTBq@>ao^3Y;_|)LCuB#0OW@sr+c!_&&h`l$jaud zw*c!Yq$kC;zsFx;|4e=MZKC_}1in=RqA43hdr9XuS6lpktBvr{*}xmEj=5eRfp0(b zt>_m*{Cu2C^=2Py2*+LGnE&wMz*g+@G!R98+q4qyjz?5snY1O8!~H64(*^##+!3S+9P3U7@m6pSerA-%1pXh@cuTadQB%gw!=t>zO0L3KG2 GV}1iQ?zone, 1.0, -20.0, -20.0, 20.0, 20.0); zoneAddSlopeRangeQuick(texture->zone, 1.0, 0.0, 0.0, 5.0, 5.0); noiseGenerateBaseNoise(texture->bump_noise, 102400); - noiseAddLevelsSimple(texture->bump_noise, 6, 1.0, 1.0); + noiseAddLevelsSimple(texture->bump_noise, 8, 1.0, 1.0); texture->bump_height = 0.1; texture->bump_scaling = 0.15; texture->material.base.r = 0.6; @@ -163,7 +163,7 @@ void autoGenRealisticLandscape(int seed) zoneAddHeightRangeQuick(texture->zone, 1.0, -1.0, 0.0, 3.0, 15.0); zoneAddSlopeRangeQuick(texture->zone, 1.0, 0.0, 0.0, 0.2, 0.3); noiseGenerateBaseNoise(texture->bump_noise, 102400); - noiseAddLevelsSimple(texture->bump_noise, 6, 1.0, 0.4); + noiseAddLevelsSimple(texture->bump_noise, 8, 1.0, 0.4); texture->bump_height = 0.02; texture->bump_scaling = 0.1; texture->material.base.r = 0.2; diff --git a/lib_paysages/terrain.c b/lib_paysages/terrain.c index 7326387..87f7206 100644 --- a/lib_paysages/terrain.c +++ b/lib_paysages/terrain.c @@ -250,12 +250,13 @@ static Color _getColor(TerrainDefinition* definition, Renderer* renderer, Vector int terrainProjectRay(TerrainDefinition* definition, Renderer* renderer, Vector3 start, Vector3 direction, Vector3* hit_point, Color* hit_color) { Vector3 inc_vector; - double inc_value, inc_base, inc_factor, height, diff, length; + double inc_value, inc_base, inc_factor, height, diff, lastdiff, length; direction = v3Normalize(direction); inc_factor = (double)renderer->render_quality; inc_base = 1.0; inc_value = inc_base / inc_factor; + lastdiff = start.y - _getHeight(definition, start.x, start.z); length = 0.0; do @@ -267,7 +268,15 @@ int terrainProjectRay(TerrainDefinition* definition, Renderer* renderer, Vector3 diff = start.y - height; if (diff < 0.0) { - start.y = height; + if (fabs(diff - lastdiff) > 0.00001) + { + start = v3Add(start, v3Scale(inc_vector, -diff / (diff - lastdiff))); + start.y = _getHeight(definition, start.x, start.z); + } + else + { + start.y = height; + } *hit_point = start; *hit_color = _getColor(definition, renderer, start, renderer->getPrecision(renderer, start)); return 1; @@ -285,6 +294,7 @@ int terrainProjectRay(TerrainDefinition* definition, Renderer* renderer, Vector3 { inc_value = diff; } + lastdiff = diff; } while (length < 50.0 && start.y <= definition->_max_height); return 0;