|
|
Hi(gh)!
Am 29.12.2017 um 16:42 schrieb clipka:
>
> Absolutely. Everything you can use in a pigment, eval_pigment() will
> handle correctly - for technically feasible definitions of "correctly".
Obviously not, at least not with POV-Ray for Windows... I used a 16-bit
PNG generated with Wilbur to be parsed to a spherical mesh2 with this
script:
// beginning of code
#include "functions.inc"
#declare xx=1024;
#declare yy=512;
#declare minrad=22;
#declare maxrad=38;
#declare AsteroidRelief =
pigment
{
image_map { tga "asteroid1.tga" }
}
#declare vertices=2+xx*(yy-2);
#fopen asteroid_mesh_inc "asteroid_mesh.inc" write
#write (asteroid_mesh_inc,
"#declare asteroid_mesh =\n
mesh2\n
{\n
vertex_vectors\n
{\n",
vertices,"\n",
<0, -35.678431, 0>," // south pole \n") // number of
vertices: 2+b*(a-2) [2+xx*(yy-2)]
#declare a=1;
#while (a<yy-1)
#declare b=0;
// #declare rdcum = 0;
#while (b<xx)
#declare redval=eval_pigment(AsteroidRelief, <(0.5+b)*(1/xx),
(0.5+a)*(1/yy), 0>).red * (maxrad-minrad);
#declare greenval=eval_pigment(AsteroidRelief, <(0.5+b)*(1/xx),
(0.5+a)*(1/yy), 0>).green * ((maxrad-minrad)/255);
#declare rd=minrad+redval+greenval;
/* #if (a=1 | a=yy-2)
#declare rdcum=rdcum+rd;
#end */
#write (asteroid_mesh_inc,
(rd*<sin(radians(b*(360/xx)))*cos(radians(-90+a*(180/(yy-2)))),
sin(radians(-90+a*(180/(yy-2)))),
cos(radians(b*(360/xx)))*cos(radians(-90+a*(180/(yy-2))))>)," // ",rd,"\n")
#declare b=b+1;
#end
#declare a=a+1;
#end
#write (asteroid_mesh_inc, <0, 35.741176, 0>,"// north pole\n
}\n
face_indices\n
{\n",
xx*2+xx*2*(yy-3),"\n") // number of faces:
b*2+b*2*(a-3) [xx*2+xx*2*(yy-3)]
#declare a=0;
#while (a<yy-1)
#declare b=0;
#while (b<xx)
#switch (a)
#case (0)
#if (b < xx-1)
#write (asteroid_mesh_inc, <0, a+1+b, a+1+mod(b+1,xx)>, "\n")
// b faces, all sharing first vertex (#0)
#else
#write (asteroid_mesh_inc, <0, a+1+b, 1>, "\n" // last
triangle connecting to first one
#end
#break
#range (1, yy-3)
#if (b < xx-1)
#write (asteroid_mesh_inc, <1+(a-1)*xx+b,
1+(a-1)*xx+mod(b+1,xx), 1+a*xx+b>,",",<1+a*xx+b, 1+a*xx+mod(b+1,xx),
1+(a-1)*xx+mod(b+1,xx)>, "\n") // b*2*(a-3) faces
#else
#write (asteroid_mesh_inc, <1+(a-1)*xx+b, 1+(a-1)*xx,
1+a*xx+b>,",",<1+a*xx+b, 1+(a-1)*xx, 1+a*xx>, "\n") // last pair of
triangles in row connecting to first pair
#end
#break
#case (yy-2)
#if (b < xx-1)
#write (asteroid_mesh_inc, <1+(a-1)*xx+b,
1+(a-1)*xx+mod(b+1,xx), vertices-1>) // b faces, all sharing last vertex
#else
#write (asteroid_mesh_inc, <1+(a-1)*xx+b, 1+(a-1)*xx,
vertices-1> // last triangle connecting to first one
#end
#break
#end
#declare b=b+1;
#end
#declare a=a+1;
#end
#write (asteroid_mesh_inc, " }\n}")
#fclose asteroid_mesh_inc
// end of code
It seemed to parse correctly - but POV-Ray crashed immediately
afterwards, regardless how big or small values I used for xx and yy. I
didn't try yet whether it still produced a valid mesh2 - but I don't
think so.
See you in Khyberspace!
Yadgar
Post a reply to this message
|
|