[Fluxus] 'polygon

Dave Griffiths dave at pawfal.org
Wed Mar 3 05:44:41 PST 2010


On Tue, 2010-03-02 at 15:45 -0500, Neil Funk wrote:
> > It's time consuming though -
> > I made a script to display the vertex indices of a polygon
> > object to make it easier.
> 
> Wait - we've got Scheme as the underlying tool here, so couldn't we
> make a macro to encapsulate this otherwise-tedious task of connecting
> wireframes with ribbons?

If your thinking what I think your thinking - it's not that simple, as
you don't want to show all the edges - or at you don't if we're talking
about what I think we're talking about :)

Take for instance this shape:

http://www.flickr.com/photos/dave-griffiths/4404021664/

The L faces can't be single polygons as they are concave, so they are
built out of triangles. The white wireframe are from (hint-wire), the
black wireframe is a bunch of ribbon primitives.

Here is the script I used to do this:

(clear)

(define (nverts)
    (pdata-index-map!
        (lambda (i p)
            (with-state
                (backfacecull 0)
                (hint-none)
                (hint-solid)
                (hint-unlit)
                (colour (rndvec))
                (translate (vadd p (vmul (rndvec) 0.3)))
                (scale 0.05)
                (build-type
"Bitstream-Vera-Sans-Mono.ttf" (number->string i))))
        "p"))


(define (build-contour p verts)
    (let ((q (with-state
                (hint-wire)
                (hint-unlit)
                (wire-colour 0)
                (line-width 10)
                (colour (vector 1 0 0))
                (build-ribbon (+ (length verts) 1)))))
    (with-primitive q
        (for ((i (in-range 0 (length verts))))
            (pdata-set! "p" i (with-primitive p (pdata-get "p" (list-ref
verts i)))))
        (pdata-set! "p" (length verts)
             (with-primitive p (pdata-get "p" (list-ref verts 0)))))
        q))

(define (build-contours p l)
    (map
        (lambda (c)
            (build-contour p c))
        l))
 
(clear-colour 0.2)
(clear-geometry-cache)

(define p (load-primitive "l.obj"))
(with-primitive p
    (wire-opacity 0.5) 
    (hint-wire) 
    (nverts))
(build-contours p '((50 53 63 62 61 11)
                    (47 48 19 34 36 24 28) 
                    (23 22) (29 27) (25 38) (8 0) (6 7) (64 42)))
    

And this is the l.obj:

# Blender3D v245 OBJ File: chm.blend
# www.blender3d.org
o Cube_Cube.001
v -0.336522 -1.000000 -1.840326
v -0.336522 -1.000000 0.159674
v -2.336522 -1.000000 0.159674
v -2.336521 -1.000000 -1.840327
v -0.336521 1.000000 -1.840325
v -0.336522 1.000000 0.159675
v -2.336522 1.000000 0.159674
v -2.336522 1.000000 -1.840326
v -2.336523 -1.000000 1.840324
v -2.336523 0.999999 1.840324
v -0.336522 -1.000000 1.840325
v -0.336523 0.999999 1.840326
v 2.336522 -1.000000 1.840326
v 2.336523 -0.999999 0.159675
v 2.336521 1.000000 1.840327
v 2.336522 1.000001 0.159676
vt 0.976457 0.269392 0.0
vt 0.977021 0.453391 0.0
vt 0.793193 0.453955 0.0
vt 0.792629 0.269957 0.0
vt 0.639471 0.654573 0.0
vt 0.823300 0.655138 0.0
vt 0.822736 0.839136 0.0
vt 0.638907 0.838572 0.0
vt 0.361847 0.976436 0.0
vt 0.178018 0.977000 0.0
vt 0.177454 0.793002 0.0
vt 0.361283 0.792437 0.0
vt 0.823300 0.655138 0.0
vt 0.639471 0.654573 0.0
vt 0.639945 0.499955 0.0
vt 0.823773 0.500519 0.0
vt 0.408558 0.746437 0.0
vt 0.592386 0.745873 0.0
vt 0.592950 0.929871 0.0
vt 0.409122 0.930436 0.0
vt 0.592386 0.745873 0.0
vt 0.408558 0.746437 0.0
vt 0.407804 0.500519 0.0
vt 0.591632 0.499955 0.0
vt 0.178018 0.499955 0.0
vt 0.361847 0.500519 0.0
vt 0.361093 0.746437 0.0
vt 0.177265 0.745873 0.0
vt 0.947105 0.023000 0.0
vt 0.947669 0.206998 0.0
vt 0.793193 0.207473 0.0
vt 0.792629 0.023474 0.0
vt 0.361847 0.206998 0.0
vt 0.177454 0.023564 0.0
vt 0.361283 0.023000 0.0
vt 0.177454 0.023564 0.0
vt 0.361847 0.206998 0.0
vt 0.178018 0.207563 0.0
vt 0.178018 0.207563 0.0
vt 0.022979 0.024039 0.0
vt 0.177454 0.023564 0.0
vt 0.178772 0.453481 0.0
vt 0.022979 0.024039 0.0
vt 0.178018 0.207563 0.0
vt 0.023543 0.208037 0.0
vt 0.022979 0.024039 0.0
vt 0.178772 0.453481 0.0
vt 0.024296 0.453955 0.0
vt 0.023543 0.208037 0.0
vt 0.178772 0.453481 0.0
vt 0.746672 0.269957 0.0
vt 0.746108 0.453955 0.0
vt 0.562280 0.453391 0.0
vt 0.562843 0.269392 0.0
vt 0.746672 0.269957 0.0
vt 0.562280 0.453391 0.0
vt 0.562843 0.269392 0.0
vt 0.562280 0.453391 0.0
vt 0.407804 0.452916 0.0
vt 0.563597 0.023474 0.0
vt 0.562843 0.269392 0.0
vt 0.407804 0.452916 0.0
vt 0.409121 0.023000 0.0
vt 0.563597 0.023474 0.0
vt 0.407804 0.452916 0.0
vt 0.591632 0.499955 0.0
vt 0.592950 0.929871 0.0
vt 0.592386 0.745873 0.0
vn 1.000000 0.000000 0.000000
vn -1.000000 -0.000000 -0.000000
vn 0.000000 0.000000 -1.000000
vn -0.000000 -0.000000 1.000000
vn -0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 -0.000001
vn 0.000000 1.000000 -0.000000
vn -0.000001 0.512053 0.858954
usemtl None_l.png.tga
s off
f 1/1/1 5/2/1 6/3/1 2/4/1
f 3/5/2 7/6/2 8/7/2 4/8/2
f 5/9/3 1/10/3 4/11/3 8/12/3
f 7/13/2 3/14/2 9/15/2 10/16/2
f 11/17/4 12/18/4 10/19/4 9/20/4
f 12/21/4 11/22/4 13/23/4 15/24/4
f 2/25/3 6/26/3 16/27/3 14/28/3
f 14/29/1 16/30/1 15/31/1 13/32/1
f 1/33/5 3/34/5 4/35/5
f 3/36/5 1/37/5 2/38/5
f 2/39/5 9/40/5 3/41/5
f 14/42/5 9/43/5 2/44/5
f 11/45/6 9/46/6 14/47/6
f 13/48/5 11/49/5 14/50/5
f 5/51/7 8/52/7 7/53/7
f 6/54/7 5/55/7 7/56/7
f 6/57/7 7/58/7 10/59/7
f 16/60/7 6/61/7 10/62/7
f 15/63/7 16/64/7 10/65/7
f 15/66/8 10/67/8 12/68/8





More information about the Fluxus mailing list