|
|
or is it a spaceship...
From paramx.inc
A unit sphere may look like this:
#declare Fx = function(U,V){sin(U)*cos(V)}
#declare Fy = function(U,V){cos(U)}
#declare Fz = function(U,V){sin(U)*sin(V)}
Parametric()
CalcSurf()
etc.
#declare Lynks = union
Well that MAY NOT make a sphere as it fails. Got many others to work, but no
sphere and no flattening. So failing Parametric(), got busy.
*************** Segement4.pov *************************
#include "stdinc.inc" // colors
#include "metals.inc"
#include "echo2.inc"
//#declare _radiosity = 0;
//#include "radiosity.inc"
#include "spheroid.inc"
spheroid(1.4, 0.0, 0.2, 0.2, 16, 32)
#macro VertexSpheres(Radius)
#local i=0;
#while (i<NumVertices)
sphere{V_vec_Arr[i], Radius}
#local i=i+1;
#end
#end
#macro By_Edges(Radius)
#local i=0;
#while (i<NumEdges)
#local uv = Edge_Arr[i];
cylinder { V_vec_Arr[Edge_Arr[i].x],V_vec_Arr[Edge_Arr[i].y],Radius }
#local i = i+1;
#end
#end
union {
By_Edges(0.05)
VertexSpheres(0.052)
texture { T_Chrome_1C }
rotate <0,0,0>
//rotate <0,0,0>
translate <0,0,0>
}
camera {
location < 0.0,1.0,-20.0 >
look_at < 0.0,0.0,0.0 >
angle 14
}
light_source {
<0.0,15.0,-15.0>
color Red
fade_distance 80
fade_power 2
}
light_source {
<40,0.5,-40>
color Green
fade_distance 80
fade_power 2
}
light_source {
<-20,5,-50>
color Blue
fade_distance 80
fade_power 2
}
#declare fl_chrome1c =
plane { y, -1.2 texture { T_Chrome_1C }
}
object { fl_chrome1c }
#declare sky_blue =
sky_sphere {
pigment {
gradient y
color_map {
[0.0 rgb <0.6,0.7,1.0>]
[0.7 rgb <0.0,0.1,0.8>]
}
}
}
sky_sphere { sky_blue }
((((((((((((((((( #include spheroid.inc )))))))))))))))))
#macro round(f,n)
#local c = floor(pow(10.0,n));
#local dd = 0.5 / c;
#local dd = dd + abs(f);
#local dd = dd * c;
#local dd=floor(dd);
#local dd = dd/c;
#if (f < 0.0) #local dd = dd * -1; #end
(dd)
#end
#macro spheroid(Radius, xflat, yflat, zflat, stacks, slices)
#declare NumVertices = numverts(stacks, slices);
#declare V_vec_Arr=array[NumVertices]
//#declare N_vec_Arr=array[NumVertices]
//#declare UV_vec_Arr=array[NumVertices]
#declare NumEdges = 0;
#declare Edge_Arr=array[NumVertices*4]
#local i = 0;
#local j = 0;
#local k = 0;
#local drho = pi / stacks;
#local dtheta = pi*2 / slices;
#local s1 = 1; #local s2 = 1; #local e1 = 1; #local e2 = 1;
#while (i <= stacks)
#local rho = i * drho;
#local s = sin(rho);
#local c = cos(rho);
#local j = 0;
#if (floor(slices * s) > 1) #local n = floor(slices * s);
#else #local n = 1; #end
#local dtheta = pi*2 / n;
#local s1 = s2;
#local s2 = k + 1;
#while (j < n)
#local theta = j * dtheta;
#local _x = sin(theta) * s;
#local _y = c;
#local _z = cos(theta) * s;
#local _x = _x * Radius * (1.0 - xflat);
#local _y = _y * Radius * (1.0 - yflat);
#local _z = _z * Radius * (1.0 - zflat);
#declare V_vec_Arr[k] = <_x,_y,_z>;
#local j=j+1;
#local k=k+1;
#end
#local e1 = e2;
#local e2 = k;
#if (i) stripfaces(s1-1, e1-1, s2-1, e2-1) #end
#local i=i+1;
#end
echo("\nNum Verts *****************")
echof(NumVertices)
echo("\nNum Edges *****************")
echof(NumEdges)
echof(NumEdges)
#end
#macro stripfaces(s1, e1, s2, e2)
//(range1 range2)
#local n1 = (e1-s1) + 1;
#local n2 = (e2-s2) + 1;
#local j = s2;
#local i = s1;
//echo("stripping edges")
#while (j < e2)
#declare Edge_Arr[NumEdges] = <j,j+1>;
#declare NumEdges = NumEdges+1;
#local j = j+1;
#end
#if (e2 != s2)
#declare Edge_Arr[NumEdges] = <e2,s2>;
#declare NumEdges = NumEdges+1;
#end
#if (n1 <= n2)
#local i = s1;
#local j = s2;
#local k = i;
#local aratio = n1 / n2;
#local h = 0;
#while (h < n1+n2)
#if (NumEdges < NumVertices*4)
#declare Edge_Arr[NumEdges] = <i,j>;
#declare NumEdges = NumEdges+1;
#end
#if (floor(k+aratio) = i)
#if ((j+1) <= e2) #local j=j+1; #local k = k+aratio; #end
#else
#if ((i+1) <= e1) #local i = i+1; #end
#end
#local h = h+1;
#end // while
#if (NumEdges < NumVertices*4)
#declare Edge_Arr[NumEdges] = <s1,e2>;
#declare NumEdges = NumEdges+1;
#end
#else
#local i = s2;
#local j = s1;
#local k = i;
#local aratio = n2 / n1;
#local h = 0;
#while (h < n1+n2)
#if (NumEdges < NumVertices*4)
#declare Edge_Arr[NumEdges] = <i,j>;
#declare NumEdges = NumEdges+1;
#end
#if (floor(k+aratio) = i)
#if ((j+1) <= e1) #local j=j+1; #local k = k+aratio; #end
#else
#if ((i+1) <= e2) #local i = i+1; #end
#end
#local h = h+1;
#end // while
#if (NumEdges < NumVertices*4)
#declare Edge_Arr[NumEdges] = <s2,e1>;
#declare NumEdges = NumEdges+1;
#end
#end
#end
#macro numverts(stacks, slices)
//
#local i = 0;
#local j = 0;
#local k = 0;
#local drho = pi / stacks;
#local dtheta = pi*2 / slices;
#while (i <= stacks)
#local rho = i * drho;
#local s = sin(rho);
#local c = cos(rho);
#local j = 0;
#if (floor(slices * s) > 1) #local n = floor(slices * s);
#else #local n = 1; #end
#local dtheta = pi*2 / n;
#while (j < n)
#local theta = j * dtheta;
#local j=j+1;
#local k=k+1;
#end
#local i=i+1;
#end
(k)
#end
((((((((((((((( #include echo2.inc )))))))))))))
#macro echo(Str)
#if (1)
#debug Str
#end
#end
#macro echof(f)
echo(concat("\n ",str(f,2,5)))
#end
#macro echov(V)
echo(concat("\n<",str(V.x,2,5),",",str(V.y,2,5),",",str(V.z,2,5),">"))
#end
#macro echov2(V)
echo(concat("\n<",str(V.x,2,5),",",str(V.y,2,5),">"))
#end
Post a reply to this message
Attachments:
Download 'segment4.png' (291 KB)
Preview of image 'segment4.png'
|
|