Mercurial > cortex
comparison org/test-creature.org @ 109:c05d8d222166
ready to start touch UV maps with GIMP
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 16 Jan 2012 03:19:15 -0700 |
parents | 92b857b6145d |
children | f89f0b9ed2fe |
comparison
equal
deleted
inserted
replaced
108:92b857b6145d | 109:c05d8d222166 |
---|---|
626 (vec (map :geometry (locate-feelers geo)))) | 626 (vec (map :geometry (locate-feelers geo)))) |
627 | 627 |
628 (defn enable-touch [#^Geometry geo] | 628 (defn enable-touch [#^Geometry geo] |
629 (let [feeler-coords (feeler-coordinates geo) | 629 (let [feeler-coords (feeler-coordinates geo) |
630 tris (triangles geo) | 630 tris (triangles geo) |
631 limit 0.1] | 631 limit 0.1 |
632 ;;results (CollisionResults.) | |
633 ] | |
632 (fn [node] | 634 (fn [node] |
633 (let [sensor-origins | 635 (let [sensor-origins |
634 (map | 636 (map |
635 #(map (partial local-to-world geo) %) | 637 #(map (partial local-to-world geo) %) |
636 feeler-coords) | 638 feeler-coords) |
655 (filter #(not (= geo %)) | 657 (filter #(not (= geo %)) |
656 (map #(.getGeometry %) results)))] | 658 (map #(.getGeometry %) results)))] |
657 (if (> (count touch-objects) 0) | 659 (if (> (count touch-objects) 0) |
658 1 0))))))))))) | 660 1 0))))))))))) |
659 | 661 |
662 | |
663 | |
660 (defn touch [#^Node pieces] | 664 (defn touch [#^Node pieces] |
661 (map enable-touch | 665 (map enable-touch |
662 (filter #(isa? (class %) Geometry) | 666 (filter #(isa? (class %) Geometry) |
663 (node-seq pieces)))) | 667 (node-seq pieces)))) |
664 | 668 |
702 (light-up-everything world) | 706 (light-up-everything world) |
703 (enable-debug world) | 707 (enable-debug world) |
704 ;;(com.aurellem.capture.Capture/captureVideo | 708 ;;(com.aurellem.capture.Capture/captureVideo |
705 ;; world (file-str "/home/r/proj/ai-videos/hand")) | 709 ;; world (file-str "/home/r/proj/ai-videos/hand")) |
706 (.setTimer world (RatchetTimer. 60)) | 710 (.setTimer world (RatchetTimer. 60)) |
707 ;;(speed-up world) | 711 (speed-up world) |
708 ;;(set-gravity world (Vector3f. 0 0 0)) | 712 ;;(set-gravity world (Vector3f. 0 0 0)) |
709 ) | 713 ) |
710 (fn [world tpf] | 714 (fn [world tpf] |
715 ;;(dorun | |
716 ;; (map #(%1 %2) touch-nerves (repeat (.getRootNode world)))) | |
717 | |
711 (dorun | 718 (dorun |
712 (map #(%1 (%2 (.getRootNode world))) touch-debug-windows touch-nerves)) | 719 (map #(%1 (%2 (.getRootNode world))) |
720 touch-debug-windows touch-nerves)) | |
721 | |
722 | |
713 ) | 723 ) |
714 ;;(let [timer (atom 0)] | 724 ;;(let [timer (atom 0)] |
715 ;; (fn [_ _] | 725 ;; (fn [_ _] |
716 ;; (swap! timer inc) | 726 ;; (swap! timer inc) |
717 ;; (if (= (rem @timer 60) 0) | 727 ;; (if (= (rem @timer 60) 0) |
718 ;; (println-repl (float (/ @timer 60)))))) | 728 ;; (println-repl (float (/ @timer 60)))))) |
719 ))) | 729 ))) |
720 | 730 |
731 | |
732 | |
733 | |
734 | |
735 | |
736 | |
737 | |
738 | |
739 ;;; experiments in collisions | |
740 | |
741 | |
742 | |
743 (defn collision-test [] | |
744 (let [a-radius 1 | |
745 a-position (Vector3f. -0.25 3 0) | |
746 b-radius 1 | |
747 b-position (Vector3f. 0.25 3 0) | |
748 | |
749 | |
750 obj-a (box 1 1 1 :color ColorRGBA/Red | |
751 :position a-position | |
752 :physical? false) | |
753 obj-b (box 1 1 1 :color ColorRGBA/Blue | |
754 :position b-position | |
755 :physical? false) | |
756 node (nodify [obj-a obj-b]) | |
757 bounds-a (BoundingBox. a-position 1 1 1) | |
758 bounds-b (BoundingBox. b-position 1 1 1) | |
759 sim | |
760 (world node | |
761 {} | |
762 no-op | |
763 no-op) | |
764 | |
765 ] | |
766 (.setBound (.getMesh obj-a) bounds-a) | |
767 (.updateBound (.getMesh obj-a)) | |
768 | |
769 | |
770 (.setBound (.getMesh obj-b) bounds-b) | |
771 (.updateBound (.getMesh obj-b)) | |
772 | |
773 | |
774 | |
775 (let [cr (CollisionResults.)] | |
776 (.collideWith node bounds-a cr) | |
777 [cr sim]) | |
778 | |
779 )) | |
780 | |
781 | |
782 | |
783 | |
721 #+end_src | 784 #+end_src |
722 | 785 |
723 #+results: body-1 | 786 #+results: body-1 |
724 : #'cortex.silly/tactile-coords | 787 : #'cortex.silly/test-creature |
725 | 788 |
726 | 789 |
727 * COMMENT purgatory | 790 * COMMENT purgatory |
728 #+begin_src clojure | 791 #+begin_src clojure |
729 (defn bullet-trans [] | 792 (defn bullet-trans [] |