POV-Ray : Newsgroups : povray.animations : How do you use an external Text file for animation values Server Time
7 May 2024 14:00:01 EDT (-0400)
  How do you use an external Text file for animation values (Message 1 to 10 of 10)  
From: audioguytodd
Subject: How do you use an external Text file for animation values
Date: 26 Jan 2008 12:20:01
Message: <web.479b6b2f274eb86c230bdc7b0@news.povray.org>
Could someone please post a small example of how to use an external Text file to
input variables in an animation??? I have Vectors (and other data) in a text
file that I would like to read for each frame. I have done this a long time
ago, but seem to have forgotten.

Thank in advance,

audioguytodd


Post a reply to this message

From: Leroy
Subject: Re: How do you use an external Text file for animation values
Date: 26 Jan 2008 23:35:14
Message: <479C0955.3050009@joplin.com>
audioguytodd wrote:
> Could someone please post a small example of how to use an external Text file to
> input variables in an animation??? I have Vectors (and other data) in a text
> file that I would like to read for each frame. I have done this a long time
> ago, but seem to have forgotten.
> 
> Thank in advance,
> 
> audioguytodd
> 
> 
Your in luck I was just doing that the other day.
(reading text files for my animated robots)
  here's an example

#declare RVal=0;
#fopen Myfile "Action.txt" read
  #while (defined(Myfile))
   #read (Myfile Frame,Data)
   #declare Frame_Count=Frame_Count+Frame;
   #if ((Frame_Count>Frame_number)&(K=0))
    // fix two frame data variables
    #declare K=1;
    #declare AtFrame1=Frame_Count-Frame; //first data frame
    #declare First_Data=OldData;// first data
    #declare Second_Data=Data;// second data frame
    #declare AtFrame2=BTD; //second data
   #end
   #declare OldData=Data;
   #declare RVal=RVal+1;//keep track of reads
  #end

You might not be in luck at that.
  My data has in it the difference between each "pose's" frame.
  It also reads all the data for every frame you render.
  Well I hope this helps.


Post a reply to this message

From: audioguytodd
Subject: Re: How do you use an external Text file for animation values
Date: 27 Jan 2008 11:55:00
Message: <web.479cb7386e870b0f230bdc7b0@news.povray.org>
Hmmm. I am getting this error:

Parse Error: Expected 'float, vector, or string literal', ,found instead.

My code in the POV file:

#fopen MyFile "c:\filename.txt" read
#while (defined(MyFile))
#read (MyFile, Var1, Var2, Var3
#end

The text file Filename just has three comma separated variables:

0, 0, 0
0, 0, 0
0, 0, 0
-12, -18, 0

etc...

In the Camera Object I want to use those variables:

amera {
  location  <Var1, Var2, Var3>
  direction 1.5*z
  right     x*image_width/image_height
  look_at   <0.3, 0.3,  0.3>
}

The POV documentation says to use comma separated files, but now it looks as if
it is hanging in the second line in the text file and giving me that error.

Any thoughts??

audioguytodd



Leroy <lrw### [at] joplincom> wrote:
> audioguytodd wrote:
> > Could someone please post a small example of how to use an external Text file to
> > input variables in an animation??? I have Vectors (and other data) in a text
> > file that I would like to read for each frame. I have done this a long time
> > ago, but seem to have forgotten.
> >
> > Thank in advance,
> >
> > audioguytodd
> >
> >
> Your in luck I was just doing that the other day.
> (reading text files for my animated robots)
>   here's an example
>
> #declare RVal=0;
> #fopen Myfile "Action.txt" read
>   #while (defined(Myfile))
>    #read (Myfile Frame,Data)
>    #declare Frame_Count=Frame_Count+Frame;
>    #if ((Frame_Count>Frame_number)&(K=0))
>     // fix two frame data variables
>     #declare K=1;
>     #declare AtFrame1=Frame_Count-Frame; //first data frame
>     #declare First_Data=OldData;// first data
>     #declare Second_Data=Data;// second data frame
>     #declare AtFrame2=BTD; //second data
>    #end
>    #declare OldData=Data;
>    #declare RVal=RVal+1;//keep track of reads
>   #end
>
> You might not be in luck at that.
>   My data has in it the difference between each "pose's" frame.
>   It also reads all the data for every frame you render.
>   Well I hope this helps.


Post a reply to this message

From: StephenS
Subject: Re: How do you use an external Text file for animation values
Date: 27 Jan 2008 12:30:00
Message: <web.479cbe776e870b0faae505180@news.povray.org>
"audioguytodd" <aud### [at] bellsouthnet> wrote:
....
> The text file Filename just has three comma separated variables:
>
> 0, 0, 0
> 0, 0, 0
> 0, 0, 0
> -12, -18, 0
>
....
Your third and fourth variable is separated by a 'new line', not a comma.
Try:
0, 0, 0,
0, 0, 0,
0, 0, 0,
-12, -18, 0

StephenS


Post a reply to this message

From: audioguytodd
Subject: Re: How do you use an external Text file for animation values
Date: 27 Jan 2008 20:05:00
Message: <web.479d29fa6e870b0f230bdc7b0@news.povray.org>
Nope that's not it, but I see what you mean.

Is there any way to read each line in the text file then move on to the next
frame and read the next line?? Well, I know there is- I just can't remember it.

I want to read each comma separated variable as in the line. Right now, there
are three (a vector):

#fopen MyFile "c:\filename.txt" read
#while (defined(MyFile))
#read (MyFile, Var1, Var2, Var3 )
#end

I thought that is what I was doing above in line 3. Read File, Variable1, etc...

But it doesn't seem to work right.

BTW, I am using the Beta 3.7 (for the SMP which is very nice on my new
Core2Quad!)

audioguytodd



"StephenS" <nomail@nomail> wrote:
> "audioguytodd" <aud### [at] bellsouthnet> wrote:
> ....
> > The text file Filename just has three comma separated variables:
> >
> > 0, 0, 0
> > 0, 0, 0
> > 0, 0, 0
> > -12, -18, 0
> >
> ....
> Your third and fourth variable is separated by a 'new line', not a comma.
> Try:
> 0, 0, 0,
> 0, 0, 0,
> 0, 0, 0,
> -12, -18, 0
>
> StephenS


Post a reply to this message

From: Leroy
Subject: Re: How do you use an external Text file for animation values
Date: 27 Jan 2008 22:50:59
Message: <479D5074.9020503@joplin.com>
audioguytodd wrote:
> Nope that's not it, but I see what you mean.
> 
> Is there any way to read each line in the text file then move on to the next
> frame and read the next line?? Well, I know there is- I just can't remember it.
> 
> I want to read each comma separated variable as in the line. Right now, there
> are three (a vector):
> 
> #fopen MyFile "c:\filename.txt" read
> #while (defined(MyFile))
> #read (MyFile, Var1, Var2, Var3 )
> #end
> 
> I thought that is what I was doing above in line 3. Read File, Variable1, etc...
> 
> But it doesn't seem to work right.
> 
> BTW, I am using the Beta 3.7 (for the SMP which is very nice on my new
> Core2Quad!)
> 
> audioguytodd
> 

First, I'm using pov3.6, I don't know nothing about 3.7.

Your line:
  #read (MyFile, Var1, Var2, Var3 )
should read a LINE of data like you want if Var1,Var2,Var3 has been NOT 
been defined earlier as anything but a float or not defined at all.

To get the frame data you want you need to add a counter and stop 
reading when you got your data.
something like:
  #declare count=0;
  #while (defined(MyFile)&(count<=frame_number))
  #read (MyFile, Var1, Var2, Var3 )
  #declare count=count+1;
  #end
Now Var1,Var2,Var3 should have the frame data!

By the way POV will let you read vectors from a file in the form <0,0,0>.


Post a reply to this message

From: audioguytodd
Subject: Re: How do you use an external Text file for animation values
Date: 28 Jan 2008 00:15:00
Message: <web.479d641b6e870b0f230bdc7b0@news.povray.org>
Ah yes, now it is coming back to me.

My only question now is where does the read code go?? In the POV file or my
animation ini file?? I ask because I think When I did this long ago, it was in
an ini.
I know about the Vector thing- that is nice.

I will try it out tomorrow.

Thank You!!
audioguytodd

Leroy <lrw### [at] joplincom> wrote:
> audioguytodd wrote:
> > Nope that's not it, but I see what you mean.
> >
> > Is there any way to read each line in the text file then move on to the next
> > frame and read the next line?? Well, I know there is- I just can't remember it.
> >
> > I want to read each comma separated variable as in the line. Right now, there
> > are three (a vector):
> >
> > #fopen MyFile "c:\filename.txt" read
> > #while (defined(MyFile))
> > #read (MyFile, Var1, Var2, Var3 )
> > #end
> >
> > I thought that is what I was doing above in line 3. Read File, Variable1, etc...
> >
> > But it doesn't seem to work right.
> >
> > BTW, I am using the Beta 3.7 (for the SMP which is very nice on my new
> > Core2Quad!)
> >
> > audioguytodd
> >
>
> First, I'm using pov3.6, I don't know nothing about 3.7.
>
> Your line:
>   #read (MyFile, Var1, Var2, Var3 )
> should read a LINE of data like you want if Var1,Var2,Var3 has been NOT
> been defined earlier as anything but a float or not defined at all.
>
> To get the frame data you want you need to add a counter and stop
> reading when you got your data.
> something like:
>   #declare count=0;
>   #while (defined(MyFile)&(count<=frame_number))
>   #read (MyFile, Var1, Var2, Var3 )
>   #declare count=count+1;
>   #end
> Now Var1,Var2,Var3 should have the frame data!
>
> By the way POV will let you read vectors from a file in the form <0,0,0>.


Post a reply to this message

From: audioguytodd
Subject: Re: How do you use an external Text file for animation values
Date: 29 Jan 2008 17:30:00
Message: <web.479fa8986e870b0f230bdc7b0@news.povray.org>
Thanks, it works fine now. However, I could not use count as a variable for some
reason.Reseved keyword maybe??? Anyhow- this works. My variable in the text file
is <12,23,04>. Then it is read as a vector.

#fopen MyFile "c:\filename.txt" read
#declare countth =0;
  #while (defined(MyFile)&(countth<=frame_number))
  #read (MyFile, Var1, )
  #declare countth=countth+1;
  #end

audioguytodd

"audioguytodd" <aud### [at] bellsouthnet> wrote:
> Ah yes, now it is coming back to me.
>
> My only question now is where does the read code go?? In the POV file or my
> animation ini file?? I ask because I think When I did this long ago, it was in
> an ini.
> I know about the Vector thing- that is nice.
>
> I will try it out tomorrow.
>
> Thank You!!
> audioguytodd
>
> Leroy <lrw### [at] joplincom> wrote:
> > audioguytodd wrote:
> > > Nope that's not it, but I see what you mean.
> > >
> > > Is there any way to read each line in the text file then move on to the next
> > > frame and read the next line?? Well, I know there is- I just can't remember it.
> > >
> > > I want to read each comma separated variable as in the line. Right now, there
> > > are three (a vector):
> > >
> > > #fopen MyFile "c:\filename.txt" read
> > > #while (defined(MyFile))
> > > #read (MyFile, Var1, Var2, Var3 )
> > > #end
> > >
> > > I thought that is what I was doing above in line 3. Read File, Variable1, etc...
> > >
> > > But it doesn't seem to work right.
> > >
> > > BTW, I am using the Beta 3.7 (for the SMP which is very nice on my new
> > > Core2Quad!)
> > >
> > > audioguytodd
> > >
> >
> > First, I'm using pov3.6, I don't know nothing about 3.7.
> >
> > Your line:
> >   #read (MyFile, Var1, Var2, Var3 )
> > should read a LINE of data like you want if Var1,Var2,Var3 has been NOT
> > been defined earlier as anything but a float or not defined at all.
> >
> > To get the frame data you want you need to add a counter and stop
> > reading when you got your data.
> > something like:
> >   #declare count=0;
> >   #while (defined(MyFile)&(count<=frame_number))
> >   #read (MyFile, Var1, Var2, Var3 )
> >   #declare count=count+1;
> >   #end
> > Now Var1,Var2,Var3 should have the frame data!
> >
> > By the way POV will let you read vectors from a file in the form <0,0,0>.


Post a reply to this message

From: Leroy
Subject: Re: How do you use an external Text file for animation values
Date: 29 Jan 2008 23:36:05
Message: <479FFE02.9070906@joplin.com>
audioguytodd wrote:
> Thanks, it works fine now. However, I could not use count as a variable for some
> reason.Reseved keyword maybe??? Anyhow- this works. My variable in the text file
> is <12,23,04>. Then it is read as a vector.
> 
> #fopen MyFile "c:\filename.txt" read
> #declare countth =0;
>   #while (defined(MyFile)&(countth<=frame_number))
>   #read (MyFile, Var1, )
>   #declare countth=countth+1;
>   #end
> 
Cool! Hope hope you have fun animating.
Sorry for the 'count' word, I used it for clearity in the example.
I just didn't think. I usually use 'Cnt' as my base counter.


Post a reply to this message

From: audioguytodd
Subject: Re: How do you use an external Text file for animation values
Date: 30 Jan 2008 00:25:00
Message: <web.47a009ca6e870b0f230bdc7b0@news.povray.org>
Now that I have the loop-the real fun can begin!!
And for any other noobs out there (using the Windows version), if you are tying
to read or write from an external file- check out the Script I/O Restrictions
in the Documentation.

Thanks again,

audioguytodd

Leroy <lrw### [at] joplincom> wrote:
> audioguytodd wrote:
> > Thanks, it works fine now. However, I could not use count as a variable for some
> > reason.Reseved keyword maybe??? Anyhow- this works. My variable in the text file
> > is <12,23,04>. Then it is read as a vector.
> >
> > #fopen MyFile "c:\filename.txt" read
> > #declare countth =0;
> >   #while (defined(MyFile)&(countth<=frame_number))
> >   #read (MyFile, Var1, )
> >   #declare countth=countth+1;
> >   #end
> >
> Cool! Hope hope you have fun animating.
> Sorry for the 'count' word, I used it for clearity in the example.
> I just didn't think. I usually use 'Cnt' as my base counter.


Post a reply to this message

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