|
![](/i/fill.gif) |
anki wrote:
> could you please suggest me a sample *.pov file which reads a text file
> containing the positions of particles like i have
Here is some sample code which should get you started.
Note that the file format needs to have a comma at the end
of the line as well!
// You mentioned you know the number of points, otherwise do two passes.
#declare NUM = 4000;
// Open data file
#fopen DATA_FILE "pos.txt" read
// Read data
#declare POS_X = array[NUM]; // Create and initialize arrays
#declare POS_Y = array[NUM];
#declare POS_Z = array[NUM];
#declare POS_X[0] = 0.0;
#declare POS_Y[0] = 0.0;
#declare POS_Z[0] = 0.0;
#declare INDEX = 0;
#while (defined(DATA_FILE) & INDEX < NUM)
#read(DATA_FILE,POS_X[INDEX],POS_Y[INDEX],POS_Z[INDEX])
#declare INDEX = INDEX+1;
#end
#declare NUM = INDEX; // Fewer than expected is ok
#fclose DATA_FILE
// Use data
union
{
#declare INDEX = 0;
#while (INDEX < NUM)
sphere {<POS_X[INDEX],POS_Y[INDEX],POS_Z[INDEX]>, 1}
#declare INDEX = INDEX+1;
#end
pigment {color rgb 1}
}
Post a reply to this message
|
![](/i/fill.gif) |