|
 |
High!
Once again, like already in December 2003, I tried to render a spherical
mesh (to be precise, a small section of a spherical mesh, covering only
one square degree) from a 1200 x 1200 ASCII matrix generated itself from
a SRTM GeoTIFF (needless to say what part of the world ;-)).
I hoped that my new Athlon 64 2800+ would be able to cope with it... but
once again was disillusioned, after about 780 lines the parsing became
so slow that it would have take millennia to parse the rest.
Are there ways to speed things up? Christoph Hormann's HF_sphere macro
would not be an alternative as it renders only complete spheres (unless
there has been an update meanwhile, of which I don`t know yet), not
sections.
Here is the code:
#declare mtrix=array[1200][1200]
#warning "Reading ASCII matrix"
#fopen matr "e:\homepage\n34e068-b.txt" read
// #while(defined(matr))
#declare a=0;
#while (a<1200)
#declare b=0;
#while (b<1200)
#read (matr, data)
#declare mtrix[a][b]=data;
#declare b=b+1;
#end
#declare a=a+1;
#end
// #end
#fclose matr
#warning "Reading of ASCII matrix completed!"
#declare F_Standard=
finish { ambient 0.1 diffuse 1 brilliance 0.5 }
light_source
{
<-5000000, 30000000, 10000000>
color rgb 1
}
camera
{
location 10000*<sin(-68.5*(pi/180))*cos(34.5*(pi/180)),
sin(34.5*(pi/180)), cos(-68.5*(pi/180))*cos(34.5*(pi/180))>
look_at 0
angle 40
}
sky_sphere
{
pigment { color rgb <0.3, 0.6, 0.8> }
}
#declare re=6378140; // Earth, equatorial radius
#declare rp=6356755; // Earth, polar radius
#declare sLat=35;
#declare eLat=34;
#declare sLong=-68;
#declare eLong=-69;
mesh
{
#declare a=0;
#while (a<1199)
#declare b=0;
#while(b<1199)
triangle{<(re+mtrix[a][b])*sin((sLong-b/1200)*(pi/180))*cos((sLat-a/1200)*(pi/180)),
(rp+mtrix[a][b])*sin((sLat-a/1200)*(pi/180)),
(re+mtrix[a][b])*cos((sLong-b/1200)*(pi/180))*cos((sLat-a/1200)*(pi/180))>,
<(re+mtrix[a][b+1])*sin((sLong-(b+1)/1200)*(pi/180))*cos((sLat-a/1200)*(pi/180)),
(rp+mtrix[a][b+1])*sin((sLat-a/1200)*(pi/180)),
(re+mtrix[a][b+1])*cos((sLong-(b+1)/1200)*(pi/180))*cos((sLat-a/1200)*(pi/180))>,
<(re+mtrix[a+1][b])*sin((sLong-b/1200)*(pi/180))*cos((sLat-(a+1)/1200)*(pi/180)),
(rp+mtrix[a+1][b])*sin((sLat-(a+1)/1200)*(pi/180)),
(re+mtrix[a+1][b])*cos((sLong-b/1200)*(pi/180))*cos((sLat-(a+1)/1200)*(pi/180))>
}
triangle{<(re+mtrix[a][b+1])*sin((sLong-(b+1)/1200)*(pi/180))*cos((sLat-a/1200)*(pi/180)),
(rp+mtrix[a][b+1])*sin((sLat-a/1200)*(pi/180)),
(re+mtrix[a][b+1])*cos((sLong-(b+1)/1200)*(pi/180))*cos((sLat-a/1200)*(pi/180))>,
<(re+mtrix[a+1][b+1])*sin((sLong-(b+1)/1200)*(pi/180))*cos((sLat-(a+1)/1200)*(pi/180)),
(rp*mtrix[a+1][b+1])*sin((sLat-(a+1)/1200)*(pi/180)),
(re*mtrix[a+1][b+1])*cos((sLong-(b+1)/1200)*(pi/180))*cos((sLat-(a+1)/1200)*(pi/180))>,
<(re+mtrix[a+1][b])*sin((sLong-b/1200)*(pi/180))*cos((sLat-(a+1)/1200)*(pi/180)),
(rp+mtrix[a+1][b])*sin((sLat-(a+1)/1200)*(pi/180)),
(re+mtrix[a+1][b])*cos((sLong-b/1200)*(pi/180))*cos((sLat-(a+1)/1200)*(pi/180))>
}
#declare b=b+1;
#end
#warning concat("Parsing lines ", str(a, 4, 0), " and ", str(a+1,
4, 0),".")
#declare a=a+1;
#end
texture
{
pigment { color rgb <1, 0.5, 0> }
finish { F_Standard }
}
}
See you in Khyberspace!
Yadgar
Post a reply to this message
|
 |