POV-Ray : Newsgroups : povray.advanced-users : DF3 density file generation for a generic 3D object ? : Re: DF3 density file generation for a generic 3D object ? Server Time
8 Jul 2024 19:51:47 EDT (-0400)
  Re: DF3 density file generation for a generic 3D object ?  
From: Antonio Ferrari
Date: 2 Oct 2007 08:15:00
Message: <web.47023516413da414e64f15d0@news.povray.org>
> There isn't a built in function for this, because there isn't a single
> answer
> to how far a minimal distance point is from the surface. You can use
> trace to collect a sample of distances from the surface in random
> directions to appoximate the minimal distance of a voxel from the
> surface.
>
> #include "rand.inc"
> #macro distToSurface(Obj, vec, samp, rsd)
>    #local dist = 1000000;
>    #local c=0;
>    #while (c<samp)
>       #local rdir = VRand_On_Sphere(rsd);
>       #declare Norm = <0, 0, 0>;
>       #local hit = trace(Obj, vec, rdir, Norm);
>       #if (vlength(Norm) != 0)
>          #local dist = min(dist, vlength(hit - vec));
>       #end
>       #local c=c+1;
>    #end
> #end
>

Hi Tim thank for this macro... It's very useful to me :)

>
> This can be done with macros I think, though it would be slow to
> calculate the distance data. You could calculate your three dimensional
> array of distances on the first frame, scale the data, then write it to file
> to reload for the remaining frames.  A slice of voxels could then be
> generated from the data with the greyscale voxel colors determined
> from the array data.
>

This just what I'd like. I have only to see if there is the possibility to
write a macro for isolating the more external points, the points nearest to
the surface. Let's call A1 the set of these points. These points have
density=my_func(1). Let's remove A1 point from our array. Let's find the
external points of the new array and call them A2. These points have
density=my_func(2). And so on for other distances.

> >
> > Oh these are just ideas. I don't know if I'm on the right way.
>
> This might work for simple objects, but will fail for complex objects.
> Think of a hollow pipe A, if you scale it smaller then the new smaller
> pipe B fits into the void of the first pipe A; the interior of A doesn't
> share any points with the interior of B.

I have to study better these cases...

Bye.


Post a reply to this message

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