POV-Ray : Newsgroups : povray.animations : build animation from dynamic solver results Server Time
18 Jun 2024 08:25:20 EDT (-0400)
  build animation from dynamic solver results (Message 1 to 3 of 3)  
From: Javier Gil
Subject: build animation from dynamic solver results
Date: 16 Dec 2003 16:00:03
Message: <web.3fdf7088f7b6d10056dfb22b0@news.povray.org>
Hi all :

I am making a bit of research on multibody dynamics. I have developed
something like a solver from which I could obtain a results file. I could
format my results in a proper way, let us say :

time1, position_vector_1, rotation_vector_1, position_vector_2, ...,
time2, position_vector_1, rotation_vector_1, position_vector_2, ...,
time2, position_vector_1, rotation_vector_1, position_vector_2, ...,

if I had a two-body simulation.


At first I tried to read in the results file via #read statement, but
I have problems to manage the clock variable.

I had prepared a simple test, but I can not make it run as I wanted

%%%%%%%%%%%%%
%%test1.ini%%
%%%%%%%%%%%%%
[Low]
+W80 +H60    ; This section has a label.

Initial_Frame = 1
Final_Frame = 10

Initial_Clock = 0.0
Final_Clock = 1.0

Input_File_Name=test1.pov
               ; Select it with "RES[Low]"
%%%%%%%%%%%%%%%%%
%%end test1.ini%%
%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%
%%test1.pov%%
%%%%%%%%%%%%%
#macro test1(Var1,Var2,Var3)
#include "colors.inc"
  camera {
    location <0, 3, -6>
    look_at <0, 0, 0>
  }
  light_source { <20, 20, -20> color White }
  plane {
    y, 0
    pigment { checker color White color Black }
  }
  sphere {
    <0, 0, 0> , 1
    pigment {
      gradient x
      color_map {
        [0.0 Blue  ]
        [0.5 Blue  ]
        [0.5 White ]
        [1.0 White ]
      }
      scale .25
    }
    rotate <0, 0, -Var1*360>
    translate <-pi, 1, Var2>
    translate <2*pi*Var3, 0, 0>
  }
#end

#fopen mydebug "out.txt" write
#fopen MyFile "mydata.txt" read

#declare AuxV1=0;
#declare AuxV2=0;
#declare AuxV3=0;

#if ( clock <= 1 )


     #if ( defined(MyFile) )

        #read (MyFile,Var1,Var2,Var3)
        #declare AuxV1=Var1;
        #declare AuxV2=Var2;
        #declare AuxV3=Var3;

     #end


  #write(mydebug, "Value is:",clock,",",AuxV1,",",AuxV2,",",AuxV3,"\n")

  test1(AuxV1,AuxV2,AuxV3)

#end

%%%%%%%%%%%%%%%%%
%%end test1.pov%%
%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%
%% mydata.txt  %%
%%%%%%%%%%%%%%%%%

0.1,0.1,0.1,
0.2,0.2,0.2,
0.3,0.3,0.3,
0.4,0.4,0.4,
0.5,0.5,0.5,
0.6,0.6,0.6,
0.7,0.7,0.7,
0.8,0.8,0.8,
0.9,0.9,0.9,
1,1,1,

%%%%%%%%%%%%%%%%%%%
%%end mydata.txt %%
%%%%%%%%%%%%%%%%%%%

After running >>povray test1[Low], I obtain the following out.txt file

%%%%%%%%%%%%%%%%%
%%   out.txt   %%
%%%%%%%%%%%%%%%%%

Value is:1,0.1,0.1,0.1

%%%%%%%%%%%%%%%%%
%% end out.txt %%
%%%%%%%%%%%%%%%%%

I spected the program to cycle through all 'mydata.txt' rows taking the
position parameters one at a time in order to build the corresponding
slide, but is not. The program takes the first slide and cycle the clock
without entering #read statement instead.

Any idea (or povray macro) to make it run ?

Thanks in advance.


Post a reply to this message

From: Warp
Subject: Re: build animation from dynamic solver results
Date: 16 Dec 2003 17:30:22
Message: <3fdf877e@news.povray.org>
Each frame of the animation is parsed in the exact same way is if
you were rendering a still (with 'clock' set to the correspondent value).

  This means that for each frame the file will be opened and read from
the beginning.

  There's no other workaround than to "read away" the data at the beginning
of the file in subsecuent frames.
  That is, in the first frame, read the first line of data and create the
scene with it. In the second frame read the first line, forget it, read
the second line and create the scene with it. In the third frame you'll
need to read the first two lines, forget them, and then read the third
line. And so on. A simple loop should do it.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Javier Gil
Subject: Re: build animation from dynamic solver results
Date: 17 Dec 2003 10:20:01
Message: <web.3fe0733298a8084056dfb22b0@news.povray.org>
You are wright !

I have replaced the contents of the time loop as follows :

%%%%%%%%%%%%%%%%%%%%%

#declare counter=0;
#declare AuxV1=0;
#declare AuxV2=0;
#declare AuxV3=0;

#if ( clock <= 1 )

     #declare counter = 10*clock;

     #declare Count=0;

     #fopen MyFile "mydata.txt" read

     #while (Count < counter)

       #if ( defined(MyFile) )

          #read (MyFile,Var1,Var2,Var3)
          #declare AuxV1=Var1;
          #declare AuxV2=Var2;
          #declare AuxV3=Var3;

       #end

       #declare Count=Count+1;

     #end

     #fclose MyFile

     test1(AuxV1,AuxV2,AuxV3)

#end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

an it works as I spected.

Thank you for your advice. This way I can represent my simulations properly.


Post a reply to this message

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