[Fluxus] Problems compiling latest
evan.raskob [lists]
lists at lowfrequency.org
Sat Dec 18 11:05:08 PST 2010
Actually, that would be great, I wanted to do a project using both in fluxus. Thanks!
The ARToolkit module does compile, by the way. And, since openframeworks can do both (I finally have a working example of how to do it[1]) in 10.6.5, we should be able to get them both working in fluxus!
I've got a bit of a "break" coming up so I will experiment.
Also, is there any Animata support in Fluxus? I'd love to do some virtual puppetry in fluxus. If not, I may build some... I've seen the Processing library and it doesn't look difficult, probably the xml parsing in scheme is the trickiest bit, but I've done that already (if not badly...)
[1] http://pixelist.info/artoolkitplus-in-openframeworks/
Best
Evan
some inefficient svg-reading xml code:
;--- http://pixelist.info
;--- licensed under the GPLv3 (available online)
(clear)
(require fluxus-017/shapes
xml/xml
scheme/list)
;----- SVG stuff
;-- print out all points in poygons in an svg file
(define (svg-polygons doc)
(build-svg-polygons doc '()))
(define (build-svg-polygons doc lst)
(cond [(empty? doc) lst]
[else
(let [(e (car doc))]
(cond [(and (list? e) (eq? (car e) 'polygon))
(build-svg-polygons (cdr doc) (cons e lst))]
[else
(build-svg-polygons (cdr doc) lst)]
)
)
])
)
;-- print out all points in poygons in an svg file
(define (svg-elems e-name doc)
(build-svg-elems e-name doc '()))
(define (build-svg-elems e-name doc lst)
(cond [(empty? doc) lst]
[else
(let [(e (car doc))]
(cond [(and (list? e) (eq? (car e) e-name))
(build-svg-elems e-name (cdr doc) (cons e lst))]
[else
(build-svg-elems e-name (cdr doc) lst)]
)
)
])
)
(define (get-svg-attr attr-name elems-list)
(cond [(empty? elems-list) '()]
[else
(let [(e-list (car elems-list))]
; (printf "e: ~s\n" e-list)
(cond [(list? e-list)
(cond
[(eq? (car e-list) attr-name)
(cdr e-list)
]
[else
(get-svg-attr attr-name (cdr e-list))]
)
]
[else (get-svg-attr attr-name (cdr elems-list))]
)
)
])
)
(define points-str '())
(define points '())
;; toplevel load
(define (svg-import filename)
(let* [(p (open-input-file (fullpath filename)))
(doc (xml->xexpr (document-element (read-xml p))))]
(display (list-ref doc 1))(newline)
(let [(doc-props (list-ref doc 1))]
(map (lambda (p) (printf "elem: ~s\n" p)) doc-props)
(map (lambda (p)
(cond [(= (car p) 'viewBox) (printf "~s\n" (cdr p))]
[else (printf "NO:~s\n" (car p))])
) doc-props)
)
(let* [(viewbox (regexp-split " " (list-ref (list-ref (list-ref doc 1) 3) 1)))
(view-x (string->number (list-ref viewbox 2)))
(view-y (string->number (list-ref viewbox 3)))]
(newline)
(display "viewbox:")(newline)
(printf "~s:~s\n\n" view-x view-y)
(set! points-str
(regexp-split " " (car (get-svg-attr 'points (svg-elems 'polygon (cdr doc))))))
(set! points-str (map (lambda (e)
(list->vector (regexp-split "," e)))
points-str)
)
(set! points-str (filter (lambda (n) (> (vector-length n) 1)) points-str))
(set! points (map (lambda (e)
(vector (- 0.5 (/ (string->number (vx e)) view-x)) (- 0.5 (/ (string->number (vy e)) view-y)) 0))
points-str)
)
; (printf "POINTS: ~s\n" points)
)
(close-input-port p)
)
)
;(svg-import "/Users/evan/cvs/newflx/fluxus/svg-test/evhand-edit.svg")
(svg-import "/Users/evan/cvs/newflx/fluxus/svg-test/hand-535.svg")
(define (smooth-path p slope-thresh)
(define (_ p-orig p-new)
(cond [(< (length p-orig) 3) p-new]
[else
(let* [(p1 (list-ref p-orig 0))
(p2 (list-ref p-orig 1))
(p3 (list-ref p-orig 2))
(slope-p31 (vsub p3 p1))
(slope-p21 (vsub p2 p1))
(slope-diff (vdist-sq slope-p31 slope-p21))]
(printf "slope diff: ~s / ~s\n" slope-diff (length p-orig))
(cond
; discard point as redundant if under threshold
[(or (< slope-diff slope-thresh)
(< (vdist-sq p1 p2) 0.00008)) (_ (cdr p-orig) p-new)]
; otherwise add it
[else (_ (cdr (cdr p-orig)) (append p-new (list p1 p2)))]
)
)
])
)
(append (_ p '()) (list (car p)))
)
(set! points (smooth-path points 0.0001))
;--- shape stuffs
(define last-mouse (mouse-pos))
(define num-pts 15)
(define l (build-list num-pts (lambda (i)
(vector 0 0 0))))
(define w (build-list num-pts (lambda (i)
(* 0.5 (+ 1 (sin (* 3.14156 (/ i 100))))))))
(define blotch
(with-state
(build-partial-extrusion points l 1)
)
)
(define (jitter)
(set! l
(map (lambda(n) (vadd (vmul (crndvec) 0.1) n)) l)))
(define (draw-extr e)
(with-primitive e
(partial-extrude
(length l)
points
l
w
#(0 1 0)
0.1)
)
)
(define (list-mix l1 l2 amt)
(map (lambda (n m)
(mix n m amt)
)
l1
l2)
)
(define (vlist-mix l1 l2 amt)
(map (lambda (n m)
(vector
(mix (vx n) (vx m) amt)
(mix (vy n) (vy m) amt)
(mix (vz n) (vz m) amt)
)
)
l1
l2)
)
(define (balls)
(display "balls")(newline)
(with-primitive blotch
(save-primitive
(string-append "obj" (number->string (time)) ".obj")))
)
(define (animator)
; (cond [(key-pressed-this-frame "$") (tiled-framedump (string-append "dump" (number->string (time)) ".jpg") 2048 1536)])
(cond [(key-pressed-this-frame "$") (balls)
])
; (jitter)
(cond [(> (vdist-sq last-mouse (mouse-pos)) 0.05)
(let* [ (last (mouse-pos))
(l-tmp (append (cdr l) (list last)))
(lr-tmp (reverse (cdr (cdr l)))) ; 2nd to last elems
]
(set! l (vlist-mix l-tmp
(append (cons (car l) lr-tmp)
(list last)) 0.98))
)
(let* [(val
(* 2 (log (+ 1 (vdist last-mouse (mouse-pos))))))
(wlast (car (reverse w)))
(w-new (append (cdr w)
(list
(mix wlast (* val val) 0.3)
)))
(w-cdr (cdr w))
(w-tmp (reverse (cdr w-cdr)))]
(set! w (list-mix w-new
(append (cons (car w) w-tmp) (list wlast)) 0.9))
)
(set! last-mouse (mouse-pos))
])
(draw-extr blotch)
)
(every-frame (animator))
On 18 Dec 2010, at 18:56, gabor papp wrote:
>> Right, that sucks. What were you using in the past to do AR? Was
>> that using PLT Scheme and not Racket?
> i still haven't switched from osx 10.5 because of this and other similar reasons. i can build a binary for you that you can use on 10.6 with the video and ar modules.
>
> gabor
More information about the Fluxus
mailing list