POV-Ray : Newsgroups : povray.general : Labelled balls Server Time
2 Nov 2024 05:20:22 EDT (-0400)
  Labelled balls (Message 1 to 4 of 4)  
From: Ralf
Subject: Labelled balls
Date: 4 Jun 2004 10:40:09
Message: <web.40c088fe3c4b035e7b0df26c0@news.povray.org>
Hello Everybody!

I'm trying to arrange labelled balls on a grid (see subsequent code). The
problem is that the balls look like pool balls. To become more reliable I
would like use uni-colored balls labelled with black text.

Modifying the 'text{..}' by inserting 'pigment {color Black}' cerates an
error.

In the web I just found examples with text in a glass ball or text growing
out from a ball. Unfortunately all my attempts to modify failed.



Thanks in advance!

Ralf




// Persistence Of Vision raytracer version 3.5 file.
// by Ralf
// 03-06-2004





#include "colors.inc"
#include "functions.inc"
#include "stones.inc"

global_settings {
    assumed_gamma 1.8
    max_trace_level 32
}



camera {location <7.5,17.5,7.5> look_at <7.5,0,7.5>}

light_source {<7.5,20,7.5> 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 /* pigment { Black } */
}
    MakeBall(TextObj, SpotSize, SpotClearance, ColorTex, WhiteTex)
#end


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

#declare BlackTex =
texture {
    pigment {color Black}
}

#declare GreenTex =
texture {
    pigment {color Green}
}



#declare BlueTex =
texture {
    pigment {color Blue}
}



#declare YellowTex =
texture {
    pigment {color Yellow}
}


/* Grid */
cylinder {<0, 0, 0>, <15, 0, 0>,  0.05  open   texture { T_Stone25 scale 4
}}
cylinder {<0, 0, 2.5>, <15, 0, 2.5>,  0.05  open   texture { T_Stone25 scale
4 }}
cylinder {<0, 0, 5>, <15, 0, 5>,  0.05  open   texture { T_Stone25 scale 4
}}
cylinder {<0, 0, 7.5>, <15, 0, 7.5>,  0.05  open   texture { T_Stone25 scale
4 }}
cylinder {<0, 0, 10>, <15, 0, 10>,  0.05  open   texture { T_Stone25 scale 4
}}
cylinder {<0, 0, 12.5>, <15, 0, 12.5>,  0.05  open   texture { T_Stone25
scale 4 }}
cylinder {<0, 0, 15>, <15, 0, 15>,  0.05  open   texture { T_Stone25 scale 4
}}
cylinder {<0, 0, 0>, <0, 0, 15>,  0.05  open   texture { T_Stone25 scale 4
}}
cylinder {<2.5, 0, 0>, <2.5, 0, 15>,  0.05  open   texture { T_Stone25 scale
4 }}
cylinder {<5, 0, 0>, <5, 0, 15>,  0.05  open   texture { T_Stone25 scale 4
}}
cylinder {<7.5, 0, 0>, <7.5, 0, 15>,  0.05  open   texture { T_Stone25 scale
4 }}
cylinder {<10, 0, 0>, <10, 0, 15>,  0.05  open   texture { T_Stone25 scale 4
}}
cylinder {<12.5, 0, 0>, <12.5, 0, 15>,  0.05  open   texture { T_Stone25
scale 4 }}
cylinder {<15, 0, 0>, <15, 0, 15>,  0.05  open   texture { T_Stone25 scale 4
}}




object {MakeTextBall("NM_8", 1.5, 0, GreenTex, WhiteTex)
    rotate x*100
    rotate z*350
    translate z*0
    translate y*0
    translate x*0
}
object {MakeTextBall("NM_2", 1.5, 0.1, GreenTex, WhiteTex)
    rotate x*100
    translate z*0
    translate y*0
    translate x*2.5
}


object {MakeTextBall("DM_10", 1.5, 0.1, BlueTex, WhiteTex)
    rotate x*95
    rotate z*350
    translate z*2.5
    translate y*0
    translate x*0
}


object {MakeTextBall("DM_4", 1.5, 0.1, BlueTex, WhiteTex)
    rotate x*90
    rotate z*350
    translate z*5
    translate y*0
    translate x*0
}

object {MakeTextBall("DM_6", 1.5, 0.1, BlueTex, WhiteTex)
    rotate x*90
    translate z*7.5
    rotate z*350
    translate y*0
    translate x*0
}


object {MakeTextBall("TM_2", 1.5, 0.1, BlackTex, WhiteTex)
    rotate x*90
    rotate z*350
    translate z*10
    translate y*0
    translate x*0
}


object {MakeTextBall("NM_5", 1.5, 0.1, GreenTex, WhiteTex)
    rotate x*85
    rotate z*350
    translate z*12.5
    translate y*0
    translate x*0
}

object {MakeTextBall("IM_10", 1.5, 0.1, RedTex, WhiteTex)
    rotate x*80
    rotate z*350
    translate z*15
    translate y*0
    translate x*0
}


object {MakeTextBall("IM_3", 1.5, 0.1, RedTex, WhiteTex)
    rotate x*80
    translate z*15
    translate y*0
    translate x*2.5
}



object {MakeTextBall("IT_3", 1.5, 0.1, YellowTex, BlackTex)
    rotate x*85
    translate z*12.5
    translate y*0
    translate x*2.5
}


object {MakeTextBall("TM_1", 1.5, 0.1, BlackTex, WhiteTex)
    rotate x*90
    translate z*10
    translate y*0
    translate x*2.5
}




object {MakeTextBall("DM_3", 1.5, 0.1, BlueTex, WhiteTex)
    rotate x*90
    translate z*7.5
    translate y*0
    translate x*2.5
}


object {MakeTextBall("TM_10", 1.5, 0.1, BlackTex, WhiteTex)
    rotate x*90
    translate z*5
    translate y*0
    translate x*2.5
}

object {MakeTextBall("IT_8", 1.5, 0.1, YellowTex, BlackTex)
    rotate x*95
    translate z*2.5
    translate y*0
    translate x*2.5
}


object {MakeTextBall("IT_7", 1.5, 0.1, YellowTex, BlackTex)
    rotate x*100
    translate z*0
    translate y*0
    translate x*5
}


object {MakeTextBall("IT_9", 1.5, 0.1, YellowTex, BlackTex)
    rotate x*95
    translate z*2.5
    translate y*0
    translate x*5
}


object {MakeTextBall("DM_7", 1.5, 0.1, BlueTex, WhiteTex)
    rotate x*90
    translate z*5
    translate y*0
    translate x*5
}

object {MakeTextBall("TM_6", 1.5, 0.1, BlackTex, WhiteTex)
    rotate x*90
    translate z*7.5
    translate y*0
    translate x*5
}

object {MakeTextBall("DM_9", 1.5, 0.1, BlueTex, WhiteTex)
    rotate x*90
    translate z*10
    translate y*0
    translate x*5
}

object {MakeTextBall("IM_2", 1.5, 0.1, RedTex, WhiteTex)
    rotate x*85
    translate z*12.5
    translate y*0
    translate x*5
}


object {MakeTextBall("IT_5", 1.5, 0.1, YellowTex, BlackTex)
    rotate x*80
    translate z*15
    translate y*0
    translate x*5
}

object {MakeTextBall("NM_4", 1.5, 0.1, GreenTex, WhiteTex)
    rotate x*80
    translate z*15
    translate y*0
    translate x*7.5
}


object {MakeTextBall("IM_9", 1.5, 0.1, RedTex, WhiteTex)
    rotate x*85
    translate z*12.5
    translate y*0
    translate x*7.5
}


object {MakeTextBall("NM_10", 1.5, 0.1, GreenTex, WhiteTex)
    rotate x*90
    translate z*10
    translate y*0
    translate x*7.5
}

object {MakeTextBall("TM_4", 1.5, 0.1, BlackTex, WhiteTex)
    rotate x*90
    translate z*7.5
    translate y*0
    translate x*7.5
}


object {MakeTextBall("IT_4", 1.5, 0.1, YellowTex, BlackTex)
    rotate x*90
    translate z*5
    translate y*0
    translate x*7.5
}

object {MakeTextBall("IT_10", 1.5, 0.1, YellowTex, BlackTex)
    rotate x*95
    translate z*2.5
    translate y*0
    translate x*7.5
}

object {MakeTextBall("IT_3", 1.5, 0.1, YellowTex, BlackTex)
    rotate x*100
    translate z*0
    translate y*0
    translate x*7.5
}


object {MakeTextBall("NM_9", 1.5, 0.1, GreenTex, WhiteTex)
    rotate x*100
    translate z*0
    translate y*0
    translate x*10
}

object {MakeTextBall("TM_9", 1.5, 0.1, BlackTex, WhiteTex)
    rotate x*95
    translate z*2.5
    translate y*0
    translate x*10
}

object {MakeTextBall("DM_8", 1.5, 0.1, BlueTex, WhiteTex)
    rotate x*90
    translate z*5
    translate y*0
    translate x*10
}

object {MakeTextBall("TM_5", 1.5, 0.1, BlackTex, WhiteTex)
    rotate x*90
    translate z*7.5
    translate y*0
    translate x*10
}


object {MakeTextBall("NM_6", 1.5, 0.1, GreenTex, WhiteTex)
    rotate x*90
    translate z*10
    translate y*0
    translate x*10
}

object {MakeTextBall("IM_8", 1.5, 0.1, RedTex, WhiteTex)
    rotate x*85
    translate z*12.5
    translate y*0
    translate x*10
}

object {MakeTextBall("IM_7", 1.5, 0.1, RedTex, WhiteTex)
    rotate x*80
    translate z*15
    translate y*0
    translate x*10
}


object {MakeTextBall("IM_4", 1.5, 0.1, RedTex, WhiteTex)
    rotate x*80
    translate z*15
    translate y*0
    translate x*12.5
}


object {MakeTextBall("IT_1", 1.5, 0.1, YellowTex, BlackTex)
    rotate x*85
    translate z*12.5
    translate y*0
    translate x*12.5
}


object {MakeTextBall("IM_4", 1.5, 0.1, BlueTex, WhiteTex)
    rotate x*90
    translate z*10
    translate y*0
    translate x*12.5
}

object {MakeTextBall("NM_7", 1.5, 0.1, GreenTex, WhiteTex)
    rotate x*90
    translate z*7.5
    translate y*0
    translate x*12.5
}

object {MakeTextBall("IM_5", 1.5, 0.1, RedTex, WhiteTex)
    rotate x*90
    translate z*5
    translate y*0
    translate x*12.5
}

object {MakeTextBall("NM_3", 1.5, 0.1, GreenTex, WhiteTex)
    rotate x*95
    translate z*2.5
    translate y*0
    translate x*12.5
}

object {MakeTextBall("DM_5", 1.5, 0.1, BlueTex, WhiteTex)
    rotate x*100
    translate z*0
    translate y*0
    translate x*12.5
}

object {MakeTextBall("TM_8", 1.5, 0.1, BlackTex, WhiteTex)
    rotate x*100
    rotate z*10
    translate z*0
    translate y*0
    translate x*15
}


object {MakeTextBall("IM_8", 1.5, 0.1, RedTex, WhiteTex)
    rotate x*95
    rotate z*10
    translate z*2.5
    translate y*0
    translate x*15
}


object {MakeTextBall("DM_1", 1.5, 0.1, BlueTex, WhiteTex)
    rotate x*90
    rotate z*10
    translate z*5
    translate y*0
    translate x*15
}


object {MakeTextBall("IT_2", 1.5, 0.1, YellowTex, BlackTex)
    rotate x*90
    rotate z*10
    translate z*7.5
    translate y*0
    translate x*15
}


object {MakeTextBall("TM_3", 1.5, 0.1, BlackTex, WhiteTex)
    rotate x*90
    rotate z*10
    translate z*10
    translate y*0
    translate x*15
}

object {MakeTextBall("TM_7", 1.5, 0.1, BlackTex, WhiteTex)
    rotate x*85
    rotate z*10
    translate z*12.5
    translate y*0
    translate x*15
}

object {MakeTextBall("NM_1", 1.5, 0.1, GreenTex, WhiteTex)
    rotate x*80
    rotate z*10
    translate z*15
    translate y*0
    translate x*15
}


plane  {<0,1,0 >,-1  pigment {color White} finish {ambient .5}}


/* Eof */


Post a reply to this message

From: Stefan Viljoen
Subject: Re: Labelled balls
Date: 5 Jun 2004 04:24:35
Message: <40c18323@news.povray.org>
Ralf wrote:

> Hello Everybody!
> 
> I'm trying to arrange labelled balls on a grid (see subsequent code). The
> problem is that the balls look like pool balls. To become more reliable I
> would like use uni-colored balls labelled with black text.
> 
> Modifying the 'text{..}' by inserting 'pigment {color Black}' cerates an
> error.
> 
> In the web I just found examples with text in a glass ball or text growing
> out from a ball. Unfortunately all my attempts to modify failed.
> 
> Now I’m looking for an example of a solid sphere labelled with text.
> 
> Thanks in advance!
> 
> Ralf

How about

1. Sphere
2. Difference the text out of it.
3. Intersect the same text with another sphere in exactly the same position.

?

-- 
Stefan Viljoen
Software Support Technician
Polar Design Solutions


Post a reply to this message

From: Florian Brucker
Subject: Re: Labelled balls
Date: 5 Jun 2004 07:11:45
Message: <40c1aa71@news.povray.org>
> Modifying the 'text{..}' by inserting 'pigment {color Black}' cerates an
> error.

The text{...} is part of an object pattern (see POV-Ray documentation 
for details) and therefore only defines the pattern. To change the 
color/texture of the pattern, change the following line in:

>     sphere  {< 0, 0, 0>, 1
>         texture {		
>             object {PatternObj texture {WhiteTex}, texture {ColorTex}}
>         }
>     }


 > object {PatternObj texture {WhiteTex}, texture {ColorTex}}

Simply replace texture{WhiteTex} or texture{ColorTex} with an other 
texture definition.


HTH,
Florian


Post a reply to this message

From: Phil Cook
Subject: Re: Labelled balls
Date: 5 Jun 2004 14:22:03
Message: <opr84wi8swe4dfwg@news.povray.org>
And lo on Sat, 05 Jun 2004 13:19:54 +0200, Florian Brucker 
<tor### [at] torfboldcom> did spake, saying:

>> Modifying the 'text{..}' by inserting 'pigment {color Black}' cerates an
>> error.
>
> The text{...} is part of an object pattern (see POV-Ray documentation 
> for details) and therefore only defines the pattern. To change the 
> color/texture of the pattern, change the following line in:
>
>>     sphere  {< 0, 0, 0>, 1
>>         texture {		
>>             object {PatternObj texture {WhiteTex}, texture {ColorTex}}
>>         }
>>     }
>
>
>  > object {PatternObj texture {WhiteTex}, texture {ColorTex}}
>
> Simply replace texture{WhiteTex} or texture{ColorTex} with an other 
> texture definition.
>
>
> HTH,

This was also posted in .newusers, I'm not sure just replacing either of 
the two textures is what Ralf is looking to achieve , the object pattern 
he's using is made up of the difference of the cylinders and the text 
pattern so they would always be the same colour, so a red ball with white 
spot and black text would not be possible by this method.

--
Phil Cook


-- 
All thoughts and comments are my own unless otherwise stated and I am 
happy to be proven wrong.


Post a reply to this message

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