POV-Ray : Newsgroups : povray.general : Reading coordinates into povray from an ascii file Server Time
29 Jul 2024 18:16:38 EDT (-0400)
  Reading coordinates into povray from an ascii file (Message 1 to 4 of 4)  
From: John
Subject: Reading coordinates into povray from an ascii file
Date: 12 Dec 2010 23:00:00
Message: <web.4d05993a67d8c71bd6b9b2630@news.povray.org>
All -

I'm trying to render a collection of rods in 3-space using a .txt file in
Windows which contains the {x,y,z} centers of the rods as well as the
{theta,phi} angles of orientation of the rods as well.

I'm very well versed in R and Matlab, but am a total neophyte in povray and need
help setting up this small but important routine.

I've managed to #fopen and apparently #read the file successfully -- well, at
least without throwing an error -- but don't know how to assign the read
material into an array that can be used in a while loop for rendering the many
(e.g., hundreds) of rods specified in the text file.

Any syntactic hints?

Thanks!

John


Post a reply to this message

From: bitman
Subject: Re: Reading coordinates into povray from an ascii file
Date: 13 Dec 2010 11:00:56
Message: <4d064338@news.povray.org>
On 12/13/2010 04:55 AM, John wrote:
> I've managed to #fopen and apparently #read the file successfully -- well, at
> ...
> Any syntactic hints?



Hi John

in one animation I write some variables into a file, to re read them with the next
frame.

Just write the declaration, you want to be read into the file, using the Povray
SDL-syntax:


	//===< Write Values to File
	 #fopen b1 "b1.inc" write
	  #write(b1,"\n#declare ST_Centre       =",ST_Centre      ,";")
	  #write(b1,"\n#declare ST_Normal       =",ST_Normal      ,";")
	  #write(b1,"\n#declare b1_pos          =",b1_pos         ,";")
	  #write(b1,"\n#declare b1_normal       =",b1_normal      ,";")
	  #write(b1,"\n#declare b1_speed        =",b1_speed       ,";")
	  #write(b1,"\n#declare bl_acceleration =",bl_acceleration,";")
	  #write(b1,"\n#declare b1_gravity      =",b1_gravity     ,";")
	  #write(b1,"\n#declare b1_resistence   =",b1_resistence  ,";")
	 #fclose b1


then you can just include this file in another run:

	#include "b1.inc"

that's it :)

BR
bitman


Post a reply to this message

From: Warp
Subject: Re: Reading coordinates into povray from an ascii file
Date: 13 Dec 2010 11:18:43
Message: <4d064762@news.povray.org>
John <jyo### [at] umichedu> wrote:
> I've managed to #fopen and apparently #read the file successfully -- well, at
> least without throwing an error -- but don't know how to assign the read
> material into an array that can be used in a while loop for rendering the many
> (e.g., hundreds) of rods specified in the text file.

  The file must contain comma-separated values. If it isn't already, then
it will be a bit difficult to read from POV-Ray directly.

  If you are able to generate the data file with whatever format you want,
you could write is as comma-separated values, but an even easier way is if
you write the data as an array declaration directly and then simply #include
the file in POV-Ray. (It would basically still be a list of comma-separated
values, but with an additional array declaration at the beginning, as well
as the curly brackets.)

-- 
                                                          - Warp


Post a reply to this message

From: bitman
Subject: Re: Reading coordinates into povray from an ascii file
Date: 13 Dec 2010 12:08:52
Message: <4d065324@news.povray.org>
On 12/13/2010 05:01 PM, bitman wrote:
> On 12/13/2010 04:55 AM, John wrote:
>> I've managed to #fopen and apparently #read the file successfully --
>> well, at
>> ...
>> Any syntactic hints?
>
>
>
> Hi John
>
> in one animation I write some variables into a file, to re read them
> with the next frame.
>
> Just write the declaration, you want to be read into the file, using the
> Povray SDL-syntax:
>
>
> //===< Write Values to File
> #fopen b1 "b1.inc" write
> #write(b1,"\n#declare ST_Centre =",ST_Centre ,";")
> #write(b1,"\n#declare ST_Normal =",ST_Normal ,";")
> #write(b1,"\n#declare b1_pos =",b1_pos ,";")
> #write(b1,"\n#declare b1_normal =",b1_normal ,";")
> #write(b1,"\n#declare b1_speed =",b1_speed ,";")
> #write(b1,"\n#declare bl_acceleration =",bl_acceleration,";")
> #write(b1,"\n#declare b1_gravity =",b1_gravity ,";")
> #write(b1,"\n#declare b1_resistence =",b1_resistence ,";")
> #fclose b1
>
>
> then you can just include this file in another run:
>
> #include "b1.inc"
>
> that's it :)
>
> BR
> bitman
>
>
>

hm, It seems I misread your post in a haste,
I would write a conversation script (perl, python etc) to convert your input format
in an format readable by Povray (#include).


Post a reply to this message

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