Commit 68006595 authored by Dave Griffiths's avatar Dave Griffiths
Browse files

reversed weft on return

parent 855214cc
......@@ -33,31 +33,60 @@
'(let ((vertex positions-start)
(t 0)
(v 0)
(weft-direction (vector 3 0 0))
(weft-position (vector 0 0 0)))
(weft-direction (vector 2 0 0))
(weft-position (vector 0 0 0))
(weft-t 0)
(draft-pos 0)
(draft-size 4)
(draft 1) (d-b 0) (d-c 0) (d-d 1)
(d-e 1) (d-f 1) (d-g 0) (d-h 0)
(d-i 0) (d-j 1) (d-k 1) (d-l 0)
(d-m 0) (d-n 0) (d-o 1) (d-p 1)
(draft-tmp 0)
(shed-tmp 0)
(weft-z (vector 0 0 0))
(weft-count 0))
(define calc-weft-z
(lambda ()
(set! draft-tmp
(read (+ (addr draft)
(+ (* draft-pos draft-size)
(cond ((> weft-direction 0)
(modulo weft-count (+ draft-size (vector 0 1 1)) ))
((< weft-direction 0)
(- draft-size (modulo weft-count (+ draft-size (vector 0 1 1)) ))))))))
(set! weft-count (+ weft-count 1))
(cond ((> draft-tmp 0.5)
(set! weft-z (vector 0 0 0.01)))
((< draft-tmp 0.5)
(set! weft-z (vector 0 0 -0.01))))
))
(define right-selvedge
(lambda (gap)
;; top corner
(write! vertex
(- (+ weft-position (vector 3 0 0)) gap)
(- (+ weft-position (vector 4 1 0)) gap)
(- (+ weft-position (vector 3 1 0)) gap))
(- (+ weft-position (vector 2 0 0)) gap)
(- (+ weft-position (vector 3 1 0)) gap)
(- (+ weft-position (vector 2 1 0)) gap))
(set! vertex (+ vertex 3))
;; vertical connection
(write! vertex
(- (+ weft-position (vector 4 1 0)) gap)
(- (+ weft-position (vector 3 1 0)) gap)
(+ weft-position (vector 3 0 0))
(- (+ weft-position (vector 4 1 0)) gap)
(+ weft-position (vector 3 0 0))
(+ weft-position (vector 4 0 0)))
(- (+ weft-position (vector 2 1 0)) gap)
(+ weft-position (vector 2 0 0))
(- (+ weft-position (vector 3 1 0)) gap)
(+ weft-position (vector 2 0 0))
(+ weft-position (vector 3 0 0)))
(set! vertex (+ vertex 6))
;; bottom corner
(write! vertex
(+ weft-position (vector 2 0 0))
(+ weft-position (vector 3 0 0))
(+ weft-position (vector 4 0 0))
(+ weft-position (vector 3 1 0)))
(+ weft-position (vector 2 1 0)))
(set! vertex (+ vertex 3))
))
......@@ -89,10 +118,26 @@
(forever
(set! vertex positions-start)
(loop (< vertex positions-end)
; (set! weft-t (+ weft-t 0.05))
; (cond ((> weft-t 1)
; (set! draft-pos (+ draft-pos 1))
; (cond ((> draft-pos draft-size)
; (set! draft-pos 0)))
; (set! weft-t 0)))
(calc-weft-z)
(set! weft-position (+ weft-position weft-direction))
;; selvedge time?
(cond
((> (mag (*v weft-position (vector 1 0 0))) 40)
((> (mag (*v weft-position (vector 1 0 0))) 22)
(set! weft-count 0)
(set! draft-pos (+ draft-pos 1))
(cond ((> draft-pos draft-size)
(set! draft-pos 0)))
(set! weft-position (- (+ weft-position (vector 0 1.5 0))
weft-direction))
(set! weft-direction (* weft-direction -1))
......@@ -100,13 +145,14 @@
((> 0 weft-direction) (right-selvedge (vector 0 1.5 0)))
((< 0 weft-direction) (left-selvedge (vector 0 1.5 0))))))
(write! vertex
weft-position
(+ weft-position (vector 3 1 0))
(+ weft-position (vector 3 0 0))
weft-position
(+ weft-position (vector 3 1 0))
(+ weft-position (vector 0 1 0)))
(+ weft-z weft-position)
(+ weft-position (+ weft-z (vector 2 1 0)))
(+ weft-position (+ weft-z (vector 2 0 0)))
(+ weft-z weft-position)
(+ weft-position (+ weft-z (vector 2 1 0)))
(+ weft-position (+ weft-z (vector 0 1 0))))
(set! vertex (+ vertex 6)))
;;(set! t (+ t 0.01))
))))
......@@ -168,8 +214,8 @@
(set! vertex positions-start)
; build 4 segments X warp-ends
(loop (< warp-end 20)
(set! warp-position (+ (vector -25 -35 0)
(* (vector 2.5 0 0) warp-end)))
(set! warp-position (+ (vector -19 -35 0)
(* (vector 2 0 0) warp-end)))
(build-quad warp-position (vector 1 35 0))
(build-quad (+ warp-position (vector 0 35 0)) (vector 1 15 0))
(build-quad (+ warp-position (vector 0 50 0)) (vector 1 15 0))
......@@ -181,7 +227,6 @@
(set! weft-t (+ weft-t 0.05))
(cond ((> weft-t 1)
(trace draft-pos)
(set! draft-pos (+ draft-pos 1))
(cond ((> draft-pos draft-size)
(set! draft-pos 0)))
......@@ -199,7 +244,7 @@
(with-primitive
warp
(hint-unlit)
(texture (load-texture "thread.png"))
; (texture (load-texture "thread.png"))
(scale weave-scale)
(pdata-index-map! (lambda (i t)
(cond
......@@ -217,7 +262,7 @@
(with-primitive
weft
(hint-unlit)
(texture (load-texture "thread.png"))
; (texture (load-texture "thread.png"))
(scale weave-scale)
(pdata-index-map! (lambda (i t)
(cond
......@@ -228,7 +273,7 @@
((eqv? (modulo i 6) 4) (vector 1 1 0))
((eqv? (modulo i 6) 5) (vector 0 1 0))
)) "t")
(pdata-map! (lambda (c) (vector 0.2 0.8 1)) "c")
(pdata-map! (lambda (c) (vector 0 0 1)) "c")
(pdata-map! (lambda (n) (vector 0 0 0)) "n"))
(every-frame
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment