comparison org/test-creature.org @ 115:247860e25536

added eye to creature in blender
author Robert McIntyre <rlm@mit.edu>
date Thu, 19 Jan 2012 22:26:16 -0700
parents 9d0fe7f54e14
children 947bef5d6670
comparison
equal deleted inserted replaced
114:9d0fe7f54e14 115:247860e25536
88 (for [index (range (count points))] 88 (for [index (range (count points))]
89 (.setRGB image (- (xs index) x0) (- (ys index) y0) -1))) 89 (.setRGB image (- (xs index) x0) (- (ys index) y0) -1)))
90 90
91 image))) 91 image)))
92 92
93 (defn test-data
94 []
95 (vec
96 (for [a (range 0 1000 2)
97 b (range 0 1000 2)]
98 (vector a b))
99 ))
100
101 (defn average [coll] 93 (defn average [coll]
102 (/ (reduce + coll) (count coll))) 94 (/ (reduce + coll) (count coll)))
103 95
104 (defn collapse-1d 96 (defn collapse-1d
105 "One dimensional analogue of collapse" 97 "One dimensional analogue of collapse"
106 [center line] 98 [center line]
107 (let [length (count line) 99 (let [length (count line)
108 num-above (count (filter (partial < center) line)) 100 num-above (count (filter (partial < center) line))
109 num-below (- length num-above)] 101 num-below (- length num-above)]
110 (range (- center num-below) 102 (range (- center num-below)
111 (+ center num-above)) 103 (+ center num-above))))
112 ))
113 104
114 (defn collapse 105 (defn collapse
115 "Take a set of pairs of integers and collapse them into a 106 "Take a set of pairs of integers and collapse them into a
116 contigous bitmap." 107 contigous bitmap."
117 [points] 108 [points]
146 min-y (apply min (map second squeezed))] 137 min-y (apply min (map second squeezed))]
147 (map (fn [[x y]] 138 (map (fn [[x y]]
148 [(- x min-x) 139 [(- x min-x)
149 (- y min-y)]) 140 (- y min-y)])
150 squeezed))] 141 squeezed))]
151 relocate 142 relocate)))
152 )))
153 143
154 (defn load-bullet [] 144 (defn load-bullet []
155 (let [sim (world (Node.) {} no-op no-op)] 145 (let [sim (world (Node.) {} no-op no-op)]
156 (doto sim 146 (doto sim
157 (.enqueue 147 (.enqueue
229 coordinates" 219 coordinates"
230 [#^Spatial object local-coordinate] 220 [#^Spatial object local-coordinate]
231 (let [world-coordinate (Vector3f.)] 221 (let [world-coordinate (Vector3f.)]
232 (.localToWorld object local-coordinate world-coordinate) 222 (.localToWorld object local-coordinate world-coordinate)
233 world-coordinate)) 223 world-coordinate))
234
235 224
236 (defmulti joint-dispatch 225 (defmulti joint-dispatch
237 "Translate blender pseudo-joints into real JME joints." 226 "Translate blender pseudo-joints into real JME joints."
238 (fn [constraints & _] 227 (fn [constraints & _]
239 (:type constraints))) 228 (:type constraints)))