POV-Ray : Newsgroups : povray.unofficial.patches : Trouble with MechSim fields : Re: Trouble with MechSim fields Server Time
18 Jun 2024 08:06:06 EDT (-0400)
  Re: Trouble with MechSim fields  
From: ssssmemyself
Date: 20 Aug 2004 13:25:00
Message: <web.4126339698395bf215c1769c0@news.povray.org>
"ssssmemyself" <sss### [at] hotmailcom> wrote:
> Christoph Hormann <chr### [at] gmxde> wrote:
> >
> > You have some basic misunderstanding of how use of #if in functions work
> > - you can not do render time conditionals this way - use select() for this.
> >
> > --
> > Christoph Hormann
> > http://www.tu-bs.de/~y0013390/
>
> Whoops! I guess the #if command works more like C precompilers then. Makes
> sense, seeing how it starts with a #.

Well, I'm having more trouble with select() now. Here's the listing for
test.pov

#version unofficial megapov 1.0;
#include "mechsim.inc"
global_settings{
  mechsim{
    method 1
    field{
      Vector_Function(
        function{select(y,-100,100)}//should move top mass +x, bottom one -x
        function{0}
        function{0}
      )
    }
    #if(frame_number>1)
      step_count 500
      time_step (1/30)/500
      topology{
        load_file "test.dat"
        save_file "test.dat"
      }
    #else
      step_count 0
      topology{
        mass{<0,5,0>,<0,0,0>,.5 mass 1}
        mass{<0,-5,0>,<0,0,0>,.5 mass 1}
        save_file "test.dat"
      }
    #end
  }
}
#debug "==========n"
#debug vstr(3,mechsim:mass(0):position,", ",0,3)
#debug "n"
#debug vstr(3,mechsim:mass(1):position,", ",0,3)
#debug "n==========n"
camera{location<0,0,-20>look_at<0,0,0>}
light_source{<0,0,-20>color rgb 1}
object{MechSim_Show_All_Objects(-1, false, -1, "")}
sky_sphere{pigment{color rgb<0.4,0.4,0.4>}}

As you can see, the field has a select statement that applies a force of
-100 or 100 in the x direction, depending on the sign of y. To quote the
POV-Ray documentation on select(A, B, C[, D])

"if A < 0 it will return B, else C (A >= 0)."

So, one would assume that the mass at <0,5,0> would move to to the right
because of the field and the mass at <0,-5,0> would move left. According to
the #debug statements and the images produced, both of the masses move

what do I have a basic misunderstanding of this time?


Post a reply to this message

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