comparison org/movement.org @ 162:2cbdd7034c6c

moved ear into cortex
author Robert McIntyre <rlm@mit.edu>
date Sat, 04 Feb 2012 01:44:06 -0700
parents 811127d79d24
children f1b078375484
comparison
equal deleted inserted replaced
161:e401dafa5966 162:2cbdd7034c6c
13 (:import jme3tools.converters.ImageToAwt) 13 (:import jme3tools.converters.ImageToAwt)
14 (:import java.awt.image.BufferedImage)) 14 (:import java.awt.image.BufferedImage))
15 15
16 (cortex.import/mega-import-jme3) 16 (cortex.import/mega-import-jme3)
17 17
18
19
20
21 ;; here's how motor-control/ proprioception will work: Each muscle is 18 ;; here's how motor-control/ proprioception will work: Each muscle is
22 ;; defined by a 1-D array of numbers (the "motor pool") each of which 19 ;; defined by a 1-D array of numbers (the "motor pool") each of which
23 ;; represent muscle fibers. A muscle also has a scalar :strength 20 ;; represent muscle fibers. A muscle also has a scalar :strength
24 ;; factor which determines how strong the muscle as a whole is. 21 ;; factor which determines how strong the muscle as a whole is.
25 ;; The effector function for a muscle takes a number < (count 22 ;; The effector function for a muscle takes a number < (count
28 ;; force in proportion to its value in the array. Lower values cause 25 ;; force in proportion to its value in the array. Lower values cause
29 ;; less force. The lower values can be put at the "beginning" of the 26 ;; less force. The lower values can be put at the "beginning" of the
30 ;; 1-D array to simulate the layout of actual human muscles, which are 27 ;; 1-D array to simulate the layout of actual human muscles, which are
31 ;; capable of more percise movements when exerting less force. 28 ;; capable of more percise movements when exerting less force.
32 29
33 ;; I don't know how to encode proprioception, so for now, just return
34 ;; a function for each joint that returns a triplet of floats which
35 ;; represent relative roll, pitch, and yaw. Write display code for
36 ;; this though.
37
38 (defn muscle-fiber-values 30 (defn muscle-fiber-values
39 "get motor pool strengths" 31 "get motor pool strengths"
40 [#^BufferedImage image] 32 [#^BufferedImage image]
41 (vec 33 (vec
42 (let [width (.getWidth image)] 34 (let [width (.getWidth image)]
43 (for [x (range width)] 35 (for [x (range width)]
44 (- 255 36 (- 255
45 (bit-and 37 (bit-and
46 0x0000FF 38 0x0000FF
47 (.getRGB image x 0))))))) 39 (.getRGB image x 0)))))))
48
49 40
50 (defn creature-muscles 41 (defn creature-muscles
51 "Return the children of the creature's \"muscles\" node." 42 "Return the children of the creature's \"muscles\" node."
52 [#^Node creature] 43 [#^Node creature]
53 (if-let [muscle-node (.getChild creature "muscles")] 44 (if-let [muscle-node (.getChild creature "muscles")]