Mercurial > cortex
view org/test-creature.org @ 91:2bcc7636cfea
faster touch creation code
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 09 Jan 2012 06:02:06 -0700 |
parents | 6d7c17c847a3 |
children | e70ec4bba96b |
line wrap: on
line source
1 #+title: First attempt at a creature!2 #+author: Robert McIntyre3 #+email: rlm@mit.edu4 #+description:5 #+keywords: simulation, jMonkeyEngine3, clojure6 #+SETUPFILE: ../../aurellem/org/setup.org7 #+INCLUDE: ../../aurellem/org/level-0.org9 * Intro10 So far, I've made the following senses --11 - Vision12 - Hearing13 - Touch14 - Proprioception16 And one effector:17 - Movement19 However, the code so far has only enabled these senses, but has not20 actually implemented them. For example, there is still a lot of work21 to be done for vision. I need to be able to create an /eyeball/ in22 simulation that can be moved around and see the world from different23 angles. I also need to determine weather to use log-polar or cartesian24 for the visual input, and I need to determine how/wether to25 disceritise the visual input.27 I also want to be able to visualize both the sensors and the28 effectors in pretty pictures. This semi-retarted creature will by my29 first attempt at bringing everything together.31 * The creature's body33 Still going to do an eve-like body in blender, but due to problems34 importing the joints, etc into jMonkeyEngine3, I',m going to do all35 the connecting here in clojure code, using the names of the individual36 components and trial and error. Later, I'll maybe make some sort of37 creature-building modifications to blender that support whatever38 discreitized senses I'm going to make.40 #+name: body-141 #+begin_src clojure42 (ns cortex.silly43 "let's play!"44 {:author "Robert McIntyre"})46 ;; TODO remove this!47 (require 'cortex.import)48 (cortex.import/mega-import-jme3)49 (use '(cortex world util body hearing touch vision))51 (rlm.rlm-commands/help)53 (declare joint-create)55 (defn load-bullet []56 (let [sim (world (Node.) {} no-op no-op)]57 (.enqueue58 sim59 (fn []60 (.stop sim)))61 (.start sim)))63 (defn load-blender-model64 "Load a .blend file using an asset folder relative path."65 [^String model]66 (.loadModel67 (doto (asset-manager)68 (.registerLoader BlenderModelLoader (into-array String ["blend"])))69 model))71 (defn meta-data [blender-node key]72 (if-let [data (.getUserData blender-node "properties")]73 (.findValue data key)74 nil))76 (defn blender-to-jme77 "Convert from Blender coordinates to JME coordinates"78 [#^Vector3f in]79 (Vector3f. (.getX in)80 (.getZ in)81 (- (.getY in))))83 (defn jme-to-blender84 "Convert from JME coordinates to Blender coordinates"85 [#^Vector3f in]86 (Vector3f. (.getX in)87 (- (.getZ in))88 (.getY in)))90 (defn joint-targets91 "Return the two closest two objects to the joint object, ordered92 from bottom to top according to the joint's rotation."93 [#^Node parts #^Node joint]94 ;;(println (meta-data joint "joint"))95 (.getWorldRotation joint)96 (loop [radius (float 0.01)]97 (let [results (CollisionResults.)]98 (.collideWith99 parts100 (BoundingBox. (.getWorldTranslation joint)101 radius radius radius)102 results)103 (let [targets104 (distinct105 (map #(.getGeometry %) results))]106 (if (>= (count targets) 2)107 (sort-by108 #(let [v109 (jme-to-blender110 (.mult111 (.inverse (.getWorldRotation joint))112 (.subtract (.getWorldTranslation %)113 (.getWorldTranslation joint))))]114 (println-repl (.getName %) ":" v)115 (.dot (Vector3f. 1 1 1)116 v))117 (take 2 targets))118 (recur (float (* radius 2))))))))120 (defn world-to-local121 "Convert the world coordinates into coordinates relative to the122 object (i.e. local coordinates), taking into account the rotation123 of object."124 [#^Spatial object world-coordinate]125 (let [out (Vector3f.)]126 (.worldToLocal object world-coordinate out) out))128 (defmulti joint-dispatch129 "Translate blender pseudo-joints into real JME joints."130 (fn [constraints & _]131 (:type constraints)))133 (defmethod joint-dispatch :point134 [constraints control-a control-b pivot-a pivot-b rotation]135 (println-repl "creating POINT2POINT joint")136 (Point2PointJoint.137 control-a138 control-b139 pivot-a140 pivot-b))142 (defmethod joint-dispatch :hinge143 [constraints control-a control-b pivot-a pivot-b rotation]144 (println-repl "creating HINGE joint")145 (let [axis146 (if-let147 [axis (:axis constraints)]148 axis149 Vector3f/UNIT_X)150 [limit-1 limit-2] (:limit constraints)151 hinge-axis152 (.mult153 rotation154 (blender-to-jme axis))]155 (doto156 (HingeJoint.157 control-a158 control-b159 pivot-a160 pivot-b161 hinge-axis162 hinge-axis)163 (.setLimit limit-1 limit-2))))165 (defmethod joint-dispatch :cone166 [constraints control-a control-b pivot-a pivot-b rotation]167 (let [limit-xz (:limit-xz constraints)168 limit-xy (:limit-xy constraints)169 twist (:twist constraints)]171 (println-repl "creating CONE joint")172 (println-repl rotation)173 (println-repl174 "UNIT_X --> " (.mult rotation (Vector3f. 1 0 0)))175 (println-repl176 "UNIT_Y --> " (.mult rotation (Vector3f. 0 1 0)))177 (println-repl178 "UNIT_Z --> " (.mult rotation (Vector3f. 0 0 1)))179 (doto180 (ConeJoint.181 control-a182 control-b183 pivot-a184 pivot-b185 rotation186 rotation)187 (.setLimit (float limit-xz)188 (float limit-xy)189 (float twist)))))191 (defn connect192 "here are some examples:193 {:type :point}194 {:type :hinge :limit [0 (/ Math/PI 2)] :axis (Vector3f. 0 1 0)}195 (:axis defaults to (Vector3f. 1 0 0) if not provided for hinge joints)197 {:type :cone :limit-xz 0]198 :limit-xy 0]199 :twist 0]} (use XZY rotation mode in blender!)"200 [#^Node obj-a #^Node obj-b #^Node joint]201 (let [control-a (.getControl obj-a RigidBodyControl)202 control-b (.getControl obj-b RigidBodyControl)203 joint-center (.getWorldTranslation joint)204 joint-rotation (.toRotationMatrix (.getWorldRotation joint))205 pivot-a (world-to-local obj-a joint-center)206 pivot-b (world-to-local obj-b joint-center)]208 (if-let [constraints209 (map-vals210 eval211 (read-string212 (meta-data joint "joint")))]213 ;; A side-effect of creating a joint registers214 ;; it with both physics objects which in turn215 ;; will register the joint with the physics system216 ;; when the simulation is started.217 (do218 (println-repl "creating joint between"219 (.getName obj-a) "and" (.getName obj-b))220 (joint-dispatch constraints221 control-a control-b222 pivot-a pivot-b223 joint-rotation))224 (println-repl "could not find joint meta-data!"))))226 (defn assemble-creature [#^Node pieces joints]227 (dorun228 (map229 (fn [geom]230 (let [physics-control231 (RigidBodyControl.232 (HullCollisionShape.233 (.getMesh geom))234 (if-let [mass (meta-data geom "mass")]235 (do236 (println-repl237 "setting" (.getName geom) "mass to" (float mass))238 (float mass))239 (float 1)))]241 (.addControl geom physics-control)))242 (filter #(isa? (class %) Geometry )243 (node-seq pieces))))245 (dorun246 (map247 (fn [joint]248 (let [[obj-a obj-b]249 (joint-targets pieces joint)]250 (connect obj-a obj-b joint)))251 joints))252 pieces)254 (defn blender-creature [blender-path]255 (let [model (load-blender-model blender-path)256 joints257 (if-let [joint-node (.getChild model "joints")]258 (seq (.getChildren joint-node))259 (do (println-repl "could not find joints node")260 []))]261 (assemble-creature model joints)))263 (def hand "Models/creature1/one.blend")265 (def worm "Models/creature1/try-again.blend")267 (def touch "Models/creature1/touch.blend")269 (defn worm-model [] (load-blender-model worm))271 (defn x-ray [#^ColorRGBA color]272 (doto (Material. (asset-manager)273 "Common/MatDefs/Misc/Unshaded.j3md")274 (.setColor "Color" color)275 (-> (.getAdditionalRenderState)276 (.setDepthTest false))))278 (defn test-creature [thing]279 (let [x-axis280 (box 1 0.01 0.01 :physical? false :color ColorRGBA/Red)281 y-axis282 (box 0.01 1 0.01 :physical? false :color ColorRGBA/Green)283 z-axis284 (box 0.01 0.01 1 :physical? false :color ColorRGBA/Blue)]285 (world286 (nodify [(blender-creature thing)287 (box 10 2 10 :position (Vector3f. 0 -9 0)288 :color ColorRGBA/Gray :mass 0)289 x-axis y-axis z-axis290 ])291 standard-debug-controls292 (fn [world]293 (light-up-everything world)294 (enable-debug world)295 ;;(com.aurellem.capture.Capture/captureVideo296 ;; world (file-str "/home/r/proj/ai-videos/hand"))297 (.setTimer world (NanoTimer.))298 ;;(set-gravity world (Vector3f. 0 0 0))299 (speed-up world)300 )301 no-op302 ;;(let [timer (atom 0)]303 ;; (fn [_ _]304 ;; (swap! timer inc)305 ;; (if (= (rem @timer 60) 0)306 ;; (println-repl (float (/ @timer 60))))))307 )))310 (defn colorful []311 (.getChild (worm-model) "worm-21"))313 (import jme3tools.converters.ImageToAwt)315 (import ij.ImagePlus)317 (defn triangle-indices318 "Get the triangle vertex indices of a given triangle from a given319 mesh."320 [#^Mesh mesh triangle-index]321 (let [indices (int-array 3)]322 (.getTriangle mesh triangle-index indices)323 (vec indices)))325 (defn uv-coord326 "Get the uv-coordinates of the vertex named by vertex-index"327 [#^Mesh mesh vertex-index]328 (let [UV-buffer329 (.getData330 (.getBuffer331 mesh332 VertexBuffer$Type/TexCoord))]333 (Vector2f.334 (.get UV-buffer (* vertex-index 2))335 (.get UV-buffer (+ 1 (* vertex-index 2))))))337 (defn touch-receptor-image338 "Return the touch-sensor distribution image in ImagePlus format."339 [#^Geometry obj]340 (let341 [mat (.getMaterial obj)342 texture343 (.getTextureValue344 (.getTextureParam345 mat346 MaterialHelper/TEXTURE_TYPE_DIFFUSE))347 im (.getImage texture)]348 (ImagePlus.349 "UV-map"350 (ImageToAwt/convert im false false 0))))353 (import ij.process.ImageProcessor)354 (import java.awt.image.BufferedImage)356 (defprotocol Frame357 (frame [this]))359 (extend-type BufferedImage360 Frame361 (frame [image]362 (merge363 (apply364 hash-map365 (interleave366 (doall (for [x (range (.getWidth image)) y (range (.getHeight image))]367 (vector x y)))368 (doall (for [x (range (.getWidth image)) y (range (.getHeight image))]369 (let [data (.getRGB image x y)]370 (hash-map :r (bit-shift-right (bit-and 0xff0000 data) 16)371 :g (bit-shift-right (bit-and 0x00ff00 data) 8)372 :b (bit-and 0x0000ff data)))))))373 {:width (.getWidth image) :height (.getHeight image)})))376 (extend-type ImagePlus377 Frame378 (frame [image+]379 (frame (.getBufferedImage image+))))381 (defn rgb->int [r g b]382 (+ (bit-shift-left r 16)383 (bit-shift-left g 8)384 b))388 (defn filter-pixels389 "List the coordinates of all pixels matching pred."390 [pred #^ImageProcessor ip]391 (let392 [width (.getWidth ip)393 height (.getHeight ip)]394 ((fn accumulate [x y matches]395 (cond396 (>= y height) matches397 (>= x width) (recur 0 (inc y) matches)398 (pred (.getPixel ip x y))399 (recur (inc x) y (conj matches (Vector2f. x y)))400 :else (recur (inc x) y matches)))401 0 0 [])))407 (defn filter-pixels*408 [pred #^ImageProcessor ip]409 (let410 [width (.getWidth ip)411 height (.getHeight ip)412 coords (ref [])413 process414 (fn [[start end]]415 (loop [i start]416 (if (<= i end)417 (do418 (let [column (rem i height)419 row (unchecked-divide i width)]420 (if (pred (.getPixel ip row column))421 (dosync (ref-set422 coords423 (conj @coords (Vector2f. column row)))))425 (recur (inc i)))))))426 ]429 (dorun430 (pmap process (partition431 2432 (conj (vec (range 0 (* width height) 100))433 (* width height)))))434 @coords))438 (comment439 ((->440 f441 (partial x)442 (partial y)443 (partial z))))445 (defn filter-pixels**446 [pred #^ImageProcessor ip]447 (let [width (.getWidth ip)448 height (.getHeight ip)]449 ((fn f [x1 x2 y1 y2]450 (println x1)451 (if452 (and453 (= x1 (dec x2))454 (= y1 (dec y2)))455 (if (pred (.getPixel ip x1 y1))456 [[x1 y1]]457 [])458 (let459 [xm (+ x1 (/ (- x2 x1) 2))460 ym (+ y1 (/ (- y2 y1) 2))]461 (apply concat462 (pvalues463 ;;(f x1 xm y1 ym)464 ;;(f xm x2 y1 ym)465 ;;(f x1 xm ym y2)466 (f xm x2 ym y2))))))467 0 width 0 height)))476 (defn white-coordinates*477 [#^ImageProcessor ip]478 (filter-pixels** #(== % -1) ip))481 (defn white-coordinates482 "List the coordinates of all the white pixels in an image."483 [#^ImageProcessor ip]484 (let [height (.getHeight ip)485 width (.getWidth ip)486 coords (transient [])]487 (dorun488 (for [x (range width)489 y (range height)]490 (let [pixel (.getPixel ip x y)]491 (if (= pixel -1)492 (conj! coords (Vector2f. x y))))))493 (persistent! coords)))502 (def white {:r 255, :g 255, :b 255})503 (def black {:r 0, :g 0, :b 0})506 (defn same-side? [p1 p2 ref p]507 (<=508 0509 (.dot510 (.cross (.subtract p2 p1) (.subtract p p1))511 (.cross (.subtract p2 p1) (.subtract ref p1)))))513 (defn inside-triangle?514 [vert-1 vert-2 vert-3 p]515 (and516 (same-side? vert-1 vert-2 vert-3 p)517 (same-side? vert-2 vert-3 vert-1 p)518 (same-side? vert-3 vert-1 vert-2 p)))521 (defn white? [color]522 (and523 (= (:r color) 255)524 (= (:b color) 255)525 (= (:g color) 255)))528 ;; for each triangle in the mesh,529 ;; get the normal to the triangle,530 ;; look at the UV touch map, restricted to that triangle,531 ;; get the positions of those touch sensors in geometry-relative532 ;; coordinates.533 (defn tactile-coords [#^Geometry obj]534 (let [mesh (.getMesh obj)535 num-triangles (.getTriangleCount mesh)536 num-verticies (.getVertexCount mesh)537 uv-coord (partial uv-coord mesh)538 triangle-indices (partial triangle-indices mesh)539 receptors (touch-receptor-image obj)540 ]541 (map542 (fn [[tri-1 tri-2 tri-3]]543 (let [width (.getWidth receptors)544 height (.getHeight receptors)545 uv-1 (uv-coord tri-1)546 uv-2 (uv-coord tri-2)547 uv-3 (uv-coord tri-3)548 x-coords (map #(.getX %) [uv-1 uv-2 uv-3])549 y-coords (map #(.getY %) [uv-1 uv-2 uv-3])550 max-x (Math/ceil (* width (apply max x-coords)))551 min-x (Math/floor (* width (apply min x-coords)))552 max-y (Math/ceil (* height (apply max y-coords)))553 min-y (Math/floor (* height (apply min y-coords)))555 image-1 (Vector2f. (* width (.getX uv-1))556 (* height (.getY uv-1)))557 image-2 (Vector2f. (* width (.getX uv-2))558 (* height (.getY uv-2)))559 image-3 (Vector2f. (* width (.getX uv-3))560 (* height (.getY uv-3)))561 left-corner562 (Vector2f. min-x min-y)564 ]566 (.setRoi receptors min-x min-y (- max-x min-x) (- max-y min-y))567 (let [processor (.crop (.getProcessor receptors))568 image (frame (.getBufferedImage processor))]569 (with-meta570 (filter-keys571 (fn [[x y]]572 (inside-triangle?573 (.subtract image-1 left-corner)574 (.subtract image-2 left-corner)575 (.subtract image-3 left-corner)576 (Vector2f. x y)))579 (filter-vals white? image))580 {:image581 (comment582 (.getBufferedImage583 (doto processor584 (.flipVertical))))585 }586 ))587 )) (map triangle-indices (range num-triangles)))))595 (defn all-names []596 (concat597 (re-split #"\n" (slurp (file-str598 "/home/r/proj/names/dist.female.first")))599 (re-split #"\n" (slurp (file-str600 "/home/r/proj/names/dist.male.first")))601 (re-split #"\n" (slurp (file-str602 "/home/r/proj/names/dist.all.last")))))612 (defrecord LulzLoader [])613 (defprotocol Lulzable (load-lulz [this]))614 (extend-type LulzLoader615 Lulzable616 (load-lulz [this] (println "the lulz have arrived!")))619 (defn world-setup [joint]620 (let [joint-position (Vector3f. 0 0 0)621 joint-rotation622 (.toRotationMatrix623 (.mult624 (doto (Quaternion.)625 (.fromAngleAxis626 (* 1 (/ Math/PI 4))627 (Vector3f. -1 0 0)))628 (doto (Quaternion.)629 (.fromAngleAxis630 (* 1 (/ Math/PI 2))631 (Vector3f. 0 0 1)))))632 top-position (.mult joint-rotation (Vector3f. 8 0 0))634 origin (doto635 (sphere 0.1 :physical? false :color ColorRGBA/Cyan636 :position top-position))637 top (doto638 (sphere 0.1 :physical? false :color ColorRGBA/Yellow639 :position top-position)641 (.addControl642 (RigidBodyControl.643 (CapsuleCollisionShape. 0.5 1.5 1) (float 20))))644 bottom (doto645 (sphere 0.1 :physical? false :color ColorRGBA/DarkGray646 :position (Vector3f. 0 0 0))647 (.addControl648 (RigidBodyControl.649 (CapsuleCollisionShape. 0.5 1.5 1) (float 0))))650 table (box 10 2 10 :position (Vector3f. 0 -20 0)651 :color ColorRGBA/Gray :mass 0)652 a (.getControl top RigidBodyControl)653 b (.getControl bottom RigidBodyControl)]655 (cond656 (= joint :cone)658 (doto (ConeJoint.659 a b660 (world-to-local top joint-position)661 (world-to-local bottom joint-position)662 joint-rotation663 joint-rotation664 )667 (.setLimit (* (/ 10) Math/PI)668 (* (/ 4) Math/PI)669 0)))670 [origin top bottom table]))672 (defn test-joint [joint]673 (let [[origin top bottom floor] (world-setup joint)674 control (.getControl top RigidBodyControl)675 move-up? (atom false)676 move-down? (atom false)677 move-left? (atom false)678 move-right? (atom false)679 roll-left? (atom false)680 roll-right? (atom false)681 timer (atom 0)]683 (world684 (nodify [top bottom floor origin])685 (merge standard-debug-controls686 {"key-r" (fn [_ pressed?] (reset! move-up? pressed?))687 "key-t" (fn [_ pressed?] (reset! move-down? pressed?))688 "key-f" (fn [_ pressed?] (reset! move-left? pressed?))689 "key-g" (fn [_ pressed?] (reset! move-right? pressed?))690 "key-v" (fn [_ pressed?] (reset! roll-left? pressed?))691 "key-b" (fn [_ pressed?] (reset! roll-right? pressed?))})693 (fn [world]694 (light-up-everything world)695 (enable-debug world)696 (set-gravity world (Vector3f. 0 0 0))697 )699 (fn [world _]700 (if (zero? (rem (swap! timer inc) 100))701 (do702 ;; (println-repl @timer)703 (.attachChild (.getRootNode world)704 (sphere 0.05 :color ColorRGBA/Yellow705 :position (.getWorldTranslation top)706 :physical? false))707 (.attachChild (.getRootNode world)708 (sphere 0.05 :color ColorRGBA/LightGray709 :position (.getWorldTranslation bottom)710 :physical? false))))712 (if @move-up?713 (.applyTorque control714 (.mult (.getPhysicsRotation control)715 (Vector3f. 0 0 10))))716 (if @move-down?717 (.applyTorque control718 (.mult (.getPhysicsRotation control)719 (Vector3f. 0 0 -10))))720 (if @move-left?721 (.applyTorque control722 (.mult (.getPhysicsRotation control)723 (Vector3f. 0 10 0))))724 (if @move-right?725 (.applyTorque control726 (.mult (.getPhysicsRotation control)727 (Vector3f. 0 -10 0))))728 (if @roll-left?729 (.applyTorque control730 (.mult (.getPhysicsRotation control)731 (Vector3f. -1 0 0))))732 (if @roll-right?733 (.applyTorque control734 (.mult (.getPhysicsRotation control)735 (Vector3f. 1 0 0))))))))739 #+end_src741 #+results: body-1742 : #'cortex.silly/test-joint745 * COMMENT purgatory746 #+begin_src clojure747 (defn bullet-trans []748 (let [obj-a (sphere 0.5 :color ColorRGBA/Red749 :position (Vector3f. -10 5 0))750 obj-b (sphere 0.5 :color ColorRGBA/Blue751 :position (Vector3f. -10 -5 0)752 :mass 0)753 control-a (.getControl obj-a RigidBodyControl)754 control-b (.getControl obj-b RigidBodyControl)755 swivel756 (.toRotationMatrix757 (doto (Quaternion.)758 (.fromAngleAxis (/ Math/PI 2)759 Vector3f/UNIT_X)))]760 (doto761 (ConeJoint.762 control-a control-b763 (Vector3f. 0 5 0)764 (Vector3f. 0 -5 0)765 swivel swivel)766 (.setLimit (* 0.6 (/ Math/PI 4))767 (/ Math/PI 4)768 (* Math/PI 0.8)))769 (world (nodify770 [obj-a obj-b])771 standard-debug-controls772 enable-debug773 no-op)))776 (defn bullet-trans* []777 (let [obj-a (box 1.5 0.5 0.5 :color ColorRGBA/Red778 :position (Vector3f. 5 0 0)779 :mass 90)780 obj-b (sphere 0.5 :color ColorRGBA/Blue781 :position (Vector3f. -5 0 0)782 :mass 0)783 control-a (.getControl obj-a RigidBodyControl)784 control-b (.getControl obj-b RigidBodyControl)785 move-up? (atom nil)786 move-down? (atom nil)787 move-left? (atom nil)788 move-right? (atom nil)789 roll-left? (atom nil)790 roll-right? (atom nil)791 force 100792 swivel793 (.toRotationMatrix794 (doto (Quaternion.)795 (.fromAngleAxis (/ Math/PI 2)796 Vector3f/UNIT_X)))797 x-move798 (doto (Matrix3f.)799 (.fromStartEndVectors Vector3f/UNIT_X800 (.normalize (Vector3f. 1 1 0))))802 timer (atom 0)]803 (doto804 (ConeJoint.805 control-a control-b806 (Vector3f. -8 0 0)807 (Vector3f. 2 0 0)808 ;;swivel swivel809 ;;Matrix3f/IDENTITY Matrix3f/IDENTITY810 x-move Matrix3f/IDENTITY811 )812 (.setCollisionBetweenLinkedBodys false)813 (.setLimit (* 1 (/ Math/PI 4)) ;; twist814 (* 1 (/ Math/PI 4)) ;; swing span in X-Y plane815 (* 0 (/ Math/PI 4)))) ;; swing span in Y-Z plane816 (world (nodify817 [obj-a obj-b])818 (merge standard-debug-controls819 {"key-r" (fn [_ pressed?] (reset! move-up? pressed?))820 "key-t" (fn [_ pressed?] (reset! move-down? pressed?))821 "key-f" (fn [_ pressed?] (reset! move-left? pressed?))822 "key-g" (fn [_ pressed?] (reset! move-right? pressed?))823 "key-v" (fn [_ pressed?] (reset! roll-left? pressed?))824 "key-b" (fn [_ pressed?] (reset! roll-right? pressed?))})826 (fn [world]827 (enable-debug world)828 (set-gravity world Vector3f/ZERO)829 )831 (fn [world _]833 (if @move-up?834 (.applyForce control-a835 (Vector3f. force 0 0)836 (Vector3f. 0 0 0)))837 (if @move-down?838 (.applyForce control-a839 (Vector3f. (- force) 0 0)840 (Vector3f. 0 0 0)))841 (if @move-left?842 (.applyForce control-a843 (Vector3f. 0 force 0)844 (Vector3f. 0 0 0)))845 (if @move-right?846 (.applyForce control-a847 (Vector3f. 0 (- force) 0)848 (Vector3f. 0 0 0)))850 (if @roll-left?851 (.applyForce control-a852 (Vector3f. 0 0 force)853 (Vector3f. 0 0 0)))854 (if @roll-right?855 (.applyForce control-a856 (Vector3f. 0 0 (- force))857 (Vector3f. 0 0 0)))859 (if (zero? (rem (swap! timer inc) 100))860 (.attachChild861 (.getRootNode world)862 (sphere 0.05 :color ColorRGBA/Yellow863 :physical? false :position864 (.getWorldTranslation obj-a)))))865 )866 ))870 #+end_src873 * COMMENT generate source874 #+begin_src clojure :tangle ../src/cortex/silly.clj875 <<body-1>>876 #+end_src