// PoVRay 3.8 Scene File " collections_ut.pov" // author: Bruno Cabasson // date: Jan 2022 // //-------------------------------------------------------------------------- #version 3.7; #include "colors.inc" #version 3.8; global_settings{ assumed_gamma 1.0 } #include "collections.inc" //-------------------------------------------------------------------------- // camera ------------------------------------------------------------------ #declare Camera_0 = camera {/*ultra_wide_angle*/ angle 75 // front view location <0.0 , 1.0 ,-3.0> right x*image_width/image_height look_at <0.0 , 1.0 , 0.0>} #declare Camera_1 = camera {/*ultra_wide_angle*/ angle 90 // diagonal view location <2.0 , 2.5 ,-3.0> right x*image_width/image_height look_at <0.0 , 1.0 , 0.0>} #declare Camera_2 = camera {/*ultra_wide_angle*/ angle 90 // right side view location <3.0 , 1.0 , 0.0> right x*image_width/image_height look_at <0.0 , 1.0 , 0.0>} #declare Camera_3 = camera {/*ultra_wide_angle*/ angle 90 // top view location <0.0 , 3.0 ,-0.001> right x*image_width/image_height look_at <0.0 , 1.0 , 0.0>} camera{Camera_0} // sun --------------------------------------------------------------------- light_source{<-1500,2500,-2500> color White} // sky --------------------------------------------------------------------- sky_sphere { pigment { gradient <0,1,0> color_map { [0.00 rgb <1.0,1.0,1.0>] [0.30 rgb <0.0,0.1,1.0>] [0.70 rgb <0.0,0.1,1.0>] [1.00 rgb <1.0,1.0,1.0>] } scale 2 } // end of pigment } //end of skysphere // fog --------------------------------------------------------------------- fog{fog_type 2 distance 50 color White fog_offset 0.1 fog_alt 2.0 turbulence 0.8} // ground ------------------------------------------------------------------ plane{ <0,1,0>, 0 texture{ pigment{ color rgb <0.825,0.57,0.35>} normal { bumps 0.75 scale 0.025 } finish { phong 0.1 } } // end of texture } // end of plane //-------------------------------------------------------------------------- //---------------------------- objects in scene ---------------------------- #debug "----------- testing dump_array()\n" #declare a0 = array {0, 1, 2, 3} dump_array(a0, "a0", TYPES._int_, 0) dump_array(a0, "a0", TYPES._float_, 0) dump_array(a0, "a0", TYPES._uv_, 0) dump_array(a0, "a0", TYPES._vector_, 0) dump_array(a0, "a0", TYPES._color_, 0) //dump_array(a0, "a0", TYPES._bool_, 0) // catched error in tostring() #debug "----------- testing extend()\n" #declare ext = array {4, 5, 6} dump_array(ext, "ext", TYPES._int_, 0) extend(a0, ext) dump_array(a0, "a0 extended", TYPES._int_,) #declare a0 = array {"b", "r", "u"} #declare ext = array {"n", "o"} extend(a0, ext) dump_array(a0, "a0", TYPES._string_, 0) #debug "----------- testing list() and ldump()\n" #declare my_list = list("my_list", TYPES._int_,) ldump(my_list,) #declare my_list1 = list("my_list1", TYPES._int_, array {0, 1, 2}) ldump(my_list1, 1) //#declare bad_list = list("bad list", TYPES._int_, array {0.5, 1.5}) // catched error in check() #debug "----------- testing push()\n" #declare my_list2 = list("my_list2", TYPES._int_,) ldump(my_list2,) push(my_list2, 1) ldump(my_list2,) //push(my_list2, 1.5) // catched error in check() #debug "----------- testing pop()\n" #local head = pop(my_list2); #debug concat("head = ", tostring(head, TYPES._int_), "\n") ldump(my_list2,) #debug "----------- testing lextend()\n" #declare my_extension = list("my_extension", TYPES._int_, array {3, 4}) ldump(my_list1,) ldump(my_extension,) lextend(my_list1, my_extension) ldump(my_list1,) ldump(my_list2,) // was pop'ed. ldump(my_extension,) lextend(my_list2, my_extension) ldump(my_list2,) #declare my_bad_tension = list("my_bad_extension", TYPES._float_, array {0.5, 0.6}) ldump(my_bad_tension,) //lextend(my_list2, my_bad_tension) // catched error in lextend() #debug "----------- testing get()\n" #debug concat("my_list2.nb_entries = ", str(my_list2.nb_entries, 0, 0), "\n") #for (i, 0, my_list2.nb_entries - 1) #declare elt = get(my_list2, i); #debug concat("get(", my_list2.name, ", ", str(i, 0, 0), ") = ", tostring(elt, my_list2.elt_type), "\n") #end #debug "----------- testing mlist()\n" #declare my_mlist = mlist("my_mlist",) // ldump(my_mlist,) // catched error in ldump(). Only lists (with all entries of the same type) can be dumped. #declare my_mlist1 = mlist("my_list1", array {0, 1, 2}) // Initialize with an array. #debug concat("my_mlist1.nb_entries = ", str(my_mlist1.nb_entries, 0, 0), "\n") #for (i, 0, dimension_size(my_mlist1.entries, 1) - 1) #debug concat("my_mlist1[", str(i, 0, 0), "] : ", tostring(my_mlist1.entries[i], TYPES._int_), "\n") #end #debug "\n" #declare my_mlist2 = mlist("my_list2", array mixed {0, 0.5, pigment {White}}) // Initialize with an array mixed. #debug concat("my_mlist2[0] : ", tostring(my_mlist2.entries[0], TYPES._int_), "\n") #debug concat("my_mlist2[1] : ", tostring(my_mlist2.entries[1], TYPES._float_), "\n") #declare junk = check(my_mlist2.entries[2], TYPES._pigment_) #debug concat("my_mlist2[2] : pigment {...}\n") #debug "----------- testing push()\n" push(my_mlist2, true) #debug concat("my_mlist2.nb_entries = ", str(my_mlist2.nb_entries, 0, 0), "\n") #debug concat("my_mlist2[0] : ", tostring(my_mlist2.entries[0], TYPES._int_), "\n") #debug concat("my_mlist2[1] : ", tostring(my_mlist2.entries[1], TYPES._float_), "\n") #declare junk = check(my_mlist2.entries[2], TYPES._pigment_) #debug concat("my_mlist2[2] : pigment {...}\n") #debug concat("my_mlist2[3] : ", tostring(my_mlist2.entries[3], TYPES._bool_), "\n") #debug "----------- testing pop()\n" #debug concat("my_mlist2.nb_entries = ", str(my_mlist2.nb_entries, 0, 0), "\n") #local head = pop(my_mlist2); #debug concat("my_mlist2.nb_entries = ", str(my_mlist2.nb_entries, 0, 0), "\n") #debug concat("head : ", tostring(head, TYPES._bool_), "\n") #local head = pop(my_mlist2); #debug concat("my_mlist2.nb_entries = ", str(my_mlist2.nb_entries, 0, 0), "\n") #declare junk = check(head, TYPES._pigment_) #debug concat("head : pigment {...}\n") #debug "----------- testing lextend()\n" #debug concat("my_mlist2.nb_entries = ", str(my_mlist2.nb_entries, 0, 0), "\n") lextend(my_mlist2, my_extension) #debug concat("my_mlist2.nb_entries = ", str(my_mlist2.nb_entries, 0, 0), "\n") #declare my_mextension = mlist("my_extension", array mixed {<0, 0.1, 0.2>, normal {crackle}}) lextend(my_mlist2, my_mextension) #debug concat("my_mlist2.nb_entries = ", str(my_mlist2.nb_entries, 0, 0), "\n") #local head = pop(my_mlist2); #debug concat("my_mlist2.nb_entries = ", str(my_mlist2.nb_entries, 0, 0), "\n") #declare junk = check(head, TYPES._normal_) #debug concat("head : normal {...}\n") #debug "----------- testing get()\n" #debug concat("my_mlist2.nb_entries = ", str(my_mlist2.nb_entries, 0, 0), "\n") #debug concat("get(", my_mlist2.name, ", 0) = ", tostring(get(my_mlist2, 0), TYPES._int_), "\n") #debug concat("get(", my_mlist2.name, ", 1) = ", tostring(get(my_mlist2, 1), TYPES._float_), "\n") #debug concat("get(", my_mlist2.name, ", 2) = ", tostring(get(my_mlist2, 2), TYPES._int_), "\n") #debug concat("get(", my_mlist2.name, ", 3) = ", tostring(get(my_mlist2, 3), TYPES._int_), "\n") #declare junk = check(get(my_mlist2, 4), TYPES._vector_); #debug concat("get(", my_mlist2.name, ", 1) = ", tostring(junk, TYPES._vector_), "\n") //#debug concat("get(", my_mlist2.name, ", 5) = ", tostring(get(my_mlist2, 5), TYPES._int_), "\n") // catched error in get() #debug "----------- testing map()\n" #declare my_extension2 = list("my_extension2", TYPES._int_, array{5, 6, 7}); lextend(my_list2, my_extension2) ldump(my_list2,) #ifdef (my_map_macro) #undef my_map_macro #end #macro my_map_macro(my_list_el, i, is_first, is_last, optional my_param_dict) // Whatever processing of my_list_el, with parameters defined in my_param_dict. // Parameter 'i' is the index of the element in the list. // Parameter 'is_first' is true for first element. // Parameter 'is_last' is true for last element. // As an example, we dump a "list of int" element. #debug concat("map() : my_list_el = ", tostring(my_list_el, TYPES._int_), "\n") #end map(my_list2,) #ifdef (my_map_macro) #undef my_map_macro #end #macro my_map_macro(my_list_el, i, is_first, is_last, optional my_param_dict) // Whatever processing of my_list_el, with parameters defined in my_param_dict. // Parameter 'i' is the index of the element in the list. // Parameter 'is_first' is true for first element. // Parameter 'is_last' is true for last element. // As an example, we dump a "list of int" element multiplied by a factor given in param_dict. #debug concat("map() : ", tostring(my_param_dict.a, TYPES._float_), "*", tostring(my_list_el, TYPES._int_)," + ", tostring(my_param_dict.b, TYPES._float_), " = ", tostring(my_param_dict.a*my_list_el + my_param_dict.b, TYPES._float_), "\n") #end map(my_list2, dictionary {.a : 10, .b : 0.5}) #debug "----------- testing exists()\n" #debug concat("exists(", my_list2.name, ", 3) = ", tostring(exists(my_list2, 3), TYPES._bool_), "\n") #debug concat("exists(", my_list2.name, ", 2) = ", tostring(exists(my_list2, 2), TYPES._bool_), "\n") //#debug concat("exists(", my_mlist2.name, ", 3) = ", tostring(exists(my_mlist2, 3), TYPES._bool_), "\n") // catched error in exists() #debug "----------- testing chunk()\n" ldump(my_list2,) #declare my_chunk = chunk(my_list2, 1, 3) ldump(my_chunk,) #declare my_chunk = chunk(my_list2, -1, 3) ldump(my_chunk,) #declare my_chunk = chunk(my_list2, -1, -3) ldump(my_chunk,) #declare my_chunk = chunk(my_list2, eol, 3) ldump(my_chunk,) #declare my_chunk = chunk(my_list2, 1, eol) ldump(my_chunk,) #declare my_chunk = chunk(my_list2, eol, eol) ldump(my_chunk,) //#declare my_chunk = chunk(my_list2, -5, 2) // catched error in chunk() //#declare my_chunk = chunk(my_list2, 1, 5) // catched error in chunk() //-------------------------------------------------------------------------- /* */