set-data-arrays-lines   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/examples/contrib/kinect_fire.xtm

Implementation

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; helpers for opengl rendering of fluidsym
(bind-func set-data-arrays-lines
  (lambda (cube:fluidcube* point_data:float* color_data:float* xoffset:float yoffset:float n:i64)
    (let ((ii:i64 0)
    (jj:i64 0)
    (Vx (tref cube 6))
    (Vy (tref cube 7))
    (size (tref cube 0))
    (size-y (tref cube 10))
    (cnt 0)
    (red (dtof 0.3))
    (blue (dtof 0.9))
    (green (dtof 0.0))
    (trans (dtof 0.9))
    (mn:double 0.0))
      (dotimes (jj (- size-y 2))
  (dotimes (ii (- size 2))
    (let ((idx (+ (+ ii 1) (* (+ jj 1) size)))
    (xv (pref Vx idx))
    (yv (pref Vy idx))
    (norm (* 1.0 (sqrt (+ (* xv xv) (* yv yv)))))
    (n1 (fabs (/ norm 0.5))))
      ;(set! norm (* 0.125 norm))
      (if (> norm mn) (set! mn norm))
      (pset! point_data (+ 0 (* 4 cnt)) (+ xoffset (i64tof ii)))
      (pset! point_data (+ 1 (* 4 cnt)) (+ yoffset (i64tof jj)))
      (pset! point_data (+ 2 (* 4 cnt)) (dtof (+ (ftod xoffset)
                   (/ xv norm)
              (i64tod ii))))
      (pset! point_data (+ 3 (* 4 cnt)) (dtof (+ (ftod yoffset)
                   (i64tod jj)
                   (/ yv norm))))
      (pset! color_data (+ 0 (* 8 cnt)) red)
      (pset! color_data (+ 1 (* 8 cnt)) green)
      (pset! color_data (+ 2 (* 8 cnt)) blue)
      (pset! color_data (+ 3 (* 8 cnt)) 1.0) ;(dtof (* 4.0 n1))) ;(dtof n1)) ;(dtof (/ norm 10.0))) ;trans) ;trans)
      (pset! color_data (+ 4 (* 8 cnt)) red)
      (pset! color_data (+ 5 (* 8 cnt)) green)
      (pset! color_data (+ 6 (* 8 cnt)) blue)
      (pset! color_data (+ 7 (* 8 cnt)) (dtof (* 4.0 n1))) ; (dtof (/ norm 10.0)))
      (set! cnt (+ cnt 1))))))
    void))


Back to Index