|
|
"John Greenwood" <joh### [at] john-greenwoodcouk> wrote:
> "Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> > "John Greenwood" <joh### [at] john-greenwoodcouk> wrote:
>
> >> can my function, which is a single closed surface, be turned into mesh?
> >
> > Perhaps you can find something useful in this thread:
> >
> > Subject: Isosurface Approximation macros rewrite
> > From: Tor Olav Kristensen
> > Date: 2008 February 22nd
> > Message: <47be20ab@news.povray.org>
> > Newsgroup: povray.binaries.scene-files
> >
> >
http://news.povray.org/povray.binaries.scene-files/thread/%3C47cc76fd@news.povray.org%3E/
> >
> > --
> > Tor Olav
> > http://subcube.com
>
> I have had a look and am floundering.
>
> An example would be worth ten thousand words.
See the code below.
> Could some kind person point me at an actual example of converting a simple
> function, such as:
> function(x,y,z){sqrt(pow(x,2)+pow(y,2)+pow(z,2))-L)/r }
> into a mesh object?
That function seemsto be missing a start parenthesis somewhere.
The code below uses a similar function.
Noe that this code also creates a file named triangles.inc that contains all the
triangles.
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8
#include "functions.inc"
// Other functions to experiment with
//#declare Fn = function { f_torus(x, y, z, 1, 0.4) }
//#declare Fn = function { y - sin(2*x*z)*cos(x*z) }
//#declare Fn = function { cos(2*pi*x) + cos(2*pi*y) + cos(2*pi*z) }
// A sphere with radius 1.8
// x^2 + y^2 + z^2 = 1.8^2
// (x^2 + y^2 + z^2)^(1/2) = 1.8
// (x^2 + y^2 + z^2)^(1/2) - 1.8 = 0.0
// The elaborate way
//#declare Fn = function(x, y, z) { sqrt(pow(x,2) + pow(y,2) + pow(z,2)) - 1.8 }
// A simpler way
#declare Fn = function { f_sphere(x, y, z, 1.8) }
#declare isoThreshold = 0.0;
// Set to yes to produce the approximation
// or to no for the actual isosurface
#declare approximateIso = yes;
// Set to yes to produce a smooth_triangle approximation
// or to no ro produce a flat triangle approximation
#declare isoSmooth = no;
// Controls the size of the cube that is beeing sampled
#declare R = 2.0;
#declare isoMin = -<1, 1, 1>*R;
#declare isoMax = +<1, 1, 1>*R;
// The resolution of the sampling in the x, y and z directions
#declare Resolution = 6;
#if (approximateIso)
#declare Depth = 1; // Set to 0 for no recursion
#declare isoSegs = <1, 1, 1>*Resolution;
#declare isoFileOption = 1;
#declare isoFile = "triangles.inc";
#declare isoName = "Surface";
#include "isosurface_kl_jf_tok.inc"
object {
Surface
pigment { color rgb <1, 1, 1>*0.9 }
finish {
phong 0.5
phong_size 10
}
}
#else
isosurface {
function { Fn(x, y, z) }
max_gradient 8.0
contained_by { box { isoMin, isoMax } }
open
pigment { color rgb <1, 1, 1>*0.9 }
finish {
phong 0.5
phong_size 10
}
}
#end // if
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8
sky_sphere {
pigment {
function { abs(y) }
color_map {
[ 0.0 color rgb <0.0, 0.0, 0.6> ]
[ 1.0 color rgb <1.0, 1.0, 1.0> ]
}
}
}
camera {
location <1, 2, -4>*2*R
look_at <0, 0, 0>
angle 32
}
light_source {
<1, 2, -1>*100
color rgb <1, 1, 1>
shadowless
}
light_source {
<-1, -2, -1>*100
color rgb <1, 1, 1>*0.5
shadowless
}
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8
--
Tor Olav
http://subcube.com
Post a reply to this message
|
|