POV-Ray : Newsgroups : povray.text.scene-files : Pool Balls Server Time
1 Nov 2024 11:16:23 EDT (-0400)
  Pool Balls (Message 1 to 1 of 1)  
From: Chris Huff
Subject: Pool Balls
Date: 3 Sep 2000 20:12:18
Message: <chrishuff-473651.19135703092000@news.povray.org>
This scene demonstrates how to put text on objects using text objects 
and the object pattern. The MakeBall macro takes an object and resizes 
it to fit the spot, the MakeTextBall macro takes a character and 
automatically generates a text object and calls the MakeBall macro. The 
text is flipped around for the opposite side of the ball.
MegaPOV required(for *_extent() functions and object pattern).


#include "colors.inc"
#include "textures.inc"
#version unofficial MegaPov 0.5;
//-------------------------------------------
global_settings {
    assumed_gamma 1.8
    max_trace_level 32
}

camera {
    location <0, 3.5,-8>
    up y*image_height right x*image_width
    angle 25
    look_at <0, 1, 0>
}
light_source {<0, 3.5,-8> color White*0.5}

box {<-100, 0,-100>, < 100, 0, 100>
    texture {
        pigment {checker color Black, color White}
    }
}
//*******************************************

#macro MakeBall(Text, SpotSize, SpotClearance, ColorTex, WhiteTex)
    #local Mn = min_extent(Text);
    #local Mx = max_extent(Text);
    #local PatternObj =
    union {
        object {Text
            translate -Mn - 0.5*(Mx-Mn)
            scale  x + y + z*1/(Mx.z - Mn.z)
            scale (x+y)*(SpotSize-SpotClearance)/vlength(<Mx.x, Mx.y, 0> 
- <Mn.x, Mn.y, 0>) + z
            translate -z*1
        }
        #debug "\n"
        #debug str((Mx.z - Mn.z),0,0)
        #debug "\n"
        object {Text
            translate -Mn - 0.5*(Mx-Mn)
            scale  -x + y + z*1/(Mx.z - Mn.z)
            scale (x+y)*(SpotSize-SpotClearance)/vlength(<Mx.x, Mx.y, 0> 
- <Mn.x, Mn.y, 0>) + z
            translate z*1
        }
        difference {
            cylinder {-z*2, z*2, 5}
            cylinder {-z*2, z*2, SpotSize/2}
        }
    }
    sphere  {< 0, 0, 0>, 1
        texture {
            object {PatternObj texture {WhiteTex}, texture {ColorTex}}
        } 
    }
#end


#macro MakeTextBall(Text, SpotSize, SpotClearance, ColorTex, WhiteTex)
    #local TextObj =
    text {ttf "crystal.ttf", Text, 1, 0}
    MakeBall(TextObj, SpotSize, SpotClearance, ColorTex, WhiteTex)
#end


#declare RedTex =
texture {
    pigment {color Red}
}
#declare WhiteTex =
texture {
    pigment {color White}
}

object {MakeTextBall("13", 0.75, 0.1, RedTex, WhiteTex)
    translate y*1
    translate -x*1
}
object {MakeTextBall("13", 0.75, 0.1, RedTex, WhiteTex)
    rotate y*180
    translate y*1
    translate x*1
}
//*******************************************

light_source {<-20, 15, -100 > color White}

//-------------------------------------------

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

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