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 12:59:01 EST (-0500)
  Re: how to draw sth on the surface of a ball  
From:
Date: 4 Oct 2003 18:20:04
Message: <3f7f4794$1@news.povray.org>
// Hi Mudong and Bob,
//
// I've played around with smileys with 3D-eyes and mouth; the
// following code (this time without eggs to avoid the "abnormal
// fears" of Bob) shows a collection of smileys with varying
// mouth. Changing the transparency of the yellow sphere's pigment
// to rgbt <1, .9, .3, .5> will show the "inner parts" of the
// mouth-torus. And of course modifying the other constants in
// the code for eyes and mouth gives funny results!
//
//    Sputnik



// Smileys

// +SP8 +EP8 +A0.1 +AM2 +R3 +W1024 +H768 -FN +D


#macro Smiley (Wide, Thick, Pos)
// Wide controls the width of the mouth (0.8 ... 1.1)
// Thick controls the thickness of "the lip" (0.6 ... 1.4)
// Pos is the position of the smiley's center

  union {

    union {

      // core of egg = head of smiley
      sphere { 0, 0.5
        pigment { rgbt <1, .9, .3, 0> } // change the transparency to
                                        // 0.5 to see what's going on!
        finish { ambient .6 diffuse .6 }
        }

      // eyes
      sphere { 0, 0.1      // get an eye ball
        scale <1, 1, 0.4>  // make it flat
        translate -0.5*z   // put onto surface of head at nose position
        rotate <20, 30, 0> // rise and turn to it's final position
        }
      sphere { 0, 0.1
        scale <1, 1, 0.2>
        translate -0.5*z
        rotate <20, -30, 0>
        }

      // mouth
      torus { 0.3, 0.1          // get a torus inside head
        scale <Wide, Thick, 1>  // make small/wide / thin/fat mouth
        translate <0, 0.2, -0.1>// pull up and towards face -- this
                                // gives a mouth at eyebrows position
        rotate -65*x            // rotate mouth to correct position
        }

      texture {
        pigment { color rgb 0 }
        finish { specular .6 }
        }

      }//union

    translate Pos

    }//union

  #end//macro Smiley


#declare Row = 0; // Row = 0, 1, 2
#while (Row<3)

  #declare Thickness = 0.6+0.4*Row;
  #declare Y = 1.3*(Row-1);

  #declare Column = 0; // Column = 0, 1, 2, 3
  #while (Column<4)

    #declare Width = 0.8+0.1*Column;
    #declare X = 1.3*(Column-1.5);

    Smiley (Width, Thickness, <X, Y, 0>)

    text { ttf "timrom.ttf"
      concat(
        "Smiley(", str(Width,3,1), ", ", str(Thickness,3,1),
        ", <", str(X,3,1), ",", str(Y,3,1), ",0>)"
        )
      0.1, 0
      scale 0.09
      translate <X-0.55, Y-0.6, 0>
      }

    #declare Column = Column+1;
    #end//while Column

  #declare Row = Row+1;
  #end//while Row


background { color <58, 110, 165>/255 }
light_source { <-10, 3, -8>, 1 }
camera { location -10*z look_at 0 angle 30 }


Post a reply to this message

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