|
![](/i/fill.gif) |
> Hi Alain and Simon
>
> Thanks a lot for your reply, atleast some things are clear now
>
> actually my text file looks like below
> 1st column is sphere number
> 2nd column is x-position, 3rd- y position and 4th- z -position
> there are 4000 particles in a box
>
> 1 487.726807 383.565125 99.485672
> 2 377.206238 393.352325 17.296064
> 3 452.328613 346.985321 33.054535
> 4 453.301697 334.173981 14.480576
> 5 724.187988 389.938171 55.237068
> 6 298.778717 388.706055 30.780521
> 7 685.588074 366.411072 31.322350
> ...............................
> .........................
> ...........................
> 4000 56.78 456.67 234.56
>
>
> i can make the text file , where columns are separated by commas like
>
> x1,y1,z1
> x2,y2,z2
> x3,y3,z3
> ......
> ......
>
> still i have a doubt about the format to use in *.pov file to read this text
> file
>
> is it like to put the commands as
>
> "#fopen identifier 'pos.txt' read
> while loop
> end" in a file named sphere.pov and use ./povray sphere.pov to produce
> rendering image ?
>
> could you please suggest me a sample *.pov file which reads a text file
> containing the positions of particles like i have
>
> thank you very much
> regards
> anki
>
Put a coma after each values.
Sample file:
#declare Cluster = union{
#fopen DATA_FILE "pos.txt" read
#read(DATA_FILE, PosX, PosY, PosZ)
#while (defined(DATA_FILE))
sphere{<PosX, PosY, PosZ>, Radius}
#end
#fclose DATA_FILE
pigment{rgb 1}
}
It opens your input file and read the first 3 values.
It then start a loop.
The loop place a single sphere, then it reads the next 3 values.
It will continue to loop until you reatch the end of your file. At that
moment, DATA_FILE becomes undefined and the loop falls through.
The #fclose DATA_FILE is not realy needed as the file is automaticaly
closed, and it's identifier suppressed, after you tried to read past
it's end.
After the end of the loop, a texture is applied to the union and the
union is closed.
I used a #declare. It allows you to use your cluster of spheres several
times with no need to read your data a second time.
This construction allows you to read any file of any length with no need
to know how many elements are contained in it.
You don't need any array.
You can use any object as your shape, you are not limited to use spheres.
Alain
Post a reply to this message
|
![](/i/fill.gif) |