POV-Ray : Newsgroups : povray.newusers : Balls on a grid : Re: Balls on a grid Server Time
2 Nov 2024 09:22:00 EDT (-0400)
  Re: Balls on a grid  
From: Ralf
Date: 8 Jun 2004 03:20:01
Message: <web.40c5681b890e5fa57b0df26c0@news.povray.org>
Dear Phil

Thank you for your advice. Your first solution already works pretty well.

An other very good solution was mailed directly by Friedrich. Because this
might be of interest for any Newbies working on similar problems, I list
the code below.

Thanks to all of you for your help :-)

Ralf



/* Code from Friedrich */

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

#include "stones.inc"

global_settings {
    assumed_gamma 1.8
    max_trace_level 32
}



#declare Camera_1 = camera { location <7.5,17.5,7.5>
                            right x*image_width/image_height
                            look_at <7.5,0,7.5>}

#declare Camera_2 = camera { angle 5.1                       // Weiter weg =
weniger Verzerrung!  Lo
                            location <7.5,280,7.5>
                            right x*image_width/image_height
                            look_at  <7.5, 0,7.5>}
camera {Camera_2}

light_source {<7.5,20+100,7.5> color White}     // Licht weiter weg wirft


// sky -------------------------------------------------------------------
sky_sphere{ pigment{ gradient <0,1,0>
                     color_map{ [0   color rgb<1,1,1>]//White
                                [0.4 color
rgb<1,1,1>]//<0.14,0.14,0.56>]//~Navy
                                [0.6 color
rgb<1,1,1>]//<0.14,0.14,0.56>]//~Navy
                                [1.0 color rgb<1,1,1>]//White
                              }
                     scale 2 }
           } // end of sky_sphere
//------------------------------------------------------------------------


/* *********************************************************** */



#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"    geschenkt! */
        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 {                           //  Das macht den Farbring
der Billiardkugeln! Lo
            cylinder {-z*2, z*2, 5}
            cylinder {-z*2, z*2, SpotSize/2}
        }
      */
    }// end of union of "PatternObj"  Lo

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

        }
    rotate <90,0,0>

    }
#end


#macro MakeTextBall(Text, SpotSize, SpotClearance, ColorTex, WhiteTex)
    #local TextObj =
    text { ttf "arial.ttf" /*crystal.ttf"*/ , Text, 1, 0  // texture{
pigment { Black } } "Das geht nicht! "
           scale <0.75,1,1> // Lo
         } // end of text object

    MakeBall(TextObj, SpotSize, SpotClearance, ColorTex, WhiteTex)
#end


#declare RedTex =
texture {
    pigment {color Red}
}
#declare WhiteTex =
texture {
    pigment {color White*1.2}
    finish  {phong 1}
}

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

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



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



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

#declare YellowGreenTex =
texture {
    pigment {color rgb<0.8,1,0.3>}
    finish  {ambient 0.15 diffuse 0.85 phong 0.5}
}


#declare HellgelbTex =
texture {
    pigment {color rgb<1.0,1.0,0.5>}
    finish  {ambient 0.15 diffuse 0.85 phong 0.5}
}

#declare DotterGelbTex =
texture {
    pigment {color rgb<1.0,0.6,0.0>}
    finish  {ambient 0.15 diffuse 0.85 phong 0.5}
}

#declare Metall1 = texture { Polished_Chrome
                   //  pigment{ color rgb<1,0,0>}
                   normal { bumps 0.5 scale 0.005}
                   finish { ambient 0.1 diffuse 0.85  phong 1}
                 } // end of texture

#declare Metall2 = texture { Polished_Chrome
                     pigment{ color rgb<1,0.6,0>}
                   normal { bumps 0.5 scale 0.005}
                   finish { ambient 0.1 diffuse 0.85  phong 1}
                 } // end of texture

/* Gitter definieren */
/*
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
}}
*/


Raster(weite) sind einfacher!
#declare Stab = cylinder {<0, 0, 0>, <15, 0, 0>,  0.05   texture {T_Stone25
scale 4 }}
                                                        // texture
{Metall2}}
#declare Raster = 2.5;

#local Nr = 0; #local End = 7; // start / end of loop
#while (Nr < End)

  object{ Stab translate<0,0,Nr*Raster>}
  object{ Stab rotate<0,-90,0>
               translate<Nr*Raster,0,0>}
 #local Nr = Nr + 1;
#end // of while loop
//-------------------------------------------------------------------------------------------

object {MakeTextBall("NM_8", 1.5, 0, BlackTex, Metall2)
    //rotate y*100
    //rotate z*350
    translate z*0
    translate y*0
    translate x*0
}
object {MakeTextBall("NM_2", 1.5, 0.1, BlackTex, YellowGreenTex)
    // rotate x*100
    translate z*0
    translate y*0
    translate x*2.5
}


object {MakeTextBall("DM_10", 1.5, 0.1, BlackTex, 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, BlackTex, WhiteTex)
   // rotate x*90
   // rotate z*350
    translate z*5
    translate y*0
    translate x*0
}

object {MakeTextBall("DM_6", 1.5, 0.1, BlackTex, 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, BlackTex, Metall2)
    //rotate x*85
    //rotate z*350
    translate z*12.5
    translate y*0
    translate x*0
}

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


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



object {MakeTextBall("IT_3", 1.5, 0.1, BlackTex, DotterGelbTex)
    //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}}
                                           finish {ambient 1 diffuse 0}}
//alternativ


/* Eof */


Post a reply to this message

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