// ========================================================================== // | ~~~~~~~~~~~~~~~~~~~~~~~ "Orange Wedge" ~~~~~~~~~~~~~~~~~~~~~~~ | // ========================================================================== // // Copyright (C) 2001 David A Fontaine #version Unofficial MegaPOV 0.5; #include "colors.inc" #include "macros2.inc" // +------------------------------------------------------------------------+ // | Control Variables | // +------------------------------------------------------------------------+ // \/ Latitudinal resolution #declare vres = 400; // \/ Number of spiral arms #declare arms = 5; // \/ Ratio of spiral-arm width to gap width (this // \/ does not take into account component radii) #declare armp = .95; // \/ Longitudinal resolution for each arm #declare armr = 40; // \/ Number of rotations each arm makes #declare revs = -1; // \/ Orange radius (minus component radius) #declare rad = 2; // \/ Blob component radius #declare crad = .06; // \/ Blob threshold #declare thr = 1.2; #declare armp = armp/(armp+1); // +------------------------------------------------------------------------+ // | Lights, Camera, Background | // +------------------------------------------------------------------------+ camera { location <0,2.5,-8>*.77 look_at <0,0,0> } light_source { <0,2.5,-8>*.77 color Gray30 } //light_source {<5000,5000,-4000> color Gray50 } light_source { <-6000,4000,-5000> color White area_light y*987*.8,z*987*.8,9,9 adaptive 0 orient } light_source { <2500,2500,-5000> color Gray40 area_light x*690*.8,y*690*.8,5,5 adaptive 0 orient } disc { y*(-rad-crad),y,10 pigment { color DustyRose*.7*1.93 } } background { color DustyRose*.7 } // +------------------------------------------------------------------------+ // | Texture Definitions | // +------------------------------------------------------------------------+ #declare N_Pulp = function { pigment { // These warps spherical // tesselate the color_map { [0.0 rgb .75][1.0 rgb .25] } // sphere like translate <1,sqrt(6)/3,sqrt(3)/2> // the points in warp { repeat 2*x } // a tetrahedron- warp { repeat sqrt(3)*z offset <1,0,0> } // octahedron warp { repeat 2*sqrt(6)/3*y offset <1,0,sqrt(3)/3> } // tiling. Very scale .15 // compact/dense. } } #declare Repeat = 3; // To make the bumps elongated in #declare N_Pulp = function { // a radial pattern, like a real N_Pulp( z*cos(x)*cos(y), // orange, the pattern is shrunk z*sin(y), // and tiled longitudinally and z*sin(x)*cos(y) ) // latitudinally. To do this, the } // coordinates are converted from #declare N_Pulp = function { // polar to rectangular, scaled, N_Pulp( atan2(z,x)*Repeat, // and converted back. atan2(y,sqrt(x^2+z^2))*Repeat, sqrt(x^2+y^2+z^2) ) } #declare Pulp = texture { pigment { color Orange*.6+LightWood*.4 } finish { specular .3 roughness .1 phong .3 phong_size 70 brilliance 0.8 } normal { function { N_Pulp } .12 sine_wave } } #declare Peel = texture { pigment { color MandarinOrange } finish { specular .1 roughness .05 } normal { bumps .35 scale .035 } } #declare Rhind = texture { pigment { color Gray95 } normal { bumps .2 scale .01 } } // +------------------------------------------------------------------------+ // | Orange Generator | // +------------------------------------------------------------------------+ blob { #declare ttl = 0; // Component counter #declare ctt = 0; // Cylindrical component counter #declare ctr = 0; #render "\n\nConstructing blob: current latitude\n\n" #while (ctr <= vres) // Latitudinal loop #render concat(str(ctr,4,0),"/",str(vres,4,0),"\r") #declare ctr2 = 0; #while (ctr2 < arms) // Spiral-arm loop #declare tarmr = int(armr*sin(ctr/vres*pi))+1; // Longitudinal res #declare ttl = ttl + tarmr; // Increment component counter #declare ctr3 = 0; #while (ctr3 < tarmr) // Longitudinal loop #if ((ctr3 = 0 | ctr3 = tarmr-1) & ctr != 0 & ctr != vres) cylinder { ( < cos( (ctr/vres*revs //-Longitudinal twisting +ctr2/arms //-plus spiral-arm offset +ctr3/(tarmr) //-plus longitudinal /arms*armp) // resolution offset; *2*pi), 0, // take the cosine for x. sin( (ctr/vres*revs // " " +ctr2/arms // " " " +ctr3/(tarmr) // " " /arms*armp) // " " *2*pi) // take the sine for z. >*sin(ctr/vres*pi) //-Multiply by distance to // y-axis at current lat. +cos(ctr/vres*pi)*y //-and add the y component )*rad, //-Multiply result by // orange radius. Ta-Da <0,0,0>, // This line connects // to the origin //cos(ctr/vres*pi)*y*rad, // This line connects // to the y-axis crad,1 } #declare ctt = ctt+1; // Increment component counter #else sphere { (< cos((ctr/vres*revs+ctr2/arms+ctr3/(tarmr)*1/arms* armp)*2*pi), 0, sin((ctr/vres*revs+ctr2/arms+ctr3/(tarmr)*1/arms* armp)*2*pi) >*sin(ctr/vres*pi) +<0,cos(ctr/vres*pi),0>)*rad, crad,1 } #end #declare ctr3 = ctr3 + 1; #end // Longitudinal loop #declare ctr2 = ctr2 + 1; #end // Spiral-arm loop #declare ctr = ctr + 1; #end // latitudinal loop #render concat("Blob complete; ",str(ttl,6,0)," components total, ", str(ttl-ctt,6,0)," spherical, ",str(ctt,6,0), " cylindrical.\n\n") threshold thr rotate <-40,45,0> //sphere { <0,0,0>,rad // This line was for testing purposes texture { spherical texture_map { [0.000 Peel scale 1/(rad+crad)] [0.020 Peel scale 1/(rad+crad)] [0.050 Rhind scale 1/(rad+crad)] [0.060 Pulp scale 1/(rad+crad)] [1.000 Pulp scale 1/(rad+crad)] } scale (rad+crad) } /*interior { media { scattering { 1, color (Orange*.6+LightWood*.4)*5 extinction 1 } intervals 4 samples 1,1 } }*/ }