POV-Ray : Newsgroups : povray.newusers : Multiple Objects : Re: Multiple Objects Server Time
4 Nov 2024 13:00:45 EST (-0500)
  Re: Multiple Objects  
From:
Date: 18 Sep 2003 18:17:07
Message: <3f6a2ee3$1@news.povray.org>
// Hi Kevin!
//
// Here follows a ball macro which might do what you need.
//
//   Sputnik


// Pool Ball

#macro PoolBall (Radius, Color, Number)

#local PoolBallFinish = finish {
  ambient .3
  diffuse .7
  specular .3 roughness 0.01
  reflection .2
  }

union {

  // main sphere
  sphere { 0, Radius
    pigment { color Color }
    finish { PoolBallFinish }
    }

  // core
  intersection {
    cylinder { -Radius*z, Radius*z, .65*Radius }
    sphere { 0, Radius*1.001 } // slightly larger radius to
                               // avoid coincident surfaces
    pigment { color rgb 1 }
    finish { PoolBallFinish }
    }

  #if (Number>0)
    // number
    #local Num = text { ttf "arial.ttf" str(Number,0,0) Radius/4, 0 }
    #local Num = intersection {
      object { Num
        translate -max_extent(Num)/2 // center around origin
        scale 1.2*Radius // make bigger
        translate -Radius*z // transfer to surface of ball
        }
      sphere { 0, Radius*1.002 } // slightly larger radius to
                                 // avoid coincident surfaces
      pigment { color rgb 0.2 }
      finish { PoolBallFinish }
      }

    // number on -z side
    object { Num }
    // number on +z side
    object { Num rotate 180*y}
    #end//if

  // no "}" to allow for application of modifiers

  #end//macro Ball


// put a ball into the scene
PoolBall (2, rgb <.8, .2, .1>, 4) /*{*/ rotate 30*z translate 2*y}

// one more ball; don't know if colors match numbers
PoolBall (0.8, rgb <.2, .2, .8>, 5) /*{*/ rotate <50, -70, 0>
  translate <-2, 0.6, -2.5> }

// small ball without number
// (of course a simple sphere would suffice)
PoolBall (1.2, rgb 1, 0) /*{*/ translate <3, 0.6, -1.5> }


// reflecting balls need a checkered plane to survive ...
plane { y, 0
  pigment { checker color green .6 color green .55 }
  finish { ambient .3 diffuse .7 }
  }


light_source { <-2, 3, -1>*10, color rgb 1 }

camera { location -20*z look_at 0 angle 25 rotate <30, -20, 0>
  translate 1*y }


Post a reply to this message

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