/* ----------------------------------------------------- Demo of baseball seam shape Seam is a series of beads (spheres) resting on surface of a larger ball (baseball) Several copies of the whole thing are shown in various angles. Rendered with color dispersion, just to be pretty. (~c) not copyrighted by Daren Scot Wilson This sample code may be copied, cut-and-pasted from, etc. without my permission, though huge financial donations are welcome :) GreenSquiggle@comcast.net ----------------------------------------------------- */ #include "colors.inc" #include "stones.inc" #include "bbcommon.povi" //----------------------------- LIGHTS AND CAMERAS ------------------ #declare MasterDimmer = 0.60; #declare BackLightsDimmer = MasterDimmer * 0.7; // main white lights light_source { <-30, 40, -20> rgb MasterDimmer fade_distance 20 } light_source { < 30, 40, -20> rgb MasterDimmer fade_distance 20 } // colored backlights light_source { <-40, 8, 40> rgb BackLightsDimmer*<0, .5, .8> } light_source { < 40, 8, 40> rgb BackLightsDimmer*< 1, .4, .2> } light_source { <40, 16, -10> rgb MasterDimmer*<.3, .1, .05> } light_source { <-8, -6, 70> rgb MasterDimmer*<.1, .3, .35> } camera { location <0, 4, -66> angle 52 } //--------------------- FLOOR and BACKDROPS -------------- plane { y, -30 texture { T_Stone22 scale 7} } plane { -z-x, -200 texture { T_Stone11 scale 7 } } plane { -z+x, -200 texture { T_Stone11 scale 7 } } //========================== THE BASEBALL ====================== //---------- Important baseball and seam parameters --------------- #declare BaseballRadius = 10.0; #declare SeamBeadRadius = 1.0; #declare SeamBeta = 0.6; // controls shape of seam #declare SeamCee = 1.0; #declare SeamCeeFour = 0.0; // experimental harmonic for z coord //EXPERIMENT #declare SeamBeta = 0.8; // controls shape of seam #declare SeamCee = 1.0; //--------------------------- DEFINE THE SEAM SHAPE ------------------- // A series of balls following the path of a baseball seam. // This is a standalone object to be attached to spheres for making baseballs. // // Create seam beads in a loop that runs angle a from 0 to 360 degrees // This is an arbitrary progress parameter, with one full cycle // corresponding to a complete trip around the seam // The space curve defined by the xxx,yyy,zzz points does not // lie on a sphere (the baseball) but we will normalize that vector // to force it to fall on a sphere. // // The complete seam has a lot of symmetry - four loops, and each loop has // a plane of symmetry. If I weren't lazy, // I'd compute just 1/8th of the seam and create copies positioned appropriately. // #declare Seam = union { #declare aa = 0; #while (aa<360) #declare ar = aa * 3.1415926 /180.00000 ; // convert to radians // Here is the baseball seam equation #declare xxx = cos(ar) - SeamBeta * cos(3*ar); #declare yyy = sin(ar) + SeamBeta * sin(3*ar); #declare zzz = SeamCee * cos(2*ar) + SeamCeeFour *cos(4*ar); // Find the radius #declare rrr2 = xxx*xxx + yyy*yyy + zzz*zzz; #declare rrr = sqrt(rrr2); // Normalize the radius and scale to desired BaseballRadius #declare xseam = BaseballRadius * xxx/rrr; #declare yseam = BaseballRadius * yyy/rrr; #declare zseam = BaseballRadius * zzz/rrr; // Make one bead sphere { , SeamBeadRadius } // Next point along the seam #declare aa = aa + 5; #end } //---------------------- DEFINE A BASEBALL -------------------- #declare Baseball = union { object { Seam pigment { color rgb 1 } finish { ambient .4 diffuse .5 phong .2 phong_size 6 } } // Big ball to represent the baseball // made of blueish glass, not totally clear sphere { <0,0,0>, BaseballRadius material { BaseballGlass } } } // Make one that's opaque #declare AllWhiteBaseball = union { object { Seam } sphere { <0,0,0>, BaseballRadius } pigment { color rgb .8 } finish { ambient .4 diffuse .5 phong .2 phong_size 6 } normal { dents .2 scale .5 } } //----------------------- PLACEMENT OF BASEBALLS --------- object { Baseball } object { Baseball rotate <50,0,20> translate -22*x } object { Baseball rotate -40*x rotate 50*y translate 22*x } object { AllWhiteBaseball rotate 70*x rotate -30*z rotate -14*x translate <8, 7, 24> } object { AllWhiteBaseball rotate -70*x rotate -45*z rotate 24*x translate <-26, 9, 20> }