POV-Ray : Newsgroups : povray.advanced-users : Has anyone ever tried using the trace function to generate a mesh2 from an = Server Time
1 Nov 2024 05:21:15 EDT (-0400)
  Has anyone ever tried using the trace function to generate a mesh2 from an = (Message 1 to 3 of 3)  
From: normdoering
Subject: Has anyone ever tried using the trace function to generate a mesh2 from an =
Date: 7 Nov 2002 21:20:05
Message: <web.3dcb1ef370d1548f7748f6790@news.povray.org>
Has anyone ever tried to use the trace function in a macro to generate a
mesh2 file from an isosurface?

If so, is there pov scene code I can look at?

normdoering


Post a reply to this message

From: Ken
Subject: Re: Has anyone ever tried using the trace function to generate a mesh2 from an =
Date: 7 Nov 2002 22:58:48
Message: <3DCB366A.3E63E017@pacbell.net>
normdoering wrote:
> 
> Has anyone ever tried to use the trace function in a macro to generate a
> mesh2 file from an isosurface?
> 
> If so, is there pov scene code I can look at?

The closest thing that I am aware of is the triscan macro which was
written for Megapov using the trace function and generates regular
meshes. I don't know if it worked with isosurfaces or if it will
even work with POV-Ray v3.5. You can take a look anyway and see
if it will give you some ideas -

http://www.silvertome.com/packages.html

-- 
Ken Tyler


Post a reply to this message

From: Mike Williams
Subject: Re: Has anyone ever tried using the trace function to generate a mesh2 from an =
Date: 8 Nov 2002 04:15:31
Message: <DsOXkCA4$3y9EwO3@econym.demon.co.uk>
Wasn't it normdoering who wrote:
>Has anyone ever tried to use the trace function in a macro to generate a
>mesh2 file from an isosurface?

Ingo Janssen has created param.inc that can make a mesh2 from a
parametric isosurface, but it does it by evaluating the functions
directly, rather than by using trace.

I think that his twovar.inc does the same thing for isosurfaces that are
a function of only two variables.

Ingo's macros are at: <http://members.home.nl/seedseven/>
My example of using param.inc is at 
                      <http://www.econym.demon.co.uk/isotut/param.htm>

If the isosurface that you want to meshify can't be manipulated into
either of these two formats, then things become rather trickier. I
strongly suspect that it wouldn't be possible to produce an algorithm
that could meshify all possible isosurfaces using trace. You may have to
use code that depends on prior knowledge of certain properties of the
particular surface you are trying to meshify. For example, if you happen
to know that the entire isosurface can be directly observed from a
single location or direction, then you can trace the surface by emitting
trace rays from there, but if your surface is highly convoluted, then
it's tricky to decide where to start the trace rays.

Since you were talking about height_fields in your other postings,
here's some code that takes a height_field-like isosurface and meshifies
it. With this particular isosurface, I happen to know that I can trace
vertically downwards (-y) from a point high above the surface
(<X,100,Y>) and can represent the surface by a square XY grid. The mesh
is green and the original isosurface red in this rendering.


#include "functions.inc"
global_settings {assumed_gamma 1.0}
camera { location  <2, 3, -6> look_at <0, 0, 0>}
light_source {<-100,200,-100> colour rgb 1}


// Declare the isosurface
#declare S=
isosurface {
  function { y-f_noise3d(x,0,z) }
        max_gradient 1.4
        contained_by{box {<-4.01,-1,-4.01><4.01,1,4.01>}}
        open
        pigment {rgb x}
}

// Render the isosurface
object {S}




#declare Divs=40; // Number of subdivisions
// obtain arrays of points and normals on the surface
#declare A=array[Divs][Divs]
#declare N=array[Divs][Divs]
#declare Norm=<0,0,0>;

#declare i=0;
#while (i<Divs)
  #declare j=0;
  #while (j<Divs)
  
    #declare X=-4+i*8/(Divs-1);
    #declare Z=-4+j*8/(Divs-1);
    
    #declare A[i][j]=trace(S, <X,100,Z>, -y , Norm);
    #declare N[i][j]=Norm;
    
    #declare j=j+1;
  #end
  #declare i=i+1;
#end


// create the mesh2
#declare M = mesh2 {
  vertex_vectors {Divs*Divs
    #declare i=0; #while (i<Divs) #declare j=0; #while (j<Divs)    
      ,A[i][j]
    #declare j=j+1;#end #declare i=i+1;#end
  }
  
  normal_vectors {Divs*Divs
    #declare i=0; #while (i<Divs) #declare j=0; #while (j<Divs)    
      ,N[i][j]
    #declare j=j+1;#end #declare i=i+1;#end
  }
  
  face_indices {(Divs-1)*(Divs-1)*2
    #declare i=0; #while (i<Divs-1) #declare j=0; #while (j<Divs-1)    
      #declare k=i+j*Divs;
      ,<k,k+1,k+Divs>, <k+1,k+1+Divs,k+Divs>
    #declare j=j+1;#end #declare i=i+1;#end
  }
  pigment {rgb y}
  no_shadow
}  


//render the mesh
object {M translate y}


Post a reply to this message

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