alias goDEMs { ; 90-meter with 7z.exe 7z.dll in folder or path ; http://www.webgis.com/terr_pages/AZ/dem1/coconino.html ; mostly Spatial Resolution 30 30 1 - Hawaii 3 3 1 ; New instructions deminit ; Set %WorkingDir - download zips -- no pasting html to dems.txt ; /unzipall ... make unzip.txt - open and check it. resave as .bat ; unzip_bat ... same-name files exist! a(u)to rename to keep all: u ; set in dems_batch -- %parameters = 0 0 5 0 0 ; /dems_batch ... make rename.txt - open and check it. resave as .bat ; rename_bat ... rename DEM files ; /dems_batch ... make dem2tga.txt, with renamed DEM files, for tga files ; dem2tga_bat ... DEMPOV nelson.dem nelson.tga 0 0 5 0 0 demHeadRead demsort } alias deminit { %parameters = 0 0 15 0 %WorkingDir = c:\ftp\dempov\kauai %proj = kauai %useDEMfilename = 1 ; skip rename to header name, if DEM filenames are ok %headformat = 0 ; 0 old, 1 new - and set by demHeadRead e Arguments: %parameters e %WorkingDir e Project Name: %proj e useDEMfilename: %useDEMfilename e Header Format: %headformat ; if (!init) program uses defaults } menu status { - DEM Commands .DEM Initialize: deminit .Make unzipbat.txt: unzipall .DEMPOV Batch Files: dems_batch .Read DEM Headers: demHeadRead .Sort DEMs: demsort .View #macro: view_macro } alias ParametersAre { if (4parameters) bias = -min_elevation 0 all 0 or 1 normalize 1 verticalScale [ bias ] optional 0 default elevation/edge stuff ? } alias dems_batch { if (%WorkingDir == $null) { %WorkingDir = $mircdir | e WorkingDir was null. Set to mircdir. } if (%proj == $null) %proj = untitled var %d = %WorkingDir, %renf = $+(%d,\,%proj,_rename.txt) var %wf = $+(%d,\,%proj,_dem2tga.txt) var %nf = $findfile(%d,*.dem,0,1), %i = 1 if (%nf) { write -c %wf | write -c %renf write %wf path $+($chr(37),PATH,$chr(37),$chr(59), %d) ; e %wf path $+($chr(37),PATH,$chr(37),$chr(59), %d) while (%i <= %nf) { batmaketxt %i inc %i } if (%useDEMfilename) e NO rename file written else e saved to %renf e saved to %wf } else e %nf Digital Elevations Models found } alias batmaketxt { var %d = %WorkingDir, %renf = $+(%d,\,%proj,_rename.txt) var %wf = $+(%d,\,%proj,_dem2tga.txt) var %i = $1 var %t, %r, %f = $findfile(%d,*.dem,%i,1) if ($fopen(ofile)) .fclose ofile .fopen ofile %f %r = $left($fread(ofile),940) %r = $formatname(%r) .fclose ofile if (%parameters == $null) %parameters = 0 0 15 0 ; dont rename if (%useDEMfilename) { %f = $nopath(%f) %t = $left(%f,-4) $+ .tga write %wf DEMPOV %f %t %parameters } else if ($nopath(%f) != %r) { ; e Renaming %f $+($nofile(%f),%r) %r = %r $+ .dem %t = %r $+ .tga write %renf ren %f %r write %wf DEMPOV %r %t %parameters } } ; Digital Elevation Model - sort position alias demsort { ; write demsformat.txt if (%headformat) demHeadRead else if (!$?!="Old Header. Sort anyway? Made your own demsformat.txt?") { e Cannot Sort: Old headers dont have lon lat. $& Need to format your own demsformat.txt. e kauai-sw -161°00'00 -160°00'00 21°00'00 22°00'00 e halting halt } var %f = demsformat.txt var %n = $lines(%f), %n2 if (%n < 2) { e nothing to sort, %n DEMS - halting | halt } if (!$window(@sort)) window -dlks @sort $calc($window(-3).w - 540) 10 500 $window(-3).h if (!$window(@sort2)) window -dlks @sort2 $calc($window(-3).w - 500) 10 500 $window(-3).h %n2 = $line(@sort,0) dline @sort 1- %n2 %n2 = $line(@sort2,0) dline @sort2 1- %n2 clear -s var %i = 1, %line var %j = 1, %r, %minlon = 9000000, %minlat = 9000000 ; /////////// location vars //////////////// start xz at 0 var %min_lat = 42.998056 var %min_lon = 78.5 ; abs(longitude) backwards for East Lon. $degreeslat() ; how many divisions of one degree - for xz place ints var %Xmult = 9 var %Ymult = 8 ; Hawaii if (!%headformat) { %Xmult = 1 %Ymult = 1 } ; auto set: %min_lat %min_lon ; EAST/WEST %x * -1 for South Lat, %y * -1 for East Lon ; ////////////////////////////////////////// while (%i <= %n) { %r = $read(%f,%i) %line = $gettok(%r,2-,32) $gettok(%r,1,32) aline -n @sort %line %n2 = $degreeslat($gettok(%line,3,32)) if (%minlat > %n2) %minlat = %n2 %n2 = $degreeslat($gettok(%line,1,32)) if (%n2 < %minlon) %minlon = %n2 inc %i } ; AUTO NAME PROJECT if ((%proj == $null) || (%proj == untitled)) { %line = $line(@sort,1) %proj = $gettok(%line,5,32) } %min_lat = %minlat %min_lon = %minlon %i = 1 %n = $line(@sort,0) var %start = $gettok($line(@sort,1),1,32) var %x, %y, %lat, %lon e // Example height_field macro in this script. e #local n = .988; while (%i <= %n) { %line = $line(@sort,%i) if (%start == $gettok(%line,1,32)) { aline -n @sort2 $gettok(%line,3-,32) $gettok(%line,1-2,32) } else { %start = %line %j = 1 %n2 = $line(@sort2,0) while (%j <= %n2) { %line = $line(@sort2,%j) %lon = $degreeslat($gettok(%line,4,32)) %y = $int($calc((%lon - %min_lon) * %Ymult)) ; e %line if ($gettok($gettok(%line,4,32),1,176) > 0) %y = $calc(%y * -1) ; -1 for East Lon if ((%i == 1) && (%y)) e DIDN'T START 0 !! - set abs min_lon min_lat to start at 0 %lat = $degreeslat($gettok(%line,1,32)) %x = $int($calc((%lat - %min_lat) * %Xmult)) if ($gettok(%line,1,176) < 0) %x = $calc(%x * -1) ; -1 for South Lat e pce( $+(", $gettok(%line,3,32), .tga") , %x *n, %y *n,0) inc %j } dline @sort2 1- %n2 aline -n @sort2 $gettok(%start,3-,32) $gettok(%start,1-2,32) %start = $gettok(%start,1,32) } inc %i } %j = 1 %n2 = $line(@sort2,0) while (%j <= %n2) { %line = $line(@sort2,%j) %lon = $degreeslat($gettok(%line,4,32)) %y = $int($calc((%lon - %min_lon) * %Ymult)) if ($gettok($gettok(%line,4,32),1,176) > 0) %y = $calc(%y * -1) %lat = $degreeslat($gettok(%line,1,32)) %x = $int($calc((%lat - %min_lat) * %Xmult)) if ($gettok(%line,1,176) < 0) %x = $calc(%x * -1) ; -1 for South Lat e pce( $+(", $gettok(%line,3,32), .tga") , %x *n, %y *n,0) inc %j } dline @sort2 1- %n2 if (%WorkingDir == $null) { %WorkingDir = $mircdir | e WorkingDir was null. Set to mircdir. } savebuf -s $+(%WorkingDir,\,%proj,_sort.pov) e saved to $+(%WorkingDir,\,%proj,_sort.pov) } alias degreeslat { var %n = $replace($1,°,$chr(32)) %n = $replace(%n,',$chr(32)) return $calc($abs($gettok(%n,1,32)) + $gettok(%n,2,32) / 60 + $gettok(%n,3,32) / 60 / 60) } alias unzipall { if (%WorkingDir == $null) { %WorkingDir = $mircdir | e WorkingDir was null. Set to mircdir. } if (%proj == $null) %proj = untitled var %d = %WorkingDir, %wf = $+(%d,\,%proj,_unzip.txt) var %nf = $findfile(%d,*.zip,0,1,e $1), %i if (%nf) { write -c %wf write %wf REM path $+($chr(37),PATH,$chr(37),$chr(59), %d) e path $+($chr(37),PATH,$chr(37),$chr(59), %d) %i = 1 while (%i <= %nf) { zzzip %i inc %i } e saved to %wf } else e No ZIP files found ; ren %WorkingDir $+ \*.dem a* ; REM 7z a archive.zip %WorkingDir $+ \* -aoa -y -sdel } alias zzzip { var %d = %WorkingDir, %wf = $+(%d,\,%proj,_unzip.txt) var %f = $findfile(%d,*.zip,$1,1) write %wf 7z x %f } alias -l e echo -s $1- alias DemRead { var %d = %WorkingDir, %r var %f = %d $+ \gasport.dem if ($1 isnum) %f = $findfile(%d,*.dem,$1,1) if ($fopen(ofile)) .fclose ofile .fopen ofile %f %r = $left($fread(ofile),940) .fclose ofile if (%useDEMfilename) return $left($nopath(%f),-4) $lonlatv(%r) return $formatname(%r) $lonlatv(%r) } alias formatname { var %r = $1 ; might be comma, might be many spaces ; HAWAII - C HI NE05-01W var %i = 1, %j = 0, %c, %last, %s if (%headformat) %r = $gettok(%r,1,44) else { ; scanning while (%i < 40) { %c = $mid(%r,%i,1) if ((%c == $chr(32)) && (%last == $chr(32))) inc %j %last = %c inc %i %s = %s $+ %c if (%j > 3) break } %r = %s } %r = $replace(%r,mountain,mtn) %r = $replace(%r,-,_) %r = $remove(%r,$chr(32),') %r = $lower(%r) return %r } alias lonlatv { var %r = $1, %a, %b, %c, %lat = 0, %lon = 0 ; %r = GASPORT, NY-24000 LAT:: 43 7 30.0000 N LONG:: -78 30 0.0000 W SCALE:: 24000 var %t = $findtok(%r,LAT::,1,32) if (%t) { inc %t %a = $gettok(%r,%t,32) inc %t %b = $gettok(%r,%t,32) inc %t %c = $gettok(%r,%t,32) if (%a isnum -90-90) %lat = %a if (%b isnum 0-60) %lat = $+(%lat,$chr(176),%b) if (%c isnum 0.0-60.0) %lat = $+(%lat,', %c) %t = $findtok(%r,LONG::,1,32) inc %t %a = $gettok(%r,%t,32) inc %t %b = $gettok(%r,%t,32) inc %t %c = $gettok(%r,%t,32) if (%a isnum -180-180) %lon = %a if (%b isnum 0-60) %lon = $+(%lon,$chr(176),%b) if (%c isnum 0.0-60.0) %lon = $+(%lon,', %c) } if ((!%lat) && (!%lon)) { %headformat = 0 ; e Header Format Set %headformat return 0 0 0 0 } %headformat = 1 return %lon 0 %lat 0 if (%lat) %lat = $degreeslat(%lat) else echo -s Latitude Not Found if (%lon) %lon = $degreeslat(%lon) else echo -s Longitude Not Found } alias demHeadRead { var %d = %WorkingDir, %nf, %input if (%d == $null) { %WorkingDir = $mircdir | e WorkingDir was null. Set to mircdir. } var %i = 1, %wf = demsformat.txt, %dr %input = %headformat if (%headformat || ((!%headformat) && ($?!="Old Header. Write file anyway?"))) { write -c %wf var %nf = $findfile(%d,*.dem,0,1,e $1) ; var %nf = $findfile(%d,*.dem,0,1) if (%nf) { while (%i <= %nf) { %dr = $DemRead(%i) write %wf %dr e %dr inc %i } e saved to $mircdir $+ %wf - required file to sort if ((%input == 1) && (%headformat == 0)) e headformat $& was set to new, but header is old. demsformat.txt written anyway. copy not made. else { ; SAVE PROJECT COPY %nf = %proj $+ _ $+ %wf if ($findfile($mircdir,%nf,1,1)) { ; scripting rule ; yes mirc evaluates variable in " " - reserved chars like {} or % is $chr(37) if ($?!=" %nf File exists. Overwrite?") copy -o %wf %nf } else copy %wf %nf } } else e %nf Digital Elevations Models found } else e No file written. Header Format %headformat } alias view_macro { var %i = 1, %f = hf_macro.txt, %n = $lines(%f), %r if (!$findfile($mircdir,%f,1,1)) write_macro while (%i <= %n) { ; n switch = "plain text" or omits braces and trying to evaluate. %r = $read(%f,n,%i) if (%r) e %r inc %i } } alias write_macro { var %f = hf_macro.txt write -c %f write %f #macro pce(hf,tx,tz,mxev) write %f echo(hf) cr() write %f height_field $chr(123) write %f tga hf // x 0-1.0 y 0-1.0 z 0-1.0 write %f smooth write %f // water_level 0.0 pigment $chr(123) White $chr(125) write %f pigment $chr(123) write %f gradient y write %f color_map $chr(123) write %f [0.0 color <0.25 , 0.25 , 1.0>] write %f [0.01 color <0.2 , 0.4 , 0.25>] write %f [0.1 color <.2 , 0.5 , 0.0>] write %f // [0.3 color <.3 , 0.4 , 0.0>] write %f [0.2 color <.4 , 0.3 , 0.0>] write %f [0.5 color <.3,.18 , 0.32>] write %f [0.9 color <.2,.18 , 0.22>] write %f [0.95 color <1,1,1>] write %f [1.0 color <0.25 , 0.25 , 1.0>] write %f $chr(125) write %f //scale 1 write %f $chr(125) write %f finish $chr(123) write %f crand 0.025 // dither - not used often. write %f ambient 0.2 // Very dark shadows write %f diffuse 0.8 // Whiten the whites write %f // phong 0.2 // shiny write %f // phong_size 100.0 // with tight highlights write %f // specular 0.5 write %f roughness 0.15 write %f $chr(125) write %f translate write %f scale < 300, 50, 300 > write %f $chr(125) write %f #end } alias anim { ; run ini with the run button, ok? then that's your 00 file. ; unload ini file ; dont have the ini file loaded. and few files loaded. ; keep single instance is off, so if render ; over-runs timer delay, still finishes each frame. ; close povray, to save how it opens. ; type /anim ; nextframe minus 1, or last good frame %GI = 0 var %allowedsecs = 45 %totalframes = 90 animat timer $calc(%totalframes - %GI) %allowedsecs animat } alias animat { inc %GI var %final_clock = 3 var %step = $calc(%totalframes / %final_clock) var %outf = $+(%WorkingDir, \kauai,$pad(%GI,2,0),.png) var %f = %WorkingDir $+ \kauai.ini write -l1 %f +K $+ $calc(%GI / %step) write -l5 %f Output_File_Name= $+ %outf run c:\povray\bin\pvengine.exe %f /EXIT } alias compositebat { var %f = %WorkingDir $+ \compa.bat.txt, %i = 0, %s while (%i <= 90) { %s = %f composite -stereo $+(kauai,$pad(%i,2,0),R.png) $& $+(kauai,$pad(%i,2,0),L.png) $+(kauai,$pad(%i,2,0),A.png) write %s inc %i } }