[Fluxus] nurbs explode FAIL

evan.raskob [lists] lists at lowfrequency.org
Mon Jan 25 10:07:49 PST 2010


hey gang

I'm trying to mess with a nurbs sphere and (eventually) distort it  
using a list of values.

right now, I'm failing.... got it to work with a regular sphere  
primitive, but that's a completely different beast... can someone  
please help?  bad code below:

;--------

(clear)


(hint-frustum-cull)
;(hint-none)
;(wire-colour #(0 1 0))
(hint-wire)


(define dims 10)

(define shape
     (with-state
         (build-nurbs-sphere dims dims)
         )
     )

(with-primitive shape
     (pdata-add "n0" "v")
     (pdata-copy "n" "n0")
     )

(define r 1)


(define vals (build-list dims (lambda (n) (vmul (rndvec) 0.003))))

(define (bump p)

     (for [(c (in-range 1 8))]
         (set! r (+ 1 (remainder r dims)))

         (with-primitive p
             (let [(faces (/ (pdata-size) 4))]
                 ;            (printf "faces: ~s\n" faces)
                 (pdata-index-map! (lambda (i p n)
                         (let* [(face (quotient i 4))
                                 (row (quotient face dims))
                                 (col (remainder face dims))
                                 (rv (list-ref vals col))]
                             ;(printf "row: ~a\n" row)
                             (cond [(= face 4)

                                     (vadd  p
                                         (vector
                                             (* (vx rv) (vx n))
                                             (* (vy rv) (vy n))
                                             (* (vz rv) (vz n))
                                             )
                                         )

                                     ]
                                 [else p])
                             )
                         )
                     "p" "n0")
                 )
             (recalc-normals 0)
             )
         )
     )

(every-frame (bump shape))








More information about the Fluxus mailing list