//test some SDL trickery //by Tek //feel free to use/copy/adapt this code or whatever :) #include "scratchfile.inc" #macro invokeCallback( sCallback, sParameters ) scratchBegin() scratchWrite(concat(sCallback,"(",sParameters,")\n")) scratchLoad() #end //test scene: camera { right x*image_width/image_height up y direction z*1.8 location <-2,1,-3> look_at -.2*y } light_source { <-1,3,-2> rgb 1 } #default { finish { diffuse .8 ambient .2 } } plane { y, -.58 pigment { rgb 1 } } // test macros executed from data. // define several macros that have the same parameters, then place references to them in an array, and invoke them indirectly from there. #macro buildSuperEllipse( pos ) superellipsoid { <.05,.05> scale .08 translate pos pigment { rgb <.2, .2, 1> } } #end #macro buildSphere( pos ) sphere { pos, .08 pigment { rgb <1, .2, 0> } } #end #declare pyramidCount = 0; #macro buildPyramid( pos ) #declare pyramidCount = pyramidCount + 1; intersection { plane { -y, 1 } plane { -x+y/2, .5 } plane { x+y/2, .5 } plane { -z+y/2, .5 } plane { z+y/2, .5 } rotate z*10*pyramidCount scale .08 translate pos pigment { rgb <1,1,0> } } #end #declare myFunctionCallback = array[3] { "buildSuperEllipse", "buildSphere", "buildPyramid" } //now, invoke those functions at random from the array. #declare rs = seed(17); #declare X=0; #while ( X < 5 ) #declare Y=0; #while ( Y < 5 ) #declare Z=0; #while ( Z < 5 ) invokeCallback( myFunctionCallback[int(rand(rs)*2.999)], ".2*" ) #declare Z=Z+1; #end #declare Y=Y+1; #end #declare X=X+1; #end