comparison org/test-creature.org @ 145:7a49b81ca1bf

finally got proprioception working to my satisfaction
author Robert McIntyre <rlm@mit.edu>
date Thu, 02 Feb 2012 12:49:11 -0700
parents d0f4b473ab4f
children 68226790d1fa
comparison
equal deleted inserted replaced
144:48f9cba082eb 145:7a49b81ca1bf
1084 (for [x (range width)] 1084 (for [x (range width)]
1085 (bit-and 1085 (bit-and
1086 0xFF 1086 0xFF
1087 (.getRGB image x 0))))) 1087 (.getRGB image x 0)))))
1088 1088
1089
1090 (defn draw-sprite [image sprite x y color ]
1091 (dorun
1092 (for [[u v] sprite]
1093 (.setRGB image (+ u x) (+ v y) color))))
1094
1095 (defn view-angle
1096 "create a debug view of an angle"
1097 [color]
1098 (let [image (BufferedImage. 50 50 BufferedImage/TYPE_INT_RGB)
1099 previous (atom [25 25])
1100 sprite [[0 0] [0 1]
1101 [0 -1] [-1 0] [1 0]]]
1102 (fn [angle]
1103 (let [angle (float angle)]
1104 (let [position
1105 [(+ 25 (int (* 20 (Math/cos angle))))
1106 (+ 25 (int (* 20(Math/sin angle))))]]
1107 (draw-sprite image sprite (@previous 0) (@previous 1) 0x000000)
1108 (draw-sprite image sprite (position 0) (position 1) color)
1109 (reset! previous position))
1110 image))))
1111
1112 (defn proprioception-debug-window
1113 []
1114 (let [yaw (view-angle 0xFF0000)
1115 roll (view-angle 0x00FF00)
1116 pitch (view-angle 0xFFFFFF)
1117 v-yaw (view-image)
1118 v-roll (view-image)
1119 v-pitch (view-image)
1120 ]
1121 (fn [prop-data]
1122 (dorun
1123 (map
1124 (fn [[y r p]]
1125 (v-yaw (yaw y))
1126 (v-roll (roll r))
1127 (v-pitch (pitch p)))
1128 prop-data)))))
1129
1130
1131
1132
1133
1134
1135
1136 (defn test-creature [thing] 1089 (defn test-creature [thing]
1137 (let [x-axis 1090 (let [x-axis
1138 (box 1 0.01 0.01 :physical? false :color ColorRGBA/Red) 1091 (box 1 0.01 0.01 :physical? false :color ColorRGBA/Red)
1139 y-axis 1092 y-axis
1140 (box 0.01 1 0.01 :physical? false :color ColorRGBA/Green) 1093 (box 0.01 1 0.01 :physical? false :color ColorRGBA/Green)
1188 (add-eye world 1141 (add-eye world
1189 (attach-eye creature (test-eye)) 1142 (attach-eye creature (test-eye))
1190 (comp (view-image) BufferedImage!)) 1143 (comp (view-image) BufferedImage!))
1191 1144
1192 (add-eye world (.getCamera world) no-op) 1145 (add-eye world (.getCamera world) no-op)
1193 (set-gravity world (Vector3f. 0 0 0)) 1146 ;;(set-gravity world (Vector3f. 0 0 0))
1194 ;;(com.aurellem.capture.Capture/captureVideo 1147 ;;(com.aurellem.capture.Capture/captureVideo
1195 ;; world (file-str "/home/r/proj/ai-videos/hand")) 1148 ;; world (file-str "/home/r/proj/ai-videos/hand"))
1196 ;;(.setTimer world (RatchetTimer. 60)) 1149 ;;(.setTimer world (RatchetTimer. 60))
1197 (speed-up world) 1150 (speed-up world)
1198 ;;(set-gravity world (Vector3f. 0 0 0)) 1151 ;;(set-gravity world (Vector3f. 0 0 0))