POV-Ray : Newsgroups : povray.general : Calculating / read from file vertices in mesh2 instead of typing them in? : Re: Calculating / read from file vertices in mesh2 instead of typing them in? Server Time
29 Apr 2024 00:30:36 EDT (-0400)
  Re: Calculating / read from file vertices in mesh2 instead of typing them in?  
From: clipka
Date: 29 Aug 2016 08:05:01
Message: <57c424ed$1@news.povray.org>
Am 29.08.2016 um 13:20 schrieb defferl:
> Hi there,
> 
> I have to visualize 3d data as some kind of surface. "height_field" often does
> the job, especially the combination with the "function" keyword is superb.
> 
> However, right now I ran into a problem where "function" does not work anymore,
> since the surface looks like a tea-pot (i.e. vertices are distributed more or
> less freely in space, distances between x- and z-values are not constant and
> there may be several y-values for any x/z-combination.
> 
> Instead of typing in hundreds of vertices (mistakes, time, ...) I thought of
> either
> a) calculating them within the .pov file, or
> b) calculate them outside, export results into a file and have povray read the
> file.
> 
> I already finished both, but still I have to use something like
> vertex_vectors
> {
>   4,
>   <vx[0][0],vy[0][0],vz[0][0]>, <vx[1][0],vy[1][0],vz[1][0]>,
>   <vx[0][1],vy[0][1],vz[0][1]>, <vx[1][1],vy[1][1],vz[1][1]>,
> }
> to get the pre-calcualted data into the mesh2 command. As I have hundreds of
> vertices, this is still some awful work!
> 
> Is there no way to use #for loops or something else to "fill" the mesh2 with
> data directly?

Why, yes, of course there is a way. There always is. But it all depends
on the format your data originally comes in.

For instance, you could rewrite the above as:

    vertex_vectors {
      4,
      #for(U,0,1)
        #for(V,0,1)
          <vx[U][V],vy[U][V],vz[U][V]>,
        #end
      #end
    }

though I would normally recommend generating the data as a single array
of vectors, rather than three arrays of scalars, so that you could
simply write:

    vertex_vectors {
      4,
      #for(U,0,1)
        #for(V,0,1)
          v[U][V],
        #end
      #end
    }

Maybe this is sufficient to give you an idea or two; if not, let us know
a few more details.


Post a reply to this message

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