POV-Ray : Newsgroups : povray.general : Calculating / read from file vertices in mesh2 instead of typing them in? Server Time
29 Mar 2024 07:23:56 EDT (-0400)
  Calculating / read from file vertices in mesh2 instead of typing them in? (Message 1 to 4 of 4)  
From: defferl
Subject: Calculating / read from file vertices in mesh2 instead of typing them in?
Date: 29 Aug 2016 07:25:00
Message: <web.57c41a653a03ee8e966b8c530@news.povray.org>
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?

Best,
Guenther


Post a reply to this message

From: clipka
Subject: Re: Calculating / read from file vertices in mesh2 instead of typing them in?
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

From: Bald Eagle
Subject: Re: Calculating / read from file vertices in mesh2 instead of typing them i=
Date: 29 Aug 2016 08:20:01
Message: <web.57c427b1ef5390f8b488d9aa0@news.povray.org>
"defferl" <gro### [at] gmailcom> wrote:
> Hi there,
>
> I have to visualize 3d data as some kind of surface.

If the data isn't structured, then maybe just plot a sphere at every vertex -
adjust the radius until they overlap and form a "surface".

Likely though, your data is already just a mesh definition.
(probably the famous "Utah teapot" : https://en.wikipedia.org/wiki/Utah_teapot )

You could probably just edit your file and save it as an .inc file, and render
the mesh directly,

> Is there no way to use #for loops or something else to "fill" the mesh2 with
> data directly?

or read the vertices in 3 at a time and use an array to store them,

or just make triangles in a mesh{} inside of your #read loop.
Look up #read and other file comands in the docs and how to use a while() loop
to read until EOF.

http://news.povray.org/povray.newusers/thread/%3Cweb.56cef0b1bc80f3839e6517f30@news.povray.org%3E/?mtop=406315&moff=1

http://news.povray.org/povray.binaries.scene-files/thread/%3Cweb.56d702f78f8162b55e7df57c0@news.povray.org%3E/


Post a reply to this message

From: defferl
Subject: Re: Calculating / read from file vertices in mesh2 instead of typing them i=
Date: 29 Aug 2016 09:10:01
Message: <web.57c43361ef5390f8966b8c530@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> 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.

Thanks very much! I was looking for the first way, but your second suggestion is
too elegant not to use it (I can't help, it somehow reminds me of Python)! It's
already implemented and works like a charm.

Bald Eagle: Thanks too! It's actually not the original tea pot, just similar in
general shape. And yes, data already comes in mesh2-format, I just did not know
that there is such an easy way to fill it into the mesh2.

And of course thanks for all the "side-ideas" - if they don't solve the problem,
they usually are an inspiration for further work :)


Post a reply to this message

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