// attempt at a vector exclusion test object placement function by [GDS|Entropy] #version unofficial megapov 1.21; global_settings { assumed_gamma 1.0 } camera { location <-5, 6,-18> up y*image_height right x*image_width look_at < 0, 1.5, 0> angle 45 } #local RsA = seed(574647); // RRand Macro by Chris Huff #macro RRand(RS, Min, Max) (rand(RS)*(Max-Min) + Min) #end // randVect Macro by [GDS|Entropy] //------ #declare Sp = 50000; #macro randVector(ctr,Min,Max,Method) #local i=0; #while (i; #break #case (1) #declare randVectArray[i] = ; #break #case (2) #declare randVectArray[i] = ; #break #case (3) #declare randVectArray[i] = ; #break #case (4) #declare randVectArray[i] = ; #break #case (5) #declare randVectArray[i] = ; #break #end #set i=i+1; #end #end #declare randVectArray = array [Sp]; //------ // draw_glow_basic Macro by [GDS|Entropy] #macro draw_glow_basic(pt,glowTypeCtr) light_source { pt #if(mod(glowTypeCtr,2) = 0) color rgb <0.2734*rand(RsA), 0.5078*rand(RsA), 0.7031*rand(RsA)>*0.0125 #else color rgb *0.0125 #end glow { #if(mod(glowTypeCtr,2) = 0) size rand(RsA)*0.1 type 0 #else size rand(RsA)*0.5 type 0 #end } #if(mod(glowTypeCtr,2) = 0) fade_distance 1 fade_power 2 #else fade_distance 2 fade_power 3 #end } #end //------ // Textures #declare IOR = 1.45; #declare Fade_Distance = 2; #declare Fade_Power = 3; #declare InteriorX = interior { fade_distance Fade_Distance fade_power Fade_Power ior IOR caustics 1.0 } #declare FinishX = finish { diffuse 0.000001 reflection 0.5 specular 1 brilliance 5 metallic on ambient 0.5 roughness 0.001 } #declare FinishY = finish { diffuse 0.000001 reflection 0.5 specular 1 brilliance 5 metallic on } //------ // testSphere Macros by [GDS|Entropy] #macro testSphere0(vect,diameter) sphere { vect,diameter texture { pigment { color rgb vect filter 1 } finish { FinishY } } interior { InteriorX } } #end #macro testSphere1(vect,diameter) sphere { vect,diameter texture { pigment { color rgb vect filter 0 } finish { FinishX } } interior { InteriorX } } #end //------ // exclusionTest Macro by [GDS|Entropy] - Debug Version // #debug gives you all information you will need // // isHollow inverts the results // // #else following the inside test allows placement // of objects both inside and outside of the bounding box // and testObject #macro exclusionTestDebug(ctr,vectorArray,isHollow,testObject) #local vectorA = min_extent(testObject); #local vectorB = max_extent(testObject); #local i=0; #while (i= vectorA.x)) & ((vectorArray[i].y <= vectorB.y) & (vectorArray[i].y >= vectorA.y)) & ((vectorArray[i].z <= vectorB.z) & (vectorArray[i].z >= vectorA.z))) #if (isHollow) #if (inside(testObject,vectorArray[i])) //#debug concat("Hollow On [1]; Vectors inside of testObject and inside bounding box: ", vstr(3,vectorArray[i],",",3,3),"\n") //testSphere0(vectorArray[i],0.06125) #else //#debug concat("Hollow On [2]; Vectors outside of testObject and inside bounding box: ", vstr(3,vectorArray[i],",",3,3),"\n") //testSphere1(vectorArray[i],0.25) #end #else #if (inside(testObject,vectorArray[i])) //#debug concat("Hollow Off [1]; Vectors inside of testObject and inside bounding box: ", vstr(3,vectorArray[i],",",3,3),"\n") //testSphere0(vectorArray[i],0.06125) #else //#debug concat("Hollow Off [2]; Vectors outside of testObject and inside bounding box: ", vstr(3,vectorArray[i],",",3,3),"\n") //testSphere1(vectorArray[i],0.25) #end #end #else #if (isHollow) //#debug concat("Hollow On [3]; Vectors outside of testObject and outside bounding box: ", vstr(3,vectorArray[i],",",3,3),"\n") //testSphere0(vectorArray[i],0.25) #else //#debug concat("Hollow Off [3]; Vectors outside of testObject and outside bounding box: ", vstr(3,vectorArray[i],",",3,3),"\n") //testSphere1(vectorArray[i],0.125) #end #end #set i=i+1; #end #end //------ // exclusionTest Macro by [GDS|Entropy] - Release - Extended Version #macro exclusionTest(ctr,vectorArray,isHollow,testObject) #local vectorA = min_extent(testObject); #local vectorB = max_extent(testObject); #local i=0; #while (i= vectorA.x)) & ((vectorArray[i].y <= vectorB.y) & (vectorArray[i].y >= vectorA.y)) & ((vectorArray[i].z <= vectorB.z) & (vectorArray[i].z >= vectorA.z))) #if (isHollow) #if (inside(testObject,vectorArray[i])) callExternal(ctr,0,vectorArray[i]) #else callExternal(ctr,1,vectorArray[i]) #end #else #if (inside(testObject,vectorArray[i])) callExternal(ctr,2,vectorArray[i]) #else callExternal(ctr,3,vectorArray[i]) #end #end #else #if (isHollow) callExternal(ctr,4,vectorArray[i]) #else callExternal(ctr,5,vectorArray[i]) #end #end #set i=i+1; #end #end //------ // exclusionTest Macro by [GDS|Entropy] - Release - Internal Version #macro exclusionTestInt(ctr,vectorArray,testObject) #local vectorA = min_extent(testObject); #local vectorB = max_extent(testObject); #local i=0; #while (i= vectorA.x)) & ((vectorArray[i].y <= vectorB.y) & (vectorArray[i].y >= vectorA.y)) & ((vectorArray[i].z <= vectorB.z) & (vectorArray[i].z >= vectorA.z))) #if (inside(testObject,vectorArray[i])) callExternal(ctr,0,vectorArray[i]) #end #end #set i=i+1; #end #end //------ // exclusionTest Macro by [GDS|Entropy] - Release - External Version #macro exclusionTestExt(ctr,vectorArray,testObject) #local vectorA = min_extent(testObject); #local vectorB = max_extent(testObject); #local i=0; #while (i= vectorA.x)) & ((vectorArray[i].y <= vectorB.y) & (vectorArray[i].y >= vectorA.y)) & ((vectorArray[i].z <= vectorB.z) & (vectorArray[i].z >= vectorA.z))) #if (inside(testObject,vectorArray[i])) // Vector is inside of test object; do nothing. #else callExternal(ctr,0,vectorArray[i]) #end #end #set i=i+1; #end #end //------ #macro callExternal(ctr,option,valueToPass) // your macros here // switch statement required for Extended variant testSphere0(vectorArray[i],0.06125) #end // test objects #declare objA = torus { 1, 0.5 translate <0,0,0> rotate <90,0,0> scale 2 } #declare objB = cone { <0, 1, 0>, 0.0, <0, -1, 0>, 1.0 scale 2 } #declare objC = quartic { < 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.01, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.01, 0.0, -0.01 > bounded_by { sphere { <0, 0, 0>, 2 } } scale 2 } //------ light_source { 0*x color rgb <0.2734, 0.5078, 0.7031> area_light <100, 0, 0> <0, 0, 100> 4, 4 adaptive 0 jitter translate <0,1000,-2000> } randVector(Sp,-4,4,0) // For Debug variant //#declare test0 = union{exclusionTestDebug(Sp,randVectArray,yes,objA)}; // For Extended variant //#declare test0 = union{exclusionTest(Sp,randVectArray,yes,objA)}; // For External only variant //#declare test0 = union{exclusionTestExt(Sp,randVectArray,objA)}; // For Internal only variant #declare test0 = union{exclusionTestInt(Sp,randVectArray,objC)}; object { test0 }