|
|
High!
(see also message in p.b.i.)
Here the code:
// cabinrailway.pov
// Maglev commuter train and Personal Rail Cabin system, 60-cm gauge
// TEXTURES
#declare T_Bright_Metal =
texture
{
pigment
{
color rgb 0.85
}
finish
{
ambient 0.15
diffuse 1
brilliance 0.3
phong 0.9
phong_size 110
}
}
// OBJECTS
#macro StraightRail(le) // le: length in meters
#local StraightOuterRounding =
cylinder
{
<0.005, 0.495, 0>, <0.005, 0.495, 4>, 0.005
}
union
{
prism
{
linear_sweep
linear_spline
0, -le, 21
<0, 0>, <0, 0.495>, <0.005, 0.495>, <0.005, 0.5>,
<0.21, 0.5>, <0.225, 0.485>, <0.225, 0.315>, <0.21, 0.3>,
<0.1, 0.3>, <0.1, 0.15>, <0.5, 0.15>, <0.5, 0.3>, <0.39, 0.3>,
<0.375, 0.315>, <0.375, 0.485>, <0.39, 0.5>, <0.595, 0.5>,
<0.595, 0.495>, <0.6, 0.495>, <0.6, 0>, <0, 0>
rotate -x*90
}
object { StraightOuterRounding }
object { StraightOuterRounding translate x*0.59 }
texture { T_Bright_Metal }
}
#end
#macro BendRail(rd, ang) // rd: bend central radius; ang: circle section
angle (positive: right, negative: left);
#local FullCircle =
lathe
{
linear_spline
21
<rd-0.3, 0>, <rd-0.3, 0.495>, <rd-0.295, 0.495>, <rd-0.295, 0.5>,
<rd-0.09, 0.5>, <rd-0.075, 0.485>, <rd-0.075, 0.315>, <rd-0.09, 0.3>,
<rd-0.2, 0.3>, <rd-0.2, 0.15>, <rd+0.2, 0.15>, <rd+0.2, 0.3>,
<rd+0.09, 0.3>,
<rd+0.075, 0.315>, <rd+0.075, 0.485>, <rd+0.09, 0.5>, <rd+0.295, 0.5>,
<rd+0.295, 0.495>, <rd+0.3, 0.495>, <rd+0.3, 0>, <rd-0.3, 0>
}
#local Bend_Subtraction_Block =
box
{
<-(rd+0.31), -1, 0>, <rd+0.31, 1, rd+0.31>
}
#local BendOuterRounding =
torus
{
rd+0.295, 0.005
}
#local BendInnerRounding =
torus
{
rd-0.295, 0.005
}
#local BendOuterRounding =
difference
{
object { BendOuterRounding }
object
{
Bend_Subtraction_Block
rotate y*ang
}
object { Bend_Subtraction_Block rotate y*180 }
}
#local BendInnerRounding =
difference
{
object { BendInnerRounding }
object
{
Bend_Subtraction_Block
rotate y*ang
}
object { Bend_Subtraction_Block rotate y*180 }
}
union
{
difference
{
object { FullCircle }
object
{
Bend_Subtraction_Block
rotate y*ang
}
object { Bend_Subtraction_Block rotate y*180 }
}
object { BendOuterRounding translate y*0.495 }
object { BendInnerRounding translate y*0.495 }
texture { T_Bright_Metal }
#if (ang >= 0)
translate x*(rd+0.3)
#else
translate -x*(rd-0.3)
#end
}
#end
#declare Straight4_Ground_Cutout =
box
{
<0, -0.45, 0>, <0.6, 0.05, 4.001>
}
// ACTUAL SCENE
sky_sphere
{
pigment
{
gradient y
color_map
{
[0 rgb 1 ]
[0.3 rgb 0.5 ]
}
}
}
plane
{
y, 0
texture
{
pigment
{
color rgb <0, 0.7, 0>
}
finish
{
ambient 0.15
diffuse 1
brilliance 0.2
}
}
}
light_source
{
<0, 1000, -2000>
color rgb 1
}
#declare RailElements = array[9][3];
#declare i=0;
#declare ty =0;
#declare s = 0;
#declare r = 0;
#fopen RailData "railtest.txt" read
#while (defined(RailData))
#read (RailData,ty,s, r)
#declare RailElements[i][0] = ty;
#declare RailElements[i][1] = s;
#declare RailElements[i][2] = r;
#declare i=i+1;
#end
#fclose RailData
#declare i=0;
#declare trans=<0, 0, 0>; // position of first rail segment (lower left
front corner)
#declare d=0; // orientation (degrees) of first rail segment
#while (i<9)
#switch (RailElements[i][0])
#case (0)
object
{
StraightRail(RailElements[i][1])
rotate y*d
translate trans
#declare trans = trans+vrotate(<0, 0, RailElements[i][1]>,<0,
d, 0>);
#warning concat("< ",str(trans.x, 3, 3), ", ", str(trans.y, 3,
3), ", ", str(trans.z, 3, 3), " >")
}
#break
#case (1)
object
{
BendRail(RailElements[i][2], RailElements[i][1])
rotate y*d
translate trans
#if (RailElements[i][1] >= 0)
#declare diff = 0.3;
#else
#declare diff = -0.3;
#end
#declare trans = trans +
2*(RailElements[i][2]+diff)*sin(radians(abs(RailElements[i][1])/2))*<sin(radians(abs(RailElements[i][1])/2)),
0, cos(radians(abs(RailElements[i][1])/2))>;
#declare d = d+RailElements[i][1];
#warning concat("< ",str(trans.x, 3, 3), ", ", str(trans.y, 3,
3), ", ", str(trans.z, 3, 3), " >")
}
#break
#end
#declare i=i+1;
#end
#warning str(d, 3, 3)
camera
{
// orthographic
location <10, 400, 10>
look_at <10, 0, 10>
angle 40
}
// end of code
Post a reply to this message
|
|