I'm needing some help with my first attempt at learning Ruby and making a Ruby script. I got Beginning Ruby by Peter Cooper; I'm still looking for something on file conversion and exporting, and for the SketchUp Ruby library similar to the Just Java guides Sun published for Java. The last time that I had programmed was about 10 years ago, so for all purposes I'm a beginner.
The first five lines below are a description of what the script should do. The remainder below is POV-Ray code that does this with embedded coordinates for the model, a 2D BĂ©zier spline rotated around an axis (part in the lathe { bezier_spline 24) procedure. For the script, I want to use a procedure to get the model's coordinates. How do I simulate the part for each ray from the center of the sphere to a grid point compute the intersection of the ray with the object for at least one ray?
-
draw a sphere around the object to be represented
-
draw a 64x64 grid on the sphere (like parallels and meridans on a world map)
-
for each ray from the center of the sphere to a grid point
-
compute the intersection of the ray with the object
-
Scale, normalize, etc to fit into 0-255 range.
` #declare t_sculpty = texture {
pigment {
average
pigment_map {
[1 gradient x color_map {[0 rgb 0][1 rgb <1,0,0>]}]
[1 gradient y color_map {[0 rgb 0][1 rgb <0,0,1>]}]
[1 gradient z color_map {[0 rgb 0][1 rgb <0,1,0>]}]
}
translate -0.5
}
finish { ambient 3 diffuse 0 }
}
lathe { bezier_spline 24,
<0.000,0.005>, <0.000,0.005>, <0.102,0.005>, <0.102,0.005>,
<0.102,0.005>, <0.102,0.102>, <0.060,0.154>, <0.214,0.212>,
<0.214,0.212>, <0.370,0.270>, <0.450,0.307>, <0.450,0.410>,
<0.450,0.410>, <0.450,0.511>, <0.450,0.957>, <0.450,0.974>,
<0.450,0.974>, <0.450,0.990>, <0.371,0.997>, <0.352,0.990>,
<0.352,0.990>, <0.332,0.985>, <0.175,0.975>, <0.000,0.975>
sturm
translate y*-0.5
scale <1,-1,1>
texture { t_sculpty }
}
sphere { 0, 1.001 inverse
finish { ambient 0 diffuse 0 reflection 1 }
}
camera { spherical location 0 look_at z*-1 }`