POV-Ray : Newsgroups : povray.newusers : how to draw sth on the surface of a ball : Re: how to draw sth on the surface of a ball Server Time
4 Nov 2024 13:03:49 EST (-0500)
  Re: how to draw sth on the surface of a ball  
From:
Date: 3 Oct 2003 23:03:48
Message: <3f7e3894$1@news.povray.org>
// Hi Mudong,
//
// Here is one more smiley I've found lying around; this was my easter
// desktop. (Actually sort of eggsperiment ...) Instead of using the
// pigment{object{...}} method the eyes and mouth are created by CSG
// and clipped by intersection with a sphere slighty larger than the
// yellow head. Of course the mouth of Bob's smiley is much nicer than
// mine, but I wanted to leave something for you to do :-))
//
//    Sputnik



// Smilegg

// +SP8 +EP8 +A0.1 +AM2 +R3 +W512 +H384 -FN +D


#macro Egg (Color)
  #local R = 2; // 1: pointed top; >1: round top
  #local T = 0.5; // thickness factor
  cubic {
    <   //    x^2 + z^2 <= y^3 - R*y^2 - y + R = (y-R) * (y+1) * (y-1)
     0, // x^3
     0, // x^2*y
     0, // x^2*z
    +1, // x^2
     0, // x*y^2
     0, // x*y*z
     0, // x*y
     0, // x*z^2
     0, // x*z
     0, // x
    -1, // y^3
     0, // y^2*z
    +R, // y^2
     0, // y*z^2
     0, // y*z
    +1, // y
     0, // z^3
    +1, // z^2
     0, // z
    -R> // 1
    sturm
    scale <T, 1, T>
    clipped_by { box { <-1, -1, -1>, <1, 1, 1> } }
    bounded_by { clipped_by }
    translate y
    texture {
      pigment { color rgb Color }
      finish { ambient .2 diffuse .5 specular .3 roughness 1 }
      }
    }
  #end//macro Egg


#macro Smilegg (XPos)

  union {

    // sliced egg
    intersection {
      plane { -z, 0.3
        texture {
          pigment { color rgb 1 }
          finish { ambient .8 }
          }
        }
      Egg (<1, .75, .5>)
      }

    // core of egg = head of smiley
    sphere { 0.8*y, 0.5
      texture {
        pigment { rgbt <1, .9, .3, 0> }
        finish { ambient .6 diffuse .6 }
        }
      }

    // eyes and mouth
    intersection {
      // clipping sphere
      sphere { 0.8*y, 0.501 }
      #local X = 0.2;
      #local Y = 0.95;
      union {
        // eyes
        cylinder { <-X, Y, -1>, <-X, Y, 1>, 0.07 }
        cylinder { < X, Y, -1>, < X, Y, 1>, 0.07 }
        // mouth
        difference {
          #local R = 0.4;
          // difference of two coaxial cylinders ...
          cylinder { -z, z, R }
          cylinder { -1.01*z, 1.01*z, R-0.07 }
          // ... reduced to a segment
          plane { -y, 0 rotate  40*z }
          plane { -y, 0 rotate -40*z }
          rotate -10*x
          translate (R+0.55)*y
          }
        }
      texture {
        pigment { color rgb 0 }
        finish { specular .5 }
        }
      }//intersection

    translate XPos*x

    }//union

  #end//macro Smilegg


Smilegg (-0.8)
Smilegg ( 0.8)

background { color <58, 110, 165>/255 }
light_source { <-10, 10, -5>, 1 }
camera { location <0, 1.5, -6> look_at y angle 30 }


Post a reply to this message

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