POV-Ray : Newsgroups : povray.general : Reading from a text file : Reading from a text file Server Time
29 Jul 2024 10:26:04 EDT (-0400)
  Reading from a text file  
From: Scott
Date: 5 Jan 2012 08:45:00
Message: <web.4f05a8fc1cabb177be8719c80@news.povray.org>
This should be easy, but I'm having some trouble.

I would like to read a series of vectors <x,y,z> from a text file and plot the
points as spheres.  To test things out, I made a text file with 2 vectors
separated by commas.

I get this error message.  Can anyone tell me what I am doing wrong?

//-------------------------------------------
#fopen MyFile "myData.txt" read
# local i = 1;
  #while (i<2)
  #read (MyFile,Vector[i]
Parse Error: Expected 'undeclared identifier', empty array found instead
//---------------------------------------------

Here is the POV-Ray code I used:

#declare maxArray = 2;
#declare Vector = array[maxArray];

#fopen MyFile "myData.txt" read
# local i = 1;
  #while (i<2)
        #read (MyFile,Vector[i])
        #local i = i + 1;
  #end

#declare Graphic = union {

sphere {
  Vector[i],    1  texture {
    pigment { color rgb <1,0,0> }
    finish { Substance }
  }
}
sphere {
  Vector[i],    1  texture {
    pigment { color rgb <1,1,0 > }
    finish { Substance }
  }
}
} // end of Graphic


Post a reply to this message

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