Meshed feedback

Still distracted, tried using the new (voxels->blobby) command to use the marching cubes algo in fluxus to mesh the feedback into a solid shape. The code is posted below.

(clear)

; make some voxels
(define vx (build-voxels 50 50 50))

; do the feedback
(for ((i (in-range 0 40))) 
     (with-primitive vx ; not sure what's happening here
      (voxels-sphere-influence (vector 0 0 0) (vector 1 1 1) 0.2)                
      (voxels-calc-gradient) ; <- probably repeated application of this...
      (voxels-point-light (vector 0 0 0) (vmul (vector 1 1 1) 0.5)))) ; <- and then this does the trick

; make a blobby from the resulting voxels
(define bb (voxels->blobby vx))
(destroy vx) ; dont need the voxels anymore

; convert to polygons
(define pb (with-state
    (scale 5)
    (blobby->poly bb)))

(destroy bb) ; don't need the blobby any more

; calculate normals and make shiny
(with-primitive pb 
    (recalc-normals 1)
    (shinyness 50)
    (specular (vector 1 1 1)))

; slap on some lights
(light-diffuse 0 (vector 0.1 0.1 0.1))
(light-specular 0 (vector 0 0 0))
(let ((l (make-light 'point 'free)))
    (light-diffuse l (vector 1 1 1))
    (light-position l (vector 0 30 10))
    (light-specular l (vector 1 1 1)))

(let ((l (make-light 'point 'free)))
    (light-diffuse l (vector 0 0 0.6))
    (light-position l (vector 0 -50 50))
    (light-specular l (vector 0 1 1)))

(clear-colour 0.5)

Leave a Reply

Your email address will not be published. Required fields are marked *