POV-Ray : Newsgroups : povray.general : Read data and draw sphere? Server Time
31 Oct 2024 08:14:46 EDT (-0400)
  Read data and draw sphere? (Message 1 to 4 of 4)  
From: cutejuly
Subject: Read data and draw sphere?
Date: 26 Nov 2005 09:05:01
Message: <web.43886ab1919621bdcce6fd2b0@news.povray.org>
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

From: Tim Nikias
Subject: Re: Read data and draw sphere?
Date: 26 Nov 2005 09:20:13
Message: <43886f1d$1@news.povray.org>
> 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

From: kurtz le pirate
Subject: Re: Read data and draw sphere?
Date: 26 Nov 2005 09:22:46
Message: <kurtzlepirate-0BCF99.15224526112005@news.povray.org>
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

From: cutejuly
Subject: Re: Read data and draw sphere?
Date: 26 Nov 2005 10:20:00
Message: <web.43887ca525670200cce6fd2b0@news.povray.org>
Thank you very much.

It works very well...


Post a reply to this message

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