[Fluxus] pdata size behavior

Dave Griffiths dave at pawfal.org
Tue May 25 02:17:23 PDT 2010


btw - I didn't check that script for non-square dimensions, so probably
some w's and h's will need flipping.

cheers,

dave

On Tue, 2010-05-25 at 12:13 +0300, Dave Griffiths wrote:
> Hi Glauber,
> 
> This is due to the fact that (build-seg-plane) returns a primitive which
> is an un-indexed quad list - the vertices are not shared between the
> faces.
> 
> The best way to deal with this is to make an indexed polygon object
> yourself with build-polygons, and stitch the vertices together with the
> index - for example:
> 
> (define (build-mesh-plane w h)
>     (let ((p (build-polygons (* w h) 'quad-list)))
>         (with-primitive p
>             (pdata-index-map!
>                 (lambda (i p)
>                     (vector (modulo i w) (quotient i w) 0))
>                 "p")            
>             (poly-set-index     
>                 (build-list
>                     (* (- w 1) (- h 1) 4)
>                     (lambda (i)
>                         (let ((f (+ (quotient i (* 4 (- w 1))) (quotient i 4))))
>                             (list-ref (list f (+ f 1) (+ f w 1) (+ f w))
>                                 (modulo i 4))))))
>             (recalc-normals 1)) p))
> 
> 
> (clear)
> (hint-wire)
> (wire-colour 0)
> (define p (build-mesh-plane 10 10))
> 
> (with-primitive p
>     (pdata-map!
>         (lambda (p)
>             (vadd p (vmul (srndvec) 0.2)))
>         "p")            
>         (recalc-normals 1))
> 
> On Mon, 2010-05-24 at 19:41 -0300, Glauber Alex Dias Prado wrote:
> > Hey ppl,
> > 
> > I was figuring out how to make a kohonen map
> > <http://en.wikipedia.org/wiki/Kohonen_map> using pdata to represent my
> > err data, but this is a bit tricky as there are much more pdata than
> > vertices, and preferably i would like a one-to-one mapping:
> > 
> > (clear)
> > (hint-none)
> > (hint-wire)
> > (point-width 4)
> > (hint-points)
> > ;(translate (vector 0 0 9))
> > 
> > (define grid
> >     (build-seg-plane 10 10))
> > 
> > above is just the grid which i would like to manipulate as if it were a
> > matrix of vertices, but:
> > 
> > (with-primitive grid
> > 	(pdata-size))
> > returns 400
> > 
> > and i would like something like 100 at least for vertex position
> > manipulation, so is those 400 related to all (t p n c) pdatas and there
> > are only 100 for "p"?
> > 
> > I guess not, so i might be using the wrong primitive type for this
> > maybe?
> > 
> > does someone know what kind of primitive i could have a
> > one-vertex-per-pdata representation? 
> 
> 





More information about the Fluxus mailing list