POV-Ray : Newsgroups : povray.general : How to autmatically change the color of balls? : Re: How to autmatically change the color of balls? Server Time
31 Jul 2024 22:19:06 EDT (-0400)
  Re: How to autmatically change the color of balls?  
From: Tim Attwood
Date: 29 Aug 2006 00:05:03
Message: <44f3bcef$1@news.povray.org>
> the following lines do not work:
>
>  #read (MyFile, MyVect; E)
>  #read (MyFile, MyVect, E)

OK, first you need to check your I/O restrictions...
Options, Script I/O restrictions, No Restrictions
Options, Script I/O restrictions,
Make sure permit read/write in current directory is checked

Secondly, POVray expects comma seperated values...
that means you need trailing commas on every line except
the last. Something like:

<0, 0, 0>, 1.0,
<0, 0.1, 0>, 0.5,
<0, 0.2, 0>, 0.0

You can set the color in various ways, selecting one from
a spline color function is a good way, or you can just
have the full color vector in the file instead.

// set colors based on a float
#declare  MyColors = function {
   spline {
      linear_spline
      0.0, Red
      0.5, Green
      1.0, Blue
   }
};
// read the file and make spheres
#fopen FileHandle "test_data.txt" read
#while (defined(FileHandle))
    #read (FileHandle, Vector, E)
    sphere {Vector, 0.1
       pigment { color MyColors(E) }
    }
#end
#fclose FileHandle


Post a reply to this message

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