POV-Ray : Newsgroups : povray.advanced-users : Trying to write new HF_ macros, how to cut the mesh? : Re: Trying to write new HF_ macros, how to cut the mesh? Server Time
29 Jul 2024 06:26:47 EDT (-0400)
  Re: Trying to write new HF_ macros, how to cut the mesh?  
From: normdoering
Date: 10 Nov 2002 17:30:07
Message: <web.3dcedcb46f4966181dffbb4f0@news.povray.org>
Christopher James Huff wrote:
>In article <web.3dcdf5256f496618178f7f9c0[at]news.povray.org>,
> "normdoering" <nor### [at] yahoocom> wrote:
>
>> That'a okay. Outputting different formats isn't that big a deal. You just
>> need a understanding of the format.
>
>Well, it just calculated the undisplaced positions of each point,
>calculated the displacement for those points, and then wrote a triangle
>with those points. Not well optimized at all, but not limited to a
>rectangular sheet.

Still, I'm looking for better starter material to work from. My macros will
probably be complex so I'm looking for more complexable tools. For example,
Ingo Janssen wrote "makemesh.inc" It has the macros and functions for
builing mesh2 objects. It looks like I'll be able to use that one rather
than the one in shapes.inc.

http://members.home.nl/seedseven/makemesh.html

His  BuildWriteMesh2() macro has options to write Wavefront *.obj files,
*.pcm files, for Chris Colefax' Compressed Mesh Macros, and *.arr files,
which writes only the arrays to a file. This last one is a great advantage
as it's the best mode for reading arrays back later for further mesh
manipulations. Another advantage, the array used by BuildWriteMesh2()
looks, at my first glance here, to be one dimensional, not thought of as a
rectangular grid.

Janssen's macro is called this way:

#include "makemesh.inc"

      BuildWriteMesh2
      ( VecArr,     //  The array that contains the vertices of the mesh.
        NormArr,    //   normal vectors that go with the vertices.
        UVArr,      //   uv_vectors
        U,          //   # of subdivisions of the surface in the
u-direction.
        V,          //   # of subdivisions in the v-direction.
        FileName    //  file, "" or .obj or .pcm or .arr that's written to.
     )

>BTW, just leaving out triangles will produce ragged edges, you will
>probably need to smooth that out somehow, which would probably be
>easiest if you had an array of vertices and another of validity flags.

Valadity flags?

Right now I'm not even sure how this bit of code works:

 #while (J<xRes+1+Smooth)
 #local K = 1-Smooth;
    #while (K<zRes+1+Smooth)

         #local UV = <(J-1)/(xRes-1),0,(K-1)/(zRes-1)>;

         #local P  = (UV*Ext*<1,0,1> + MnExt);

         #if (UVheight)
            #local H = Function(UV.x, UV.z, 0);
         #else
            #local H = Function(P.x, P.y, P.z);
// -----------------------------------------------------------------
// What kind of data is the Function that reads the picture data here
// assigning to H? Does the picture reading function read a 2D array
// of data and assign a 3D point to H or just the height value?
//
// I've only used these picture reading functions in isosurfaces and
// never learned to use them in a pixel by pixel read.
// ------------------------------------------------------------------

         #end

         #declare PArr[J][K] = P + H*Ext*y;

         #declare K = K+1;
      #end
      #declare J = J+1;
   #end

   HFCreate_()
#end
>
>> The what? I never saw any early versions (yet) so I don't know what you're
>> talking about. I only found out the HF_ macros existed a day or so ago when
>> you guys told me they were there.
>
>It was a version of the spherical height field that didn't use a
>rectangular sheet wrapped around the sphere. When you do that, the top
>and bottom get pinched together at the poles, wasting triangles and
>potentially causing visible artifacts. An alternative method is to
>repeatedly subdivide a polyhedron, usually a tetrahedron or octahedron.
>Each level of subdivision increases the number of triangles by 4, so you
>don't get as tight control of the resolution, but the triangles are all
>more or less of equal size and equally spread out, and without the
>obvious patterns leadinging towards the poles. Looks like it disappeared
>when the macros were updated for mesh2.

Hmmm, right now what I want is to is learn how the picture reading function
works in a pixel by pixel loop and then create a one dimensional array of
vertices, what BuildWriteMesh2() seems to use.

--normdoering


Post a reply to this message

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