Skip to content

Instantly share code, notes, and snippets.

@knorth55
Last active June 6, 2020 21:42
Show Gist options
  • Save knorth55/a852656d8fa69dcd48c40c5038748e5c to your computer and use it in GitHub Desktop.
Save knorth55/a852656d8fa69dcd48c40c5038748e5c to your computer and use it in GitHub Desktop.
(require "models/room73b2-hitachi-fiesta-refrigerator-object.l")
(defun main ()
(let ((faces (flatten (send-all (flatten (send-all (send *fridge* :links) :bodies)) :faces)))
(face-i 0))
(while (< face-i (length faces))
(send *viewer* :draw-objects :flush nil)
(do-until-key
(let ((i 0))
(while (< i (length faces))
(let* ((f (elt faces i))
(normal (scale 200 (send f :normal)))
(vertices (send f :vertices))
(center #f(0 0 0))
(prev-v nil))
(if (eq face-i i)
(progn
(send *viewer* :viewsurface :line-width 3)
(send *viewer* :viewsurface :color #F(1.0 0 0))
(dolist (v vertices)
(if prev-v (send *viewer* :draw-line prev-v v))
(setq prev-v v)
(setq center (v+ center v)))
(setq center (scale (/ 1.0 (length vertices)) center))
(send *viewer* :draw-arrow center (v+ center normal)))
(progn
(send *viewer* :viewsurface :line-width 0.5)
(send *viewer* :viewsurface :color #F(0 1.0 0))
(dolist (v vertices)
(if prev-v (send *viewer* :draw-line prev-v v))
(setq prev-v v)))))
(setq i (+ i 1))))
(send *viewer* :viewsurface :flush)
(x::window-main-one)
(unix::usleep (* 100 1000)))
(setq face-i (+ face-i 1)))))
(setq *fridge* (room73b2-hitachi-fiesta-refrigerator))
(when (not (and (boundp '*viewer*) *viewer*))
(make-irtviewer :draw-origin nil :draw-floor #F(0 0 0) :title "fridge-normal.l"))
(main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment