POV-Ray : Newsgroups : povray.newusers : reading from a text file : Re: reading from a text file Server Time
29 Jul 2024 10:24:27 EDT (-0400)
  Re: reading from a text file  
From: Mike Williams
Date: 25 Jan 2006 08:50:55
Message: <km7hVDA5I41DFwZh@econym.demon.co.uk>
Wasn't it shimon_a10 who wrote:
>Hi, every body
>
>1. I want to know how can i read from a text file, float numbers, in order,
>   without the "defined" command.
>2. When i used the exmple in the tutorial, for reading, i read the float
>   numbers not in the order(seqance) that i wanted.
>3. Exmple of the text file, look like that:
>   -0.5 0 -0.5
>    0   0  0
>    0.2 0  0.2
>    1   1  1
>4. I want to know how can i read line's (the three commponent of the vector
>   at the same time).
>5. Is any other format that pov can read except *.txt?.
>6. Lots of thanks.

1. I can't imagine what defined() has to do with any of this.

2. POV's #read command doesn't see the file as a series of lines, it
sees it as a series of fields separated by commas. If you don't have
commas between each of your fields it will miss them. 

3. That's no good. It doesn't have any commas.

4. Only if the data file contains the fields in vector format, like this
        <-0.5,0,-0.5>,
        <0,0,0>,
        <0.2,0,0.2>,
        <1,1,1>
Note that the commas after each vector are required. The line breaks are
not required, sot you can write it like this if you prefer.
        <-0.5,0,-0.5>,<0,0,0>,<0.2,0,0.2>,<1,1,1>

POV doesn't know in advance what sort of field it is expected to try to
read. If is sees a vector it reads a vector. If it sees a number it
reads a number. If it sees a quoted string it reads a string. It doesn't
matter if the variable already contains a different type of object.

5. You can give the file any extension you like, but it has to contain
ASCII text in the specified format.

6. You're welcome
-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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