1// Persistence Of Vision Ray Tracer Scene Description File
2//
3// File:            benchmark.pov
4// POV-Ray Vers:    3.5
5// Benchmark Vers:  1.02
6// Desc:            POV-Ray 3.5 benchmark scene
7// Date:            October/November 2001
8//
9// Assembled by Christoph Hormann
10// Contributions by:
11//    - Ingo Janssen
12//    - Mick Hazelgrove
13//
14// ==================================================================
15//
16//          Standard POV-Ray v3.5 benchmark version 1.02
17//
18// This is the official POV-Ray v3.5 benchmark scene.  It is designed
19// to test a variety of POV-Ray features and should render in a
20// reasonable amount of time on current machines.  Note that the
21// radiosity feature is still experimental and not very suitable for
22// comparing results of different versions, therefore it is turned
23// off by default.
24//
25// Please log all changes made to this file below.
26//
27// Note that only results generated with the above options and the
28// unchanged scene file are allowed to be published as 'official
29// POV-Ray benchmark results'.  Feel free to do additional tests, but
30// make sure the differences are made clear when publishing them.
31//
32// When publishing results, be sure to quote the exact version of the
33// benchmark scene used (1.02), and the exact version of POV-Ray.
34//
35// ==================================================================
36//
37// Change history
38// --------------
39//
40// Nov. 2001   Initial release (version 3.5.0)
41// Jan. 2002   using 'max()' instead of '&' in isosurface
42// Apr. 2002   changed max_gradient of isosurface (new ver is 1.01)
43// Jun. 2002   added photons pass_through to clouds (new ver is 1.02)
44//
45// ==================================================================
46//
47// Permission is granted for this file and the output from it to be
48// freely redistributed in an unmodified form for the purpose of
49// generating and maintaining POV-Ray benchmarks.  Derivative works
50// are permitted provided that they have a clearly different filename
51// and do not claim to be the standard benchmark file.
52//
53// ==================================================================
54//
55// Suggested command line options if not using an INI file:
56//
57// -w384 -h384 +a0.3 +v -d -f -x
58//
59// The following INI options are used when the 'Run Benchmark' command
60// is chosen on versions of POV-Ray that support the built-in version.
61//
62// All_Console=Off
63// Antialias_Depth=3
64// Antialias=On
65// Antialias_Threshold=0.3
66// Bits_Per_Color=8
67// Bounding=On
68// Bounding_Threshold=3
69// Buffer_Output=Off
70// Buffer_Size=0
71// Clock=0
72// Continue_Trace=Off
73// Create_Histogram=Off
74// Cyclic_Animation=Off
75// Debug_Console=On
76// Display=Off
77// Display_Gamma=1.0
78// Draw_Vistas=Off
79// End_Column=1
80// End_Row=1
81// Fatal_Console=On
82// Fatal_Error_Command=
83// Fatal_Error_Return=I
84// Field_Render=Off
85// Final_Clock=1
86// Final_Frame=1
87// Height=384
88// Histogram_Name=
89// Histogram_Grid_Size=0.0
90// Initial_Clock=0
91// Initial_Frame=1
92// Include_Header=
93// Jitter_Amount=1
94// Jitter=On
95// Light_Buffer=On
96// Odd_Field=Off
97// Output_Alpha=Off
98// Output_File_Name=
99// Output_File_Type=s
100// Output_To_File=Off
101// Palette=3
102// Pause_When_Done=Off
103// Post_Frame_Command=
104// Post_Frame_Return=I
105// Post_Scene_Command=
106// Post_Scene_Return=I
107// Preview_End_Size=1
108// Preview_Start_Size=1
109// Pre_Frame_Command=
110// Pre_Frame_Return=I
111// Pre_Scene_command=
112// Pre_Scene_Return=I
113// Quality=9
114// Remove_Bounds=On
115// Render_Console=On
116// Sampling_Method=1
117// Split_Unions=Off
118// Start_Column=0
119// Start_Row=0
120// Statistic_Console=On
121// Subset_End_Frame=1
122// Subset_Start_Frame=1
123// Test_Abort_Count=0
124// Test_Abort=Off
125// User_Abort_Command=
126// User_Abort_Return=I
127// Verbose=On
128// Version=3.5
129// Video_Mode=0
130// Vista_Buffer=On
131// Warning_Console=On
132// Width=384
133//
134// ==================================================================
135
136#version 3.5;
137
138#include "functions.inc"
139#include "colors.inc"
140#include "logo.inc"
141
142
143#declare use_radiosity = false;
144// #declare use_radiosity = true;
145
146
147
148#declare use_photons = true;
149#declare use_area_light = true;
150
151#declare show_clouds = true;
152#declare show_objects = true;
153
154#declare Rad = 50000;
155
156global_settings {
157   max_trace_level 12
158   assumed_gamma 1.0
159
160   #if (use_radiosity=true)
161
162      radiosity {
163         pretrace_start 0.08
164         pretrace_end 0.01
165         count 80
166
167         nearest_count 5
168         error_bound 0.5
169         recursion_limit 1
170
171         low_error_factor .5
172         gray_threshold 0.0
173         minimum_reuse 0.015
174         brightness 0.7
175
176         adc_bailout 0.01/2
177
178         normal on
179      }
180
181   #end
182
183   #if (use_photons=true)
184      photons { spacing 0.007 }
185   #end
186
187}
188
189#if (use_radiosity=false)
190   #default {finish {ambient 0.02}}
191#else
192   #default {finish {ambient 0.00}}
193#end
194
195//====================================================================================
196
197camera {
198   location  <3.2, 3.2, 1.8>
199   direction y
200   sky       z
201   up        z
202   right     -x
203   look_at   <-1, -1, 0.9>
204   angle     45
205}
206
207
208light_source {
209   <-0.7, 0.83, 0.24>*150000
210   color rgb <3.43,2.87,1.95>
211   #if (use_area_light=true)
212      area_light 4000*x 4000*y  4,4
213      jitter
214      orient
215      circular
216   #end
217
218   media_attenuation on
219   media_interaction on
220
221   photons {
222      reflection on
223      refraction on
224   }
225}
226
227#if (use_radiosity=false)
228   light_source {
229      <0.9, -0.6, 0.5>*150000
230      color rgb 0.35
231
232      shadowless
233   }
234#end
235
236fog{
237   fog_type 2
238   fog_alt 1.5
239   fog_offset 0
240   color rgbt <0.75, 0.80, 0.86, 0.2>
241   distance 400
242   up z
243}
244
245
246//====================================================================================
247
248
249#declare RMF = function{ f_ridged_mf(x, y, z, 0.07, 2.2,  7, 0.6, 0.9, 1)}
250
251#declare M_Watx4 =
252material {
253   texture {
254      pigment { color rgbt <0.21, 0.20, 0.3, 0.96> }
255      finish {
256         diffuse 0.0
257         ambient 0.0
258
259         reflection {
260            0.1, 0.95
261            fresnel on
262            exponent 0.8
263         }
264
265         conserve_energy
266
267         specular 0.1
268         roughness 0.007
269         metallic
270      }
271      normal{
272         function { RMF(x, y, z) } 0.2
273         scale 0.07
274      }
275   }
276   interior {
277      ior 1.31
278      fade_distance 0.8
279      fade_power 1001.0
280      fade_color <0.02, 0.20, 0.06>
281   }
282}
283
284box {              // --- Water ---
285   <-1.95,  -1.65, 0.42>, < 1.95,  1.65, -5.5>
286
287   material { M_Watx4 }
288   hollow on
289
290   photons { collect off }
291}
292
293#declare fn_RMF = function{ f_ridged_mf(x, y, z, 0.1, 3.1, 8 ,0.7, 0.8, 2) }
294
295
296plane {            // --- floor ---
297   z, -0.3
298
299   texture {
300      pigment { color rgb <1.0, 0.85, 0.6> }
301      finish {
302         diffuse 0.7
303         specular 0.1
304      }
305      normal {
306         function { fn_RMF(x, y, z) } 0.3
307         scale 8
308      }
309   }
310
311   clipped_by {
312      box { <-1.95,  -1.65, 1>, < 1.95,  1.65, -1> inverse }
313   }
314
315   photons { collect off }
316}
317
318
319isosurface {
320   function {
321      z - fn_RMF(x, y, z)*0.07
322   }
323
324   max_gradient 1.3
325
326   contained_by { box { <-15, -15, 0.0>, <15, 15, 0.2> } }
327
328   texture {
329      pigment { color rgb <1.0, 0.85, 0.6> }
330      finish {
331         diffuse 0.7
332         specular 0.1
333      }
334   }
335
336   scale 8
337   translate -0.16*z
338
339   clipped_by {
340      box { <-1.95,  -1.65, 1>, < 1.95,  1.65, -1> inverse }
341   }
342
343   photons { collect off }
344}
345
346
347// ====================================================================================
348
349
350
351sphere {           // --- Sky ---
352   <0, 0, 0>, 1
353   texture {
354      pigment {
355         gradient z
356         pigment_map {
357            [0.00 color rgb <0.6667, 0.7255, 0.7725>]
358            [0.19
359               spherical
360               color_map {
361                  [0.08 color rgb <0.33, 0.37, 0.90> ]
362                  [0.14 color rgb <0.3210, 0.53, 0.9259> ]
363                  [0.26 color rgb <0.3610, 0.57, 0.9259> ]
364                  [0.50 color rgb < 0.880, 0.935, 0.976 > ]
365               }
366               scale 1.8
367               translate <-0.7, 0.7, 0.24>
368            ]
369         }
370      }
371      finish {
372         diffuse 0
373         ambient 1
374      }
375   }
376   scale Rad*<20, 20, 4>
377   translate -2*z
378   no_shadow
379   hollow on
380
381   photons { collect off pass_through }
382}
383
384#if (show_clouds)
385
386// from mick
387
388difference {
389   sphere { 0,Rad}
390   sphere {0,Rad-15000}
391   material{
392      texture{
393         pigment{ rgbf 1 }
394         finish {
395            ambient 0
396            diffuse 0
397         }
398      }
399      interior{
400         media{
401            scattering {2,<.013,.012,.008>/1.3 extinction 1/1.3 }
402            method 3
403            samples 7,7
404            intervals 1
405
406            density { // one
407               wrinkles
408               ramp_wave
409
410               noise_generator 1
411
412               color_map {
413                  [0 rgb 0]
414                  [0.5 rgb 0]
415                  [0.7 rgb 0.275]
416                  [1 rgb 0.475]
417               } // color_map
418
419               scale <10000,9000,5000>/3
420               rotate z*29
421               translate <1000,0,Rad-30000>
422            } // density
423
424            density { // two
425               marble
426               warp { turbulence 1.65 octaves 7 }
427               noise_generator 1
428
429               color_map {
430                  [0 rgb 0]
431                  [0.4 rgb 0]
432                  [0.85 rgb 0.25]
433                  [1 rgb 0.5]
434               } // color_map
435
436               scale <10000,7500,5000>*5
437               rotate z*-25
438               translate <0,0,Rad-30000>
439            } // density
440
441         } // media
442      } // interior
443   } // material
444   hollow
445
446   rotate z*70
447   rotate y*15
448   translate <0,0,32000-Rad>
449   rotate -102*z
450
451   scale <1,1,0.4>
452
453   photons { collect off pass_through }
454
455} // difference
456
457#end
458
459// ====================================================================================
460
461
462#declare Metal_Texture =
463texture {
464   pigment { color rgb <0.65, 0.55, 0.5> }
465   finish {
466      ambient 0.0
467      diffuse 0.15
468      specular 0.3
469      metallic
470      roughness 0.01
471      reflection {
472         0.8
473         metallic
474      }
475   }
476}
477
478#declare Stone_Tex =
479texture {
480   pigment {
481      crackle
482      pigment_map {
483         [0.03
484            bozo
485            color_map {
486               [0 color rgb <0.2, 0.14, 0.05>]
487               [1 color rgb <0.2, 0.14, 0.05>]
488            }
489            warp { turbulence 0.6 }
490         ]
491         [0.055
492            granite
493            color_map {
494               [0.0 color rgb <1, 0.95, 0.9>]
495               [0.5 color rgb <0.6, 0.5, 0.52>]
496               [1.0 color rgb <0.9, 0.8, 0.7>]
497            }
498            warp { turbulence 0.4 lambda 2.4 octaves 8 }
499            scale 0.5
500         ]
501      }
502
503      warp { turbulence 0.72 lambda 2.25 omega 0.53 octaves 9}
504
505      scale 0.3
506   }
507   finish {
508      diffuse 0.55
509      specular 0.1
510   }
511   normal {
512      granite 0.15
513      scale 0.06
514   }
515}
516
517#declare Stone_Tex2 =
518texture {
519   pigment {
520      crackle
521      pigment_map {
522         [0.03
523            bozo
524            color_map {
525               [0 color rgb <0.1, 0.08, 0.2>]
526               [1 color rgb <0.1, 0.08, 0.2>]
527            }
528            warp { turbulence 0.6 }
529         ]
530         [0.055
531            granite
532            color_map {
533               [0.0 color rgb <1, 0.95, 0.9>]
534               [0.5 color rgb <0.6, 0.5, 0.52>]
535               [1.0 color rgb <0.9, 0.8, 0.7>]
536            }
537            warp { turbulence 0.4 lambda 2.4 octaves 8 }
538            scale 1.2
539         ]
540      }
541
542      warp { turbulence 0.55 lambda 2.25 omega 0.53 octaves 9 }
543
544      scale 0.24
545   }
546   finish {
547      diffuse 0.55
548      specular 0.1
549   }
550   normal {
551      granite 0.15
552      scale 0.06
553   }
554}
555
556#declare Stone_Tex3 =
557texture {
558   pigment {
559      agate
560      pigment_map {
561         [0.3
562            crackle
563            color_map {
564               [0.1 color rgb <0.3, 0.28, 0.4>]
565               [0.2 color rgb <0.8, 0.7, 0.4>]
566            }
567            warp { turbulence 0.5 lambda 2.2 omega 0.52 octaves 8 }
568            scale 0.3
569         ]
570         [0.5
571            granite
572            color_map {
573               [0.0 color rgb <1, 0.95, 0.9>]
574               [0.5 color rgb <0.3, 0.6, 0.52>]
575               [1.0 color rgb <0.3, 0.8, 0.7>]
576            }
577            warp { turbulence 0.4 lambda 2.4 octaves 8 }
578         ]
579      }
580
581      warp { turbulence 0.55 }
582
583      scale 0.24
584   }
585   finish {
586      diffuse 0.55
587      specular 0.1
588   }
589   normal {
590      granite 0.15
591      scale 0.06
592   }
593}
594
595#declare Mat_Glass =
596material {
597   texture {
598      pigment { color rgbt 1 }
599      finish {
600         diffuse 0
601         ambient 0
602         specular 0.6
603         metallic 0.5
604         roughness 0.005
605
606         reflection {
607            0.05, 0.95
608            fresnel on
609         }
610
611         conserve_energy
612      }
613   }
614   interior {
615      ior 1.5
616      fade_distance 0.12
617      fade_power 1001
618      fade_color <0.6, 0.5, 0.7>
619   }
620}
621
622
623#declare Socket =
624union {
625   difference {
626      cylinder { -5*z, -0.04*z, 0.8 }
627      cylinder { -6*z, 0, 0.3 }
628
629      #declare Cnt = 0;
630
631      #while (Cnt<360)
632
633         merge {
634            cylinder { < 0.0,  0.0, -0.24>, < 1.0,  0.0, -0.24>, 0.1 }
635            box { < 0.0,  -0.1, -0.24>, < 1.0,  0.1, -6> }
636
637            rotate Cnt*z
638         }
639
640         #declare Cnt = Cnt+30;
641      #end
642   }
643
644   #declare Cnt = 0;
645
646   #while (Cnt<360)
647
648      union {
649         cylinder { < 0.8,  0.0, -0.04>, < 0.8,  0.0, -5>, 0.05 }
650         cylinder { < 0.8,  0.0, -0.04>, < 0.8,  0.0, -0.01>, 0.07 }
651
652         rotate 15*z
653         rotate Cnt*z
654      }
655
656      #declare Cnt = Cnt+30;
657   #end
658
659   cylinder { -0.04*z, 0, 0.86 }
660   torus {
661      0.83, 0.03
662      rotate 90*x
663   }
664}
665
666#declare Pos1 = < 0.0,  0.0, 0.6>;
667#declare Pos2 = <-2.4, -0.8, 1.0>;
668#declare Pos3 = <-1.4, -2.8, 1.3>;
669#declare Pos4 = < 1.4,  0.6, 0.5>;
670
671#declare Pos5 = <-10, -5, 1.5>;
672
673object { Socket translate Pos1 texture { Stone_Tex } }
674
675object { Socket translate Pos2 texture { Stone_Tex } }
676
677object { Socket scale 0.8 translate Pos3 texture { Stone_Tex } }
678
679object { Socket scale 0.4 translate Pos4 texture { Stone_Tex } }
680
681object { Socket scale 2 translate Pos5 texture { Stone_Tex } }
682
683difference {
684   box { <-2.0,  -1.7, 0.5>, < 2.0,  1.7, -6> }
685   box { <-1.9,  -1.6, 1.0>, < 1.9,  1.6, -5> }
686
687   texture {
688      Stone_Tex2
689   }
690}
691
692#if (show_objects)
693
694#declare POV_Text =
695text {
696   ttf
697   "timrom.ttf"
698   "POV-Ray"
699   0.25,0
700   scale 0.3
701   rotate 90*x
702   rotate -90*z
703}
704
705object {
706   POV_Text
707   translate <-1.97,  0.86, 0.5>
708   texture { Stone_Tex2 }
709}
710
711object {
712   POV_Text
713   rotate 90*z
714   translate <-0.5, -1.6, 0.5>
715   texture { Stone_Tex2 }
716}
717
718#end
719
720
721height_field {
722
723   function 300,300 {
724      pigment {
725         function { 1-(min(pow(x*x + y*y, 0.25), 1) -0.0001) }
726
727         color_map {
728            [0.0 rgb 0.0]
729            [1.0 rgb 1.0]
730         }
731
732         translate <0.5,0.5,0>
733
734         scale 0.45
735
736         warp { turbulence 0.455 }
737
738         scale 3
739         warp { turbulence 0.2 lambda 2.2 octaves 8 }
740         scale 1/3
741
742      }
743   }
744
745   water_level 0.02
746
747   rotate 90*x
748
749   rotate 43*z
750
751   scale <5, 5, 1.3>
752   scale 2.6
753
754   texture {
755      pigment {
756         bozo
757         color_map {
758            [0.40 color rgb <0.6, 0.6, 0.7>*0.6]
759            [0.58 color rgb <0.9, 0.6, 0.3>*0.6]
760            [0.62 color rgb <0.2, 0.6, 0.1>*0.4]
761         }
762         warp { turbulence 0.4 }
763         scale <0.2, 0.2, 3>
764      }
765      finish {
766         diffuse 0.6
767         specular 0.2
768      }
769   }
770
771   translate <-18, -13, -0.4>
772}
773
774
775#if (show_objects)
776
777// ---------- Pos1 ----------
778
779difference {
780   cylinder { -0.0*z, 0.15*z, 0.7 }
781   cylinder { -0.1*z, 0.25*z, 0.68 }
782
783   texture { Metal_Texture }
784
785   translate 0.6*z
786
787   photons { target reflection on }
788}
789
790#declare fn_pigm =
791function {
792   pigment {
793      bozo
794      poly_wave 2
795      color_map {
796         [0 rgb 0][1 rgb 1]
797      }
798      warp {  turbulence 0.4 lambda 2.3 omega 0.52 }
799
800      scale 0.2
801   }
802}
803
804
805isosurface {
806   function {
807      (max(sqrt(x*x + y*y)-0.25, z-0.7))
808
809      - fn_pigm(x, y, z).gray*0.07
810
811   }
812
813   max_gradient 2.4
814
815   contained_by { box { <-0.35, -0.35, 0.0>, <0.35, 0.35, 0.8> } }
816
817   texture {
818      pigment { color rgb <1, 0.45, 0.2> }
819      finish {
820         diffuse 0.6
821         specular 0.2
822      }
823   }
824
825   translate Pos1
826}
827
828object {
829   Povray_Logo
830
831   rotate 90*x
832   scale 0.4
833   translate -0.2*y
834
835   texture {
836      pigment { color rgb <0.65, 0.55, 0.9> }
837      finish {
838         ambient 0.0
839         diffuse 0.15
840         specular 0.3
841         metallic
842         roughness 0.01
843         reflection {
844            0.8
845            metallic
846         }
847      }
848      normal {
849         bumps 0.3
850         scale 0.3
851      }
852   }
853
854   rotate -25*z
855
856   translate 0.96*z
857
858   translate Pos1
859}
860
861#end
862
863#if (show_objects)
864
865// ---------- Pos2 ----------
866
867#declare rd = seed(45);
868
869union {
870
871   #declare Cnt = 0;
872
873   #while (Cnt<360)
874
875      superellipsoid {
876         <rand(rd)*2, rand(rd)*2>
877         texture { Metal_Texture }
878         scale 0.12
879         translate <0.6, 0.0, 0.12>
880         rotate (Cnt+30)*z
881      }
882
883      julia_fractal {
884         < rand(rd), rand(rd)*0.6, -0.54, 0.2 >
885         quaternion
886         max_iteration 7
887         precision 500
888         scale 0.12
889         translate <0.6, 0.0, 0.1>
890         rotate Cnt*z
891
892         texture {
893            pigment { color rgb <1, 0.4, 0.8> }
894            finish {
895               ambient 0
896               diffuse 0.6
897               specular 0.2
898               reflection 0.2
899            }
900         }
901      }
902
903      #declare Cnt = Cnt+60;
904   #end
905
906   translate Pos2
907}
908
909#end
910
911#if (show_objects)
912
913// ---------- Pos3 ----------
914
915sphere {
916   0, 0.24
917
918   translate 0.24*z
919
920   material { Mat_Glass }
921
922   photons { target reflection on refraction on }
923
924   translate Pos3
925}
926
927#end
928
929#if (show_objects)
930
931
932// ---------- Pos4 ----------
933
934
935// from ingo
936
937#declare Letter =
938text {
939   ttf
940   "timrom.ttf"
941   "X"
942   1,0
943   scale <1/0.7,1/0.66,1>
944   translate <0,0,-0.5>
945}
946
947#declare xPigm =
948function {
949   pigment {
950      object {
951         Letter
952         pigment {rgb 1}
953         pigment {rgb 0}
954      }
955      warp {repeat x}
956      warp {repeat y}
957      scale 1.00002
958      translate < 0.000001,-0.00001, 0>
959   }
960}
961
962#declare XsinPigm =
963function {
964   pigment {
965      function {xPigm(sin(x),pow(sin(y),2),z).gray}
966   }
967}
968
969#declare Fn_Obj =
970difference {
971   cylinder {
972      -2*y, 2*y, 2
973      pigment {
974         function{XsinPigm(x,y,z).gray}
975         warp {planar}
976         scale <0.5/pi, 1, 1>*0.5
977         warp {
978            cylindrical
979            orientation z
980            dist_exp 1
981         }
982         colour_map {
983            [0, rgb 1]
984            [1, rgbf 1]
985         }
986      }
987      finish {
988        diffuse 0.6
989        specular 0.4
990      }
991   }
992   cylinder {
993      -1.9*y, 2.1*y, 1.9
994      pigment {rgbf 1}
995      finish {
996        diffuse 0.6
997        specular 0.4
998      }
999   }
1000
1001   translate 1.96*y
1002   rotate 90*x
1003   scale 0.12
1004}
1005
1006object {
1007   Fn_Obj
1008   translate Pos4
1009}
1010
1011#end
1012
1013
1014#if (show_objects)
1015
1016
1017// ---------- Pos5 ----------
1018
1019
1020// from ingo
1021
1022#macro BuildWriteMesh2(VecArr, NormArr, UVArr, U, V)
1023
1024   #debug concat("\n\n Building mesh2: \n   - vertex_vectors\n")
1025   #local NumVertices = dimension_size(VecArr,1);
1026   mesh2 {
1027      vertex_vectors {
1028         NumVertices
1029         #local I = 0;
1030         #while (I<NumVertices)
1031            VecArr[I]
1032            #local I = I+1;
1033         #end
1034      }
1035
1036      #debug concat("   - normal_vectors\n")
1037      #local NumVertices = dimension_size(NormArr,1);
1038      normal_vectors {
1039         NumVertices
1040         #local I = 0;
1041         #while (I<NumVertices)
1042            NormArr[I]
1043            #local I = I+1;
1044         #end
1045      }
1046
1047      #debug concat("   - uv_vectors\n")
1048      #local NumVertices = dimension_size(NormArr,1);
1049      uv_vectors {
1050         NumVertices
1051         #local I = 0;
1052         #while (I<NumVertices)
1053            UVArr[I]
1054            #local I = I+1;
1055         #end
1056      }
1057
1058      #debug concat("   - face_indices\n")
1059      #declare NumFaces = U*V*2;
1060      face_indices {
1061         NumFaces
1062         #local I = 0;
1063         #local H = 0;
1064         #while (I<V)
1065            #local J = 0;
1066            #while (J<U)
1067               #local Ind = (I*U)+I+J;
1068               <Ind, Ind+1, Ind+U+2>, <Ind, Ind+U+1, Ind+U+2>
1069               #local J = J+1;
1070               #local H = H+1;
1071            #end
1072            #local I = I+1;
1073         #end
1074      }
1075   }
1076#end
1077
1078#macro FnA(X)
1079   #if (X<0.13)
1080      0.5+sin(X*14)*0.4
1081   #else
1082      0.5+sin((X-0.13)*7.2)*0.3
1083   #end
1084#end
1085
1086
1087// Build a two-dimensional array with vectors and normals retrieved from a function macro
1088// ResSpl: the amount of vectors to get from the macro
1089// based on ingo's code for splines
1090
1091#macro L_GetVN(ResSpl)
1092   #local I = 0;
1093   #local A = array[ResSpl+1][2]
1094   #while (I<=ResSpl)
1095      #local P0 = 0+<FnA(I/ResSpl), I/ResSpl, 0>;
1096      #if (P0.x=0 & P0.z=0)
1097         #local P0 = <1e-25,P0.y,1e-25>;
1098      #end
1099      #if (I=0)
1100         #local P1 = 0+<FnA(((I-0.5)/ResSpl)), I/ResSpl, 0>;
1101         #local P2 = 0+<FnA(((I+0.5)/ResSpl)), I/ResSpl, 0>;
1102      #else
1103         #local P1 = P2;
1104         #local P2 = 0+<FnA(((I+0.5)/ResSpl)), I/ResSpl, 0>;
1105      #end
1106      #local P3 = vrotate(P0,<0,1,0>);
1107      #local P4 = vrotate(P0,<0,-1,0>);
1108      #local B1 = P4-P0;
1109      #local B2 = P2-P0;
1110      #local B3 = P3-P0;
1111      #local B4 = P1-P0;
1112      #local N1 = vcross(B1,B2);
1113      #local N2 = vcross(B2,B3);
1114      #local N3 = vcross(B3,B4);
1115      #local N4 = vcross(B4,B1);
1116      #local N = vnormalize((N1+N2+N3+N4)*-1);
1117      #local A[I][0] = P0;
1118      #local A[I][1] = N;
1119      #local I = I+1;
1120   #end
1121   A
1122#end
1123
1124#macro FnLathe (Rot, ResRot, ResSpl)
1125   #declare VNArr = L_GetVN (ResSpl)
1126   #local VecArr = array[(ResRot+1)*(ResSpl+1)]
1127   #local NormArr = array[(ResRot+1)*(ResSpl+1)]
1128   #local UVArr = array[(ResRot+1)*(ResSpl+1)]
1129   #local R = Rot/ResRot;
1130   #local Dim = dimension_size(VNArr,1);
1131   #local Count = 0;
1132   #local I = 0;
1133   #while (I<=ResRot)
1134      #local J = 0;
1135      #while (J<Dim)
1136         #local VecArr[Count] = vrotate(VNArr[J][0],<0,R*I,0>);
1137         #local NormArr[Count] = vrotate(VNArr[J][1],<0,R*I,0>);
1138         #local UVArr[Count] = <I/ResRot,J/(Dim-1)>;
1139         #local J = J+1;
1140         #local Count = Count+1;
1141      #end
1142      #local I = I+1;
1143   #end
1144   BuildWriteMesh2(VecArr, NormArr, UVArr, ResSpl, ResRot)
1145#end
1146
1147
1148#declare MSH = FnLathe(360, 100, 100)
1149
1150#declare Obj_Msh =
1151object {
1152   MSH
1153
1154   uv_mapping
1155
1156   texture {
1157      pigment{
1158         checker
1159         color rgb <1.0, 0.7, 0.5>,
1160         color rgb <0, 0, 0.15>
1161
1162         scale 0.05
1163      }
1164      finish {
1165         diffuse 0.7
1166         specular 0.3
1167      }
1168   }
1169
1170   rotate 90*x
1171   scale <1.9, 1.9, 2.8>
1172
1173
1174   translate Pos5
1175}
1176
1177
1178object { Obj_Msh }
1179
1180
1181#end
1182
1183