POV-Ray : Newsgroups : povray.binaries.scene-files : Apple_Code Server Time
2 Sep 2024 14:17:23 EDT (-0400)
  Apple_Code (Message 1 to 1 of 1)  
From: F Audet
Subject: Apple_Code
Date: 8 Oct 2001 10:51:58
Message: <3BC1BCBE.9EF49D25@sympatico.ca>
// Persistence of Vision Ray Tracer Scene Description File
// File: Absolute_Apple.pov
// Vers: 3.1
// Desc: construction of a macro aimed to build shapes made of
spheres...
// Date: 29/09/01
// Auth: Alex Pilot

//#version 3.1

#include "colors.inc"
//#include "surface.inc" // inc. of my own

global_settings {
  assumed_gamma 1.95 max_trace_level 12
}

// ----------------------------------------
#declare flying_cam =
camera {
  location  < 0, 0, -1 >
  look_at   0.0*y   angle 45   rotate 0*x
}

#declare x_c_r = 22.5;   #declare y_c_r = 20   #declare z_c_r = 0;
#declare cam_light_trans = 45;

#declare lighting_right =
light_source {
  0*x
  color rgb < 1, 1, 1.0 >*1.2
  spotlight
  point_at < 0, 0, cam_light_trans >
  radius 45
  tightness 20
  falloff cam_light_trans*1.35
  media_interaction off
}

#declare lighting_bottom =
light_source {
  0*x
  color rgb < 1, 1, 0.75 >*0.8
  spotlight
  point_at < 0, 0, cam_light_trans >
  radius 45
  tightness 20
  falloff cam_light_trans*1.35
  media_interaction off
}

camera { flying_cam translate < 0, -2, -cam_light_trans >
  rotate < x_c_r, -y_c_r, z_c_r >
}

object { lighting_right translate < 0, 0, -cam_light_trans*1.05 >
  rotate < x_c_r*1.25, -y_c_r*1.5, z_c_r >
}

object { lighting_bottom translate < 0, 0, -cam_light_trans*1.05 >
  rotate < -x_c_r*0.5, +y_c_r*1.5, z_c_r >
}

///////////////
///////////////
///////////////
///////////////
///////////////
///////////////


#declare rough_chrome =
finish {
  ambient 0.05   diffuse 0.6
  roughness 0.02  specular 0.65
  reflection 0.25  brilliance 1
}

plane { y, -42.5 pigment { color rgb < 0.6, 0.6, 0.6 > }
  finish { rough_chrome }
}

sky_sphere {
  pigment {
    gradient y
    color_map { [0.0 color White*0.50 ] [1.0 color rgb 0.80] }
  //  color_map { [0.0 color Black ] [0.3 color Blue 0.8] }
  }
}

/////////////////////////////
   /////////////////////////////
      /////////////////////////////
         /////////////////////////////
            /////////////////////////////
               /////////////////////////////
                  /////////////////////////////


//#local s1 = seed(1); // I don' t know why,  but I have to put this
item
                     // out of the macro, in order to get a random
                     // choice between the "0" and the "1"...
// But I don't use it for now....  I only use a simple sphere object
...//

#macro pomme_profile ( prof_rad, definition,
                         ray1, deg1,
                         ray2, deg2,
                         ray3, deg3,
                         ray4, deg4,
                         center    )


#local sph = sphere { 0, prof_rad }

//#macro binary_01 ()
//  #local obj_temp =
//  #if ( rand(s1) <= 0.5 )
//    torus { prof_rad-(prof_rad/2.5), prof_rad/2.5 scale 0.65*x
//      translate -(prof_rad/2.5)*y scale 3*y rotate < -90, -90, 0 >
//    }
//  #else
//    union { cylinder
{<0,(prof_rad-(prof_rad/2.5)),0>,<0,(-prof_rad+(prof_rad/2.5)),0>,prof_rad/2.5
}
//      sphere { 0, prof_rad/2.5 translate (+prof_rad-(prof_rad/2.5))*y
}
//      sphere { 0, prof_rad/2.5 translate (-prof_rad+(prof_rad/2.5))*y
}
//      translate -(prof_rad/2.5)*x scale 3*x
//    }
//  #end
//  object { obj_temp }
//#end

///////////////////////////////////
  union {
    #local A_factor       = 1/definition;
    #local curve_A        = deg1;
    #local balls_num_A    = curve_A/A_factor;
    #local rot_z_A        = curve_A/balls_num_A;
    #local balls_num_intA = int(curve_A/rot_z_A);
    #local reel_dist_A    = rot_z_A*balls_num_intA;
    #local counter_A      = rot_z_A;
    #while ( counter_A <= reel_dist_A )
      object { sph translate ray1*x
        rotate < 0, 0, counter_A >
      }
      #local counter_A = counter_A+rot_z_A;
    #end
    #local B_factor       = 1/(definition/ray1*ray2);
    #local curve_B        = deg2;
    #local balls_num_B    = curve_B/B_factor;
    #local rot_z_B        = curve_B/balls_num_B;
    #local balls_num_intB = int(curve_B/rot_z_B);
    #local reel_dist_B    = rot_z_B*balls_num_intB;
    #local counter_B      = 0;
    #declare x1 = (ray1-ray2)*cos(radians(reel_dist_A));
    #declare y1 = (ray1-ray2)*sin(radians(reel_dist_A));
    #while ( counter_B <= reel_dist_B )
      object { sph translate ray2*x rotate reel_dist_A*z
        rotate < 0, 0, +counter_B >
        translate < x1, y1, 0 >
      }
      #local counter_B = counter_B+rot_z_B;
    #end
    #local C_factor       = 1/(definition/ray1*ray3);
    #local curve_C        = deg3;
    #local balls_num_C    = curve_C/C_factor;
    #local rot_z_C        = curve_C/balls_num_C;
    #local balls_num_intC = int(curve_C/rot_z_C);
    #local reel_dist_C    = rot_z_C*balls_num_intC;
    #local counter_C      = 0;
    #while ( counter_C <= reel_dist_C )
      object { sph translate ray3*x
        rotate < 0, 0, -counter_C >
        translate < -ray3+ray1, 0, 0 >
      }
      #local counter_C = counter_C+rot_z_C;
    #end
    #local D_factor       = 1/(definition/ray1*ray4);
    #local curve_D        = deg4;
    #local balls_num_D    = curve_D/D_factor;
    #local rot_z_D        = curve_D/balls_num_D;
    #local balls_num_intD = int(curve_D/rot_z_D);
    #local reel_dist_D    = rot_z_D*balls_num_intD;
    #local counter_D      = 0;
    #declare xx = (ray3-ray4)*cos(radians(360-(reel_dist_C)))-ray3+ray1;

    #declare yy = (ray3-ray4)*sin(radians(360-(reel_dist_C)));
    #while ( counter_D <= reel_dist_D )
      object { sph translate ray4*x rotate 360-(reel_dist_C)*z
        rotate < 0, 0, -counter_D >
        translate < xx, yy, 0 >
      }
      #local counter_D = counter_D+rot_z_D;
    #end
    translate center*x
  }
#end


#declare apple_gamma   = union {
#declare start    = 0.00;
#declare end_path =  180;
#declare smooth_A = 0.09; // keep it between 0.075-1.00
#declare smooth_B = 0.80; // keep it between 0.5-1.5
#while ( start <= end_path )
  #declare step_num = end_path*smooth_A;
  object {
    pomme_profile (
// 0.25 = radius of the sphere while 0.03 is the starting "density" of
sph rows...
      0.25+((start/end_path)*0.1), 0.03+((start/end_path)*0.5),
      6, 90,
      4.0, 90,
      20, 30,
      4.11111, 150,
      4.0 )
    rotate 90-1*y
    rotate < 0, -start, 0 >
  //  pigment { color rgb < 0.4, 0.4, 0.4 > }
    pigment { color rgb
      < 0.20+((start/end_path)*0.70),
        0.85-((start/end_path)*0.75),
        0.20-((start/end_path)*0.10) >
    }
    finish { rough_chrome }
  }
  #declare smooth_A = smooth_A +((smooth_B-smooth_A)/step_num);
  #declare start = start + end_path/step_num;
#end
}

union {
  object { apple_gamma }
  object { apple_gamma   scale < -1, +1, +1 >  }
  cone { < 0,0,0>, 0.2, < 0,5.0, 0>, 0.75  translate 4*y
    pigment { color Green*0.25 }
    finish { rough_chrome }
  }
  rotate 15*y
}

///////////////   End of this Code
///////////////////////////////////////////////////////////////////////////////////////


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.