|
|
I really wanted objects with a rectangular cross-section with rounded corners
for my first serious scene. There does not seem to be satisfactory means of
creating this so I have written the scene below.
This works fine but is very clunky. Could it be turned into a macro?
Could it be extended to take an arbitrary number of sides?
I have looked at the manual but feel rather daunted!
// Persistence Of Vision Ray Tracer sample Scene
// by John Greenwood
// Rounded.POV demonstrates a means of creating a straight sided quadrilateral
// with rounded corners
#version 3.7;
global_settings {assumed_gamma 1.0}
#default{ finish{ ambient 0.1 diffuse 0.9 }}
#include "colors.inc"
light_source { <100,1000,-1000>, White}
camera { location <2,10,-20>
right x*image_width/image_height
angle 35 // direction 2*z
look_at <0,0,0>
}
#declare Cor = array [5][4] {
{ 0.0 , 4.0 , 1.0 , 0.0 }, // Put the coordinates of the four corners in the
first two cells in the row.
{ -4.0 , 0.0 , 1.0 , 0.0 }, // Put the radius for the corner in the third
cell in the row.
{ 0.0 , -4.0 , 1.0 , 0.0 }, // The fourth cell in the row is used for
calculation, no input required.
{ 4.0 , 0.0 , 3.0 , 0.0 },
{ 0.0 , 4.0 , 1.0 , 0.0 } // same as row 1
} ;
#for (N,0,3)
#declare Cor[N][3] = atan2((Cor[N][1]-Cor[N+1][1]),(Cor[N][0]-Cor[N+1][0]));
#end
#declare Cor[4][3] = Cor[0][3];
#declare S = array[32]
#for (N,0,3)
#declare S[8*N ] = <Cor[N][0] - Cor[N][2] *cos(Cor[N][3]) ,Cor[N][1] -
Cor[N][2] *sin(Cor[N][3])>;
#declare S[8*N+1] = <Cor[N][0] -1.5*Cor[N][2] *cos(Cor[N][3]) ,Cor[N][1]
-1.5*Cor[N][2] *sin(Cor[N][3])>;
#declare S[8*N+2] = <Cor[N+1][0]+1.5*Cor[N+1][2]*cos(Cor[N][3])
,Cor[N+1][1]+1.5*Cor[N+1][2]*sin(Cor[N][3])>;
#declare S[8*N+3] = <Cor[N+1][0]+ Cor[N+1][2]*cos(Cor[N][3]) ,Cor[N+1][1]+
Cor[N+1][2]*sin(Cor[N][3])>;
#declare S[8*N+4] = <Cor[N+1][0]+ Cor[N+1][2]*cos(Cor[N][3]) ,Cor[N+1][1]+
Cor[N+1][2]*sin(Cor[N][3])>;
#declare S[8*N+5] = <Cor[N+1][0]+0.5*Cor[N+1][2]*cos(Cor[N][3])
,Cor[N+1][1]+0.5*Cor[N+1][2]*sin(Cor[N][3])>;
#declare S[8*N+6] =
<Cor[N+1][0]-0.5*Cor[N+1][2]*cos(Cor[N+1][3]),Cor[N+1][1]-0.5*Cor[N+1][2]*sin(Cor[N+1][3])>;
#declare S[8*N+7] = <Cor[N+1][0]- Cor[N+1][2]*cos(Cor[N+1][3]),Cor[N+1][1]-
Cor[N+1][2]*sin(Cor[N+1][3])>;
#end
prism {
linear_sweep
bezier_spline
0,1,32,
S[0] ,S[1] ,S[2] ,S[3] ,S[4] ,S[5] ,S[6] ,S[7], // can this be done more
elegantly?
S[8] ,S[9 ],S[10],S[11],S[12],S[13],S[14],S[15],
S[16],S[17],S[18],S[19],S[20],S[21],S[22],S[23],
S[24],S[25],S[26],S[27],S[28],S[29],S[30],S[31]
pigment { White }
}
Post a reply to this message
|
|