POV-Ray : Newsgroups : povray.animations : build animation from dynamic solver results : build animation from dynamic solver results Server Time
27 Sep 2024 18:11:35 EDT (-0400)
  build animation from dynamic solver results  
From: Javier Gil
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

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