[Fluxus] voxels and blobby commits

evan.raskob [lists] lists at lowfrequency.org
Tue Feb 2 04:15:04 PST 2010


This is great but when do we get the holy grail of poly->voxels?? :)




On Feb 2, 2010, at 10:04 AM, Dave Griffiths wrote:

> Hi all,
>
> I've added a (voxel->blobby) command to so we can use the marching  
> cubes
> meshing algorithm to create polygon solids from voxels. I've also
> updated the documentation a little for the voxels.
>
> I also stumbled across some strange new effects:
> http://www.pawfal.org/dave/blog/category/accidental-art/
>
> Here is a script for converting polygons into voxels - thus completing
> the circle:
>
> (clear)
> (clear-colour 0.5)
>
> ; load the polygon object
> (define poly (with-state
>    (scale 2) ; make it fit nicely within the voxels area
>    (load-primitive "bot.obj")))
>
> ; apply the fitting transform
> (with-primitive poly (apply-transform))
>
> ; make some voxels
> (define v
>    (with-state
>        (blend-mode 'src-alpha 'one)
>        (hint-nozwrite)
>        (texture (load-texture "splat.png"))
>        ; move around the polygon object
>        (scale 8)
>        (translate (vector -0.5 -0.5 -0.5))
>        (build-voxels 50 50 50)))
>
> ; utils - need to put these somewhere else
> (define (voxels-index x y z)
>    (+ x (* y (voxels-width)) (* z (voxels-width) (voxels-height))))
>
> (define (voxels-pos i)
>    (vdiv (vector (modulo i (voxels-width))
>            (modulo (quotient i (voxels-width)) (voxels-height))
>            (quotient i (* (voxels-width) (voxels-height)))) (voxels- 
> width)))
>
> ; for each voxel, check for odd or even intersection counts against  
> the poly
> (with-primitive v
>  (pdata-index-map!
>     (lambda (i c)
>          (let ((p (vtransform (voxels-pos i) (get-transform))))
>              (if (odd? (length (with-primitive poly (geo/line- 
> intersect (vector 0 1 -1000) p))))
>                    (vector 1 1 1 1) ; inside
>                    (vector 0 0 0 0)))) ; outside
>        "c")
>    ; the rest of this is to make it look pretty for previewing
>    (voxels-calc-gradient)
>    (pdata-copy "g" "c")
>    (pdata-map!
>        (lambda (c)
>            (if (< (vmag c) 0.1)
>                (vector 0 0 0 0) c))
>        "c"))
>
> (destroy poly)
>
> ; convert to a blobby
> (define bp
>    (with-state
>        (hint-unlit) ; again all this
>        (colour 1)   ; just for
>        (hint-wire)  ; preview rendering
>        (voxels->blobby v)))
> (destroy v)
>
> (define pp (blobby->poly bp))
> (destroy bp)
>
> (with-primitive pp
>    (recalc-normals 1))
>
>
>




More information about the Fluxus mailing list