// PoVRay 3.8 Scene File "oocore_ut.pov" // author: Bruno Cabasson // date: Jan 2022 // //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- #version 3.7; #include "colors.inc" #version 3.8; global_settings{ assumed_gamma 1.0 } #include "oocore.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 2 lambda 3 omega 0.75} // 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 "+--------------------+\n" #debug "| testing class() |\n" #debug "| testing describe() |\n" #debug "+--------------------+\n" // == class EmptyClass ========================= #debug "== defining class EmptyClass =========================\n" #declare EmptyClass = class("EmptyClass", no,,,) // No parent class, no properties, no methods. #debug "===========================================\n\n" #debug "== testing class EmptyClass =========================\n" describe(EmptyClass,) #debug "===========================================\n\n" // == class PropertyClass ========================= #debug "== defining class PropertyClass =========================\n" #declare PropertyClass = class ( "PropertyClass", no,, // no parent class array { array mixed {"int_prop", TYPES._int_}, array mixed {"string_prop", TYPES._string_} } ,, // no methods. WARNING : don't know why I need the last comma. ) #debug "===========================================\n\n" #debug "== testing class PropertyClass =========================\n" describe(PropertyClass,) #debug "===========================================\n\n" // == class MethodClass ========================= #debug "== defining class MethodClass =========================\n" #declare MethodClass = class ( "MethodClass", no,, // no parent class , // no properties array {"meth1" , "meth2"} // methods declaration. ) // define meth1() #macro MethodClass_meth1(this,) #end // Leave meth2() undefined. #debug "===========================================\n\n" #debug "== testing class MethodClass =========================\n" describe(MethodClass,) #debug "===========================================\n\n" #debug "== testing property redefinition ignore =========================\n" #declare Parent = class("Parent", no,, array{ array mixed {"property1", TYPES._float_}, array mixed {"property2", TYPES._string_}},,) // WARNING : don't know why I need the last comma. describe(Parent,) #declare Child = class("Child", yes, Parent, array{ array mixed {"property2", TYPES._int_},array mixed {"property3", TYPES._int_}},,) // WARNING : don't know why I need the last comma. describe(Child,) #debug "===========================================\n\n" #debug "== testing method redefinition ignore =========================\n" #declare Parent = class("Parent", no,,, array {"method1", "method2"},) describe(Parent,) #declare Child = class("Child", yes, Parent,, array {"method2", "method3"},) describe(Child,) #debug "===========================================\n\n" #debug "+--------------------------+\n" #debug "| testing _method_mangle() |\n" #debug "+--------------------------+\n" #debug concat(" _method_mangle(EmptyClass, \"method_name\") = \"", _method_mangle(EmptyClass, "method_name"), "\"\n") #debug "\n" #debug "+-------------------------------------+\n" #debug "| testing _class_has_defined_method() |\n" #debug "+-------------------------------------+\n" #debug concat ( " _class_has_defined_method(EmptyClass, \"method_name\") = ", tostring(_class_has_defined_method(EmptyClass, "method_name"), TYPES._bool_), "\n" ) #debug concat ( " _class_has_defined_method(MethodClass, \"method_name\") = ", tostring(_class_has_defined_method(MethodClass, "method_name"), TYPES._bool_), "\n" ) #debug concat ( " _class_has_defined_method(MethodClass, \"meth1\") = ", tostring(_class_has_defined_method(MethodClass, "meth1"), TYPES._bool_), "\n" ) #debug concat ( " _class_has_defined_method(MethodClass, \"meth2\") = ", tostring(_class_has_defined_method(MethodClass, "meth2"), TYPES._bool_), // "meth2()" is just declared, not defined. "\n" ) #debug "\n" #debug "+----------------------------+\n" #debug "| testing _method_ancestor() |\n" #debug "+----------------------------+\n" #declare GandParent = class("GandParent", no,,, array{"method1", "method2"}) // Leave "method2" undefined. Shall generate an error. #macro GandParent_method1(this,) #end describe(GandParent,) #declare Parent = class("Parent", yes, GandParent,, array{"method1", "method3"}) #macro Parent_method3(this,) #end describe(Parent,) #declare Child = class("Child", yes, Parent,, array{"method1", "method3"}) // "method1()" defined by GrandParent. Redefine "method3()" #macro Child_method3(this,) #end describe(Child,) #declare ancestor = _method_ancestor(Child, "method1"); #debug concat("Ancestor for method1() : ", ancestor.classname, "\n") //#declare ancestor = _method_ancestor(Child, "method2"); // catched error in _method_ancestor() : method2() is not defined #declare ancestor = _method_ancestor(Child, "method3"); #debug concat("Ancestor for method3() : ", ancestor.classname, "\n") #debug "\n" #debug "+-------------------------+\n" #debug "| testing _link_methods() |\n" #debug "+-------------------------+\n" #declare pseudo_child_instance = dictionary {.class : Child} // Fake new() operator. #macro Parent_method2(this,) // define method2() in Parent, otherwise _method_ancestor() will generate an error. #end _link_methods(pseudo_child_instance, Child) #debug concat("method1() => ", pseudo_child_instance.method1, "\n") #debug concat("method2() => ", pseudo_child_instance.method2, "\n") #debug concat("method3() => ", pseudo_child_instance.method3, "\n") #debug "\n" #debug "+----------------------------+\n" #debug "| testing _link_properties() |\n" #debug "+----------------------------+\n" #declare GandParent = class("GandParent", no,, array{ array mixed {"property1", TYPES._int_}, array mixed {"property2", TYPES._string_}},,) // WARNING : don't know why I need the last comma. #declare Parent = class("Parent", yes, GandParent, array{ array mixed {"property2", TYPES._float_}, array mixed {"property3", TYPES._string_}},,) // WARNING : don't know why I need the last comma. #declare Child = class("Child", yes, Parent, array{ array mixed {"property4", TYPES._int_}},,) // WARNING : don't know why I need the last comma. describe(GandParent,) describe(Parent,) describe(Child,) #declare pseudo_child_instance = dictionary {.class : Child} // Fake new() operator. _link_properties(pseudo_child_instance, Child) // All properties set to None (0) ==> use TYPES._int_. #debug concat("property1 => ", tostring(pseudo_child_instance.property1, TYPES._int_), "\n")// No parser error ==> pseudo_child_instance.property1 exists. #debug concat("property2 => ", tostring(pseudo_child_instance.property2, TYPES._int_), "\n")// No parser error ==> pseudo_child_instance.property1 exists. #debug concat("property3 => ", tostring(pseudo_child_instance.property3, TYPES._int_), "\n")// No parser error ==> pseudo_child_instance.property1 exists. #debug concat("property4 => ", tostring(pseudo_child_instance.property4, TYPES._int_), "\n")// No parser error ==> pseudo_child_instance.property1 exists. #debug "\n" #debug "+-------------------------------+\n" #debug "| testing _constructor_mangle() |\n" #debug "+-------------------------------+\n" #debug concat(" _constructor_mangle(EmptyClass, 0) = \"", _constructor_mangle(EmptyClass, 0), "\"\n") #debug concat(" _constructor_mangle(EmptyClass, 1) = \"", _constructor_mangle(EmptyClass, 1), "\"\n") #debug "\n" #debug "+------------------------+\n" #debug "| testing _constructor() |\n" #debug "+------------------------+\n" // Fake "new()" operator #local this = dictionary; #local this.class = EmptyClass; #macro new_EmptyClass(this,) #debug "Executing new_EmptyClass(this,)\n" #end #macro new_1_EmptyClass(this,) #debug "Executing new_1_EmptyClass(this,)\n" #end #macro new_2_EmptyClass(this, optional params_dict) #ifdef (local.params_dict) #debug "Executing new_2_EmptyClass(this, param_dict)\n" #debug concat(" param1 :", tostring(params_dict.param1, TYPES._int_), "\n") #debug concat(" param2 :", params_dict.param2, "\n") #else #debug "Executing new_2_EmptyClass(this,)\n" #debug " no params_dict : using default values\n" #end #end _constructor(this, 0,) _constructor(this, 1,) _constructor(this, 2,) _constructor(this, 2, dictionary {.param1 : 5, .param2 : "text"}) #debug "\n" #debug "+---------------+\n" #debug "| testing new() |\n" #debug "+---------------+\n" #local empty_instance = new(EmptyClass,,) //#local empty_instance = new(EmptyClass,, dictionary {.param1 : 7, .param2 : "text2"}) // Parser error : wrong signature for default constructor. #local empty_instance = new(EmptyClass, 0,) //#local empty_instance = new(EmptyClass, 0, dictionary {.param1 : 7, .param2 : "text2"}) // Parser error : wrong signature for default constructor. #local empty_instance = new(EmptyClass, 1,) //#local empty_instance = new(EmptyClass, 1, dictionary {.param1 : 7, .param2 : "text2"}) // Parser error : wrong signature for #1 constructor. #debug "\n" #debug "+-----------------------+\n" #debug "| testing whole classes |\n" #debug "| ---- |\n" #debug "| testing call() |\n" #debug "| testing dump() |\n" #debug "+-----------------------+\n" // == class MyClass ========================= #debug "== defining class MyClass =========================\n" #declare MyClass = class ( "MyClass", no,, // no parent array { array mixed {"property1", TYPES._int_}, array mixed {"property2", TYPES._string_} }, array { "method1", "method2" } ) // Define 2 overloaded constructors used through the 'new' macro in "oocore.inc". // Default constructor, with signature number = 0. // // new_MyClass(this, property1, property2) #macro new_MyClass(this, optional params_dict) #ifdef (local.params_array) #local this.property1 = check(params_dict.property1, TYPES._int_); #local this.property2 = check(params_dict.property2, TYPES._string_); #else #local this.property1 = 0; #local this.property2 = "default string"; #end #end // Overloaded constructor #1, with signature number = 1. // new_1_MyClass(this, property1, property2, _offset) #macro new_1_MyClass(this, optional params_dict) // By hand : check parameter types, then link methods to the class to get the instance. #local p1 = check(params_dict.property1, TYPES._int_); #local p2 = check(params_dict.property2, TYPES._string_); #local offset_ = check(params_dict.offset_, TYPES._vector_); #local this.property1 = p1 + vlength(offset_); #local this.property2 = concat(p2, " ", vstr(5, offset_, ",", 0, 0)); #end // Instance dump method, used through the 'dump' macro in "oocore.inc". #macro MyClass_dump(this, indent_level) #debug concat(indent[indent_level], "instance of \"", this.class.classname, "\"\n") #debug "{\n" #debug concat(indent[indent_level+1], ".class : ", this.class.classname, "\n") #debug concat(indent[indent_level+1], ".property1 : ", str(this.property1, 0, 0), "\n") #debug concat(indent[indent_level+1], ".property2 : ", this.property2, "\n") #debug concat(indent[indent_level+1], ".method1() : ", this.method1, "\n") #debug concat(indent[indent_level+1], ".method2() : ", this.method2, "\n") #debug "}\n" #end // Default 'method1' method, used through the 'call' macro in oocore.inc". // MyClass_method1(this, p1, p2) #macro MyClass_method1(this, optional params_dict) #local p1 = check(params_dict.property1, TYPES._int_); #local p2 = check(params_dict.property2, TYPES._string_); #debug concat("==> ", this.method1, "(p1 = ", str(p1, 0, 0), " (int), p2 = ", p2, " (string))\n") #debug "executing ...\n" #debug concat("this.property1 = ", str(this.property1, 0, 0), "\n") #debug concat("this.property2 = \"", this.property2, "\"\n") #debug concat("<== ", this.method1, "\n") #end // Overloaded 'method1' method #1, used through the 'call' macro in oocore.inc". // MyClass_method1_1(this, p1, p2, p3) #macro MyClass_method1_1(this, optional params_dict) #local p1 = check(params_dict.property1, TYPES._int_); #local p2 = check(params_dict.property2, TYPES._string_); #local p3 = check(params_dict.pigment_, TYPES._pigment_); #debug concat("==> ", this.method1, "_1(p1 = ", str(p1, 0, 0), " (int), p2 = \"", p2, "\" (string), p3 = pigment {})\n") #debug "executing ...\n" #debug concat("this.property1 = ", str(this.property1, 0, 0), "\n") #debug concat("this.property2 = \"", this.property2, "\"\n") #debug concat("<== ", this.method1, "\n") #end // Default 'method2' method, used through the 'call' macro in oocore.inc". // MyClass_method2(this, p1) #macro MyClass_method2(this, optional params_dict) #local p1 = check(params_dict.p1, TYPES._vector_); #debug concat("==> ", this.method2, "(p1 = <", vstr(3, p1, ", ", 0, 0), "> (vector)\n") #debug "executing ...\n" #debug concat("this.property1 = ", str(this.property1, 0, 0), "\n") #debug concat("this.property2 = \"", this.property2, "\"\n") #debug concat("<== ", this.method2, "\n") #end #debug "===========================================\n\n" // =========================================== #debug "== testing class MyClass =========================\n" // Using MyClass describe(MyClass,) // Get 2 instances of MyClass, using the 2 provided constructors. #declare my_instance = new(MyClass,,); // dump(my_instance,) #declare my_instance = new(MyClass, 0, dictionary {.property1 : 0, .property2 : "text"}); dump(my_instance,) #declare my_instance2 = new(MyClass, 1, dictionary {.property1 : 0, .property2 : "text", .offset_ : x + y}); dump(my_instance2, ) // Call all the versions of the overloaded 'method1' method of class 'MyClass'. call(my_instance.method1,, my_instance, dictionary {.property1 : 0, .property2 : "text"}) call(my_instance.method1, 1, my_instance, dictionary {.property1 : 0, .property2 : "text", .pigment_ : pigment{Yellow}}) // Call all 'method3' method of class 'MyClass'. call(my_instance.method2,, my_instance, dictionary {.p1 : <0, 1, 3>}) #debug "===========================================\n\n" // == class Derived ========================= #debug "== defining class Derived =========================\n" #declare Derived = class ( "Derived", yes, MyClass, array { array mixed {"property3", TYPES._vector_} }, array { "method3" } ) describe(Derived,) // Instance dump method., used through the 'dump' macro in "oocore.inc". #macro new_Derived(this, optional params_dict) #debug "==> new_Derived()\n" super(this,, params_dict) #ifdef (local.params_array) #local offset_ = check(params_dict.offset_, TYPES._vector_); #else #local offset_ = 0; #end #local this.property1 = this.property1 + vlength(offset_); #local this.property2 = concat(this.property2, " ", str(2*vlength(offset_), 0, 4)); #local this.property3 = offset_; #debug "<== new_Derived()\n" #end #macro Derived_dump(this, indent_level) #debug concat(indent[indent_level], "instance of \"", this.class.classname, "\"\n") #debug "{\n" #debug concat(indent[indent_level+1], ".class : ", this.class.classname, "\n") #debug concat(indent[indent_level+1], ".property1 : ", str(this.property1, 0, 0), "\n") #debug concat(indent[indent_level+1], ".property2 : ", this.property2, "\n") #debug concat(indent[indent_level+1], ".property3 : <", vstr(3, this.property3, ", ", 0, 6), ">\n") #debug concat(indent[indent_level+1], ".method1() : ", this.method1, "\n") #debug concat(indent[indent_level+1], ".method2() : ", this.method2, "\n") #debug concat(indent[indent_level+1], ".method3() : ", this.method3, "\n") #debug "}\n" #end #macro Derived_method2(this, params_dict) #debug "Derived_method2()\n" #end #macro Derived_method3(this, params_dict) #debug "Derived_method3()\n" #end #debug "===========================================\n\n" // =========================================== #debug "== testing class Derived =========================\n" #declare my_derived_intance = new(Derived,, dictionary {.propery1 : 33, .property2 : "zorg", .offset_ : <0,1,2>}); dump(my_derived_intance,) #debug "===========================================\n\n" // == class Derived2 ========================= #debug "== defining class Derived2 =========================\n" #declare Derived2 = class ( "Derived2", yes, Derived, array {}, // no more properties array {} // no more methods ) describe(Derived2,) // Instance dump method., used through the 'dump' macro in "oocore.inc". #macro new_Derived2(this, optional params_dict) #debug "==> new_Derived2()\n" super(this,, params_dict) #debug "<== new_Derived2()\n" #end #macro Derived2_dump(this, indent_level) #debug concat(indent[indent_level], "instance of \"", this.class.classname, "\"\n") #debug "{\n" #debug concat(indent[indent_level+1], ".class : ", this.class.classname, "\n") #debug concat(indent[indent_level+1], ".property1 : ", str(this.property1, 0, 0), "\n") #debug concat(indent[indent_level+1], ".property2 : ", this.property2, "\n") #debug concat(indent[indent_level+1], ".property3 : <", vstr(3, this.property3, ", ", 0, 6), ">\n") #debug concat(indent[indent_level+1], ".method1() : ", this.method1, "\n") #debug concat(indent[indent_level+1], ".method2() : ", this.method2, "\n") #debug concat(indent[indent_level+1], ".method3() : ", this.method3, "\n") #debug "}\n" #end #macro Derived2_method3(this, optional params_dict) #debug "Derived2_method3()\n" #end #debug "===========================================\n\n" // =========================================== #debug "== testing class Derived2 =========================\n" #declare my_derived2_intance = new(Derived2,, dictionary {.property1 : 33, .property2 : "zorg", .offset_ : <0,1,2>}); dump(my_derived2_intance, 0) call(my_derived2_intance.method3,, my_derived2_intance,) #debug concat("isinstance(my_derived2_intance, Derived2) : ", str(instanceof(my_derived2_intance, Derived2), 0, 0), "\n") #debug concat("isinstance(my_derived2_intance, Derived) : ", str(instanceof(my_derived2_intance, Derived), 0, 0), "\n") #debug concat("isinstance(my_derived2_intance, MyClass) : ", str(instanceof(my_derived2_intance, MyClass), 0, 0), "\n") #debug "===========================================\n" // == class Junk ============================= #debug "== defining class Junk =========================\n\n" #declare Junk = class ( "Junk", yes, Derived, array {}, // no more properties array {} // no more methods ) #macro Junk_dump(this, indent_level) Derived_dump(this, indent_level) #end #macro new_Junk(this, optional params_dict) super(this,, params_array) #end #debug "===========================================\n\n" #debug "== testing class Junk =========================\n" #debug concat("isinstance(my_derived2_intance, Junk) : ", str(instanceof(my_derived2_intance, Junk), 0, 0), "\n") describe(Junk,) #declare my_junk = new(Junk,,) dump(my_junk,) #debug "===========================================\n\n" //#error "============= STOP HERE =================" //--------------------------------------------------------------------------