|
|
Hi!
I looked at some answers to read data and to draw spheres in 3D BOX. I am
very interested in that. So, I am trying to do those. But, drawn spheres is
not matched with data as a position. My data file is 'practice.txt'. Also,
format is as following:
100.2 200.3 0
200.1 100.2 0
10.2 23.1 0
etc
For original data(sphere position), I use 'space' instead of 'comma' between
values.
Program is also as following:
#fopen MyFile "practice.txt" read
#while (defined(MyFile))
#read (MyFile,Var1,Var2,Var3)
sphere {
<Var1, Var3, Var2>, 0.5
texture {
pigment { color Yellow }
}
}
#end
Is there any problem on the program and/or data file format?
Thank you very much for your help.
Post a reply to this message
|
|
|
|
> I looked at some answers to read data and to draw spheres in 3D BOX. I am
> very interested in that. So, I am trying to do those. But, drawn spheres
is
> not matched with data as a position. My data file is 'practice.txt'. Also,
> format is as following:
>
> 100.2 200.3 0
> 200.1 100.2 0
> 10.2 23.1 0
> etc
Povray requires commas between the various values, even at the end of line
(but not at the end of file!). In regard to your other questions: it can
read integers or floats (where a "." separates integer-part from float-part,
like "3.51" or "2135.98124"), or strings surrounded by " (e.g. "string").
You could also have a look at my IO-Macros, the link to my website is in the
sig.
Regards,
Tim
--
aka "Tim Nikias v2.0"
Homepage: <http://www.nolights.de>
Post a reply to this message
|
|
|
|
In article <web.43886ab1919621bdcce6fd2b0@news.povray.org>,
"cutejuly" <cut### [at] hotmaicom> wrote:
::Hi!
::
::I looked at some answers to read data and to draw spheres in 3D BOX. I am
::very interested in that. So, I am trying to do those. But, drawn spheres is
::not matched with data as a position. My data file is 'practice.txt'. Also,
::format is as following:
::
::100.2 200.3 0
::200.1 100.2 0
::10.2 23.1 0
::etc
::
::For original data(sphere position), I use 'space' instead of 'comma' between
::values.
::
::Program is also as following:
::
::#fopen MyFile "practice.txt" read
:: #while (defined(MyFile))
:: #read (MyFile,Var1,Var2,Var3)
::
:: sphere {
:: <Var1, Var3, Var2>, 0.5
:: texture {
:: pigment { color Yellow }
:: }
:: }
::#end
::
::
::Is there any problem on the program and/or data file format?
::
::Thank you very much for your help.
at http://www.povray.org/documentation/view/3.6.1/238/ you can read :
"The format of the data to be read must be a series of valid string
literals, float literals, or vector literals SEPARATED BY COMMA."
any valid reason to use a space instead of comma ?
can can play with this small sample code (not tested in deep)
// --------------------------------------------------------------
#version unofficial MegaPov 1.21;
#declare alea=seed(13589);
#declare theFileName="outfile.txt";
#declare floatNum = 30;
// --- fill the file with random floats numbers
#debug "fill the file"
#declare index=1;
#fopen myFileRef theFileName write
#while (index<floatNum)
#write (myFileRef, 10000*rand(alea)-5000,",")
#set index=index+1;
#end
#write (myFileRef, 10000*rand(alea)-5000)
#fclose myFileRef
#debug "\n\n"
// --- now, read numbers as single float value
#debug "Read as single value"
#declare index=1;
#fopen myFileRef theFileName read
#while (defined(myFileRef))
#read (myFileRef,oneFloat)
#debug concat(str(index,3,0)," : ",str(oneFloat,10,3),"\n")
#set index=index+1;
#end
#fclose myFileRef
#debug "\n\n"
// --- say that this is vectors...
#debug "Read as vector value...\n"
#declare index=1;
#fopen myFileRef theFileName read
#while (defined(myFileRef))
#read (myFileRef,xFloat, yFloat, zFloat)
#debug concat(str(index,3,0)," :
<",str(xFloat,10,3),",",str(yFloat,10,3),",",str(zFloat,10,3),">\n")
#set index=index+1;
#end
#fclose myFileRef
#debug "\n\n"
klp ;)
Post a reply to this message
|
|