Commit b72fe097e8f37c960538e19ed50bcc2a768469df

Authored by Edmar Moretti
1 parent 122762fc

Correção na visualização em 3d, modificando-se a forma de sobreposição da imagem…

… do mapa ao modelo do relevo
Showing 1 changed file with 50 additions and 22 deletions   Show diff stats
ferramentas/3d/3d.php
@@ -21,7 +21,9 @@ Free Software Foundation, Inc., no endereço @@ -21,7 +21,9 @@ Free Software Foundation, Inc., no endereço
21 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. 21 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
22 */ 22 */
23 require_once("../../classesphp/pega_variaveis.php"); 23 require_once("../../classesphp/pega_variaveis.php");
  24 +require_once("../../classesphp/carrega_ext.php");
24 error_reporting(0); 25 error_reporting(0);
  26 +set_time_limit(120);
25 if (isset($g_sid)) 27 if (isset($g_sid))
26 {session_id($g_sid);} 28 {session_id($g_sid);}
27 session_name("i3GeoPHP"); 29 session_name("i3GeoPHP");
@@ -35,7 +37,7 @@ require_once("../../classesphp/funcoes_gerais.php"); @@ -35,7 +37,7 @@ require_once("../../classesphp/funcoes_gerais.php");
35 // 37 //
36 //carrega o phpmapscript 38 //carrega o phpmapscript
37 // 39 //
38 -if (!function_exists(ms_GetVersion)) 40 +if (!function_exists('ms_GetVersion'))
39 { 41 {
40 $exts = get_loaded_extensions(); 42 $exts = get_loaded_extensions();
41 if (array_search( "MapScript", $exts) != TRUE) 43 if (array_search( "MapScript", $exts) != TRUE)
@@ -64,10 +66,12 @@ if ($temaz=="") @@ -64,10 +66,12 @@ if ($temaz=="")
64 if ($maptemp == ""){echo "Arquivo com o relevo não foi encontrado";return;} 66 if ($maptemp == ""){echo "Arquivo com o relevo não foi encontrado";return;}
65 } 67 }
66 $mapa = ms_newMapObj($map_file); 68 $mapa = ms_newMapObj($map_file);
67 -if ($mapa->width > 400) 69 +if ($mapa->width > 500)
68 { 70 {
69 - $mapa->setsize(400,400); 71 + $mapa->setsize(500,500);
70 } 72 }
  73 +$of = $mapa->outputformat;
  74 +$of->set("imagemode",MS_IMAGEMODE_RGB);
71 $imgo = $mapa->draw(); 75 $imgo = $mapa->draw();
72 $nome = ($imgo->imagepath).nomeRandomico().".png"; 76 $nome = ($imgo->imagepath).nomeRandomico().".png";
73 $nomefinal = ($imgo->imagepath).nomeRandomico().".wrl"; 77 $nomefinal = ($imgo->imagepath).nomeRandomico().".wrl";
@@ -106,9 +110,12 @@ $imgo->saveImage($nome); @@ -106,9 +110,12 @@ $imgo->saveImage($nome);
106 $arquivoalt = $nome; 110 $arquivoalt = $nome;
107 111
108 $imgcor = imagecreatefrompng($arquivocor); 112 $imgcor = imagecreatefrompng($arquivocor);
  113 +$imgcor = flipImage($imgcor, true, false);
  114 +imagepng($imgcor,$arquivocor);
  115 +
109 $imgalt = imagecreatefrompng($arquivoalt); 116 $imgalt = imagecreatefrompng($arquivoalt);
110 -$sx = imagesx($imgcor);  
111 -$sy = imagesy($imgcor); 117 +$sx = imagesx($imgalt);
  118 +$sy = imagesy($imgalt);
112 $fp = fopen($nomefinal,"w"); 119 $fp = fopen($nomefinal,"w");
113 120
114 121
@@ -116,7 +123,12 @@ $texto = "#VRML V2.0 utf8 @@ -116,7 +123,12 @@ $texto = "#VRML V2.0 utf8
116 Group { 123 Group {
117 children [DirectionalLight { direction 0 -1 0 } 124 children [DirectionalLight { direction 0 -1 0 }
118 Shape { 125 Shape {
119 -appearance Appearance { material Material { diffuseColor .2 .2 .2}} 126 +appearance Appearance {
  127 + material Material { diffuseColor .2 .2 .2 }";
  128 +$texto .= "texture ImageTexture { url ".'"'.basename($arquivocor).'"';
  129 +$texto .= "}
  130 +}
  131 +
120 geometry ElevationGrid { 132 geometry ElevationGrid {
121 xDimension $sx 133 xDimension $sx
122 xSpacing 1 134 xSpacing 1
@@ -135,26 +147,12 @@ for ($y = 0; $y < $sy; $y++) @@ -135,26 +147,12 @@ for ($y = 0; $y < $sy; $y++)
135 $alt = imagecolorat($imgalt, $x, $y); 147 $alt = imagecolorat($imgalt, $x, $y);
136 $z = ($alt >> 16) & 0xFF; 148 $z = ($alt >> 16) & 0xFF;
137 fwrite($fp,($z/$fz)." "); 149 fwrite($fp,($z/$fz)." ");
  150 + //fwrite($fp,($alt)." ");
138 } 151 }
139 } 152 }
140 153
141 -$texto = "]  
142 -color Color { color [\n";  
143 -fwrite($fp,$texto);  
144 -  
145 -for ($y = 0; $y < $sy; $y++)  
146 -{  
147 - for ($x = 0; $x < $sx; $x++)  
148 - {  
149 - $cor = imagecolorat($imgcor, $x, $y);  
150 - $r = ($cor >> 16) & 0xFF;  
151 - $g = ($cor >> 8) & 0xFF;  
152 - $b = $cor & 0xFF;  
153 - fwrite($fp,($r/500)." ".($g/500)." ".($b/500)." ");  
154 - }  
155 -}  
156 154
157 -$texto = '] } 155 +$texto = ']
158 } 156 }
159 } 157 }
160 ] 158 ]
@@ -170,4 +168,34 @@ echo &quot;&lt;br&gt;&lt;a id=abre href=&#39;&#39; &gt;Clique aqui&lt;/a&gt;&quot;; @@ -170,4 +168,34 @@ echo &quot;&lt;br&gt;&lt;a id=abre href=&#39;&#39; &gt;Clique aqui&lt;/a&gt;&quot;;
170 echo "<br><br>x:$x y:$y"; 168 echo "<br><br>x:$x y:$y";
171 169
172 echo "<script>document.getElementById('abre').href=".$h."</script>"; 170 echo "<script>document.getElementById('abre').href=".$h."</script>";
  171 +
  172 +
  173 + function flipImage($image, $vertical, $horizontal) {
  174 + $w = imagesx($image);
  175 + $h = imagesy($image);
  176 +
  177 + if (!$vertical && !$horizontal) return $image;
  178 +
  179 + $flipped = imagecreatetruecolor($w, $h);
  180 +
  181 + if ($vertical) {
  182 + for ($y=0; $y<$h; $y++) {
  183 + imagecopy($flipped, $image, 0, $y, 0, $h - $y - 1, $w, 1);
  184 + }
  185 + }
  186 +
  187 + if ($horizontal) {
  188 + if ($vertical) {
  189 + $image = $flipped;
  190 + $flipped = imagecreatetruecolor($w, $h);
  191 + }
  192 +
  193 + for ($x=0; $x<$w; $x++) {
  194 + imagecopy($flipped, $image, $x, 0, $w - $x - 1, 0, 1, $h);
  195 + }
  196 + }
  197 +
  198 + return $flipped;
  199 + }
  200 +
173 ?> 201 ?>