rlm@73: #+title: First attempt at a creature! rlm@73: #+author: Robert McIntyre rlm@73: #+email: rlm@mit.edu rlm@73: #+description: rlm@73: #+keywords: simulation, jMonkeyEngine3, clojure rlm@73: #+SETUPFILE: ../../aurellem/org/setup.org rlm@73: #+INCLUDE: ../../aurellem/org/level-0.org rlm@73: rlm@129: rlm@129: rlm@99: rlm@73: * Intro rlm@73: So far, I've made the following senses -- rlm@73: - Vision rlm@73: - Hearing rlm@73: - Touch rlm@73: - Proprioception rlm@73: rlm@73: And one effector: rlm@73: - Movement rlm@73: rlm@73: However, the code so far has only enabled these senses, but has not rlm@73: actually implemented them. For example, there is still a lot of work rlm@73: to be done for vision. I need to be able to create an /eyeball/ in rlm@73: simulation that can be moved around and see the world from different rlm@73: angles. I also need to determine weather to use log-polar or cartesian rlm@73: for the visual input, and I need to determine how/wether to rlm@73: disceritise the visual input. rlm@73: rlm@73: I also want to be able to visualize both the sensors and the rlm@104: effectors in pretty pictures. This semi-retarted creature will be my rlm@73: first attempt at bringing everything together. rlm@73: rlm@73: * The creature's body rlm@73: rlm@73: Still going to do an eve-like body in blender, but due to problems rlm@104: importing the joints, etc into jMonkeyEngine3, I'm going to do all rlm@73: the connecting here in clojure code, using the names of the individual rlm@73: components and trial and error. Later, I'll maybe make some sort of rlm@73: creature-building modifications to blender that support whatever rlm@158: discritized senses I'm going to make. rlm@73: rlm@73: #+name: body-1 rlm@73: #+begin_src clojure rlm@73: (ns cortex.silly rlm@73: "let's play!" rlm@73: {:author "Robert McIntyre"}) rlm@73: rlm@73: ;; TODO remove this! rlm@73: (require 'cortex.import) rlm@73: (cortex.import/mega-import-jme3) rlm@158: (use '(cortex world util body hearing touch vision sense rlm@158: proprioception movement)) rlm@73: rlm@73: (rlm.rlm-commands/help) rlm@99: (import java.awt.image.BufferedImage) rlm@99: (import javax.swing.JPanel) rlm@99: (import javax.swing.SwingUtilities) rlm@99: (import java.awt.Dimension) rlm@99: (import javax.swing.JFrame) rlm@99: (import java.awt.Dimension) rlm@106: (import com.aurellem.capture.RatchetTimer) rlm@99: (declare joint-create) rlm@108: (use 'clojure.contrib.def) rlm@73: rlm@73: (defn load-blender-model rlm@73: "Load a .blend file using an asset folder relative path." rlm@73: [^String model] rlm@73: (.loadModel rlm@73: (doto (asset-manager) rlm@73: (.registerLoader BlenderModelLoader (into-array String ["blend"]))) rlm@73: model)) rlm@73: rlm@78: (defn blender-to-jme rlm@78: "Convert from Blender coordinates to JME coordinates" rlm@78: [#^Vector3f in] rlm@78: (Vector3f. (.getX in) rlm@78: (.getZ in) rlm@78: (- (.getY in)))) rlm@74: rlm@96: rlm@87: (defmulti joint-dispatch rlm@87: "Translate blender pseudo-joints into real JME joints." rlm@88: (fn [constraints & _] rlm@87: (:type constraints))) rlm@87: rlm@87: (defmethod joint-dispatch :point rlm@87: [constraints control-a control-b pivot-a pivot-b rotation] rlm@87: (println-repl "creating POINT2POINT joint") rlm@130: ;; bullet's point2point joints are BROKEN, so we must use the rlm@130: ;; generic 6DOF joint instead of an actual Point2Point joint! rlm@130: rlm@130: ;; should be able to do this: rlm@130: (comment rlm@130: (Point2PointJoint. rlm@130: control-a rlm@130: control-b rlm@130: pivot-a rlm@130: pivot-b)) rlm@130: rlm@130: ;; but instead we must do this: rlm@130: (println-repl "substuting 6DOF joint for POINT2POINT joint!") rlm@130: (doto rlm@130: (SixDofJoint. rlm@130: control-a rlm@130: control-b rlm@130: pivot-a rlm@130: pivot-b rlm@130: false) rlm@130: (.setLinearLowerLimit Vector3f/ZERO) rlm@130: (.setLinearUpperLimit Vector3f/ZERO) rlm@130: ;;(.setAngularLowerLimit (Vector3f. 1 1 1)) rlm@130: ;;(.setAngularUpperLimit (Vector3f. 0 0 0)) rlm@130: rlm@130: )) rlm@130: rlm@87: rlm@87: (defmethod joint-dispatch :hinge rlm@87: [constraints control-a control-b pivot-a pivot-b rotation] rlm@87: (println-repl "creating HINGE joint") rlm@87: (let [axis rlm@87: (if-let rlm@87: [axis (:axis constraints)] rlm@87: axis rlm@87: Vector3f/UNIT_X) rlm@87: [limit-1 limit-2] (:limit constraints) rlm@87: hinge-axis rlm@87: (.mult rlm@87: rotation rlm@87: (blender-to-jme axis))] rlm@87: (doto rlm@87: (HingeJoint. rlm@87: control-a rlm@87: control-b rlm@87: pivot-a rlm@87: pivot-b rlm@87: hinge-axis rlm@87: hinge-axis) rlm@87: (.setLimit limit-1 limit-2)))) rlm@87: rlm@87: (defmethod joint-dispatch :cone rlm@87: [constraints control-a control-b pivot-a pivot-b rotation] rlm@87: (let [limit-xz (:limit-xz constraints) rlm@87: limit-xy (:limit-xy constraints) rlm@87: twist (:twist constraints)] rlm@87: rlm@87: (println-repl "creating CONE joint") rlm@87: (println-repl rotation) rlm@87: (println-repl rlm@87: "UNIT_X --> " (.mult rotation (Vector3f. 1 0 0))) rlm@87: (println-repl rlm@87: "UNIT_Y --> " (.mult rotation (Vector3f. 0 1 0))) rlm@87: (println-repl rlm@87: "UNIT_Z --> " (.mult rotation (Vector3f. 0 0 1))) rlm@87: (doto rlm@87: (ConeJoint. rlm@87: control-a rlm@87: control-b rlm@87: pivot-a rlm@87: pivot-b rlm@87: rotation rlm@87: rotation) rlm@87: (.setLimit (float limit-xz) rlm@87: (float limit-xy) rlm@87: (float twist))))) rlm@87: rlm@88: (defn connect rlm@87: "here are some examples: rlm@87: {:type :point} rlm@87: {:type :hinge :limit [0 (/ Math/PI 2)] :axis (Vector3f. 0 1 0)} rlm@87: (:axis defaults to (Vector3f. 1 0 0) if not provided for hinge joints) rlm@87: rlm@89: {:type :cone :limit-xz 0] rlm@89: :limit-xy 0] rlm@89: :twist 0]} (use XZY rotation mode in blender!)" rlm@87: [#^Node obj-a #^Node obj-b #^Node joint] rlm@87: (let [control-a (.getControl obj-a RigidBodyControl) rlm@87: control-b (.getControl obj-b RigidBodyControl) rlm@87: joint-center (.getWorldTranslation joint) rlm@87: joint-rotation (.toRotationMatrix (.getWorldRotation joint)) rlm@87: pivot-a (world-to-local obj-a joint-center) rlm@87: pivot-b (world-to-local obj-b joint-center)] rlm@89: rlm@87: (if-let [constraints rlm@87: (map-vals rlm@87: eval rlm@87: (read-string rlm@87: (meta-data joint "joint")))] rlm@89: ;; A side-effect of creating a joint registers rlm@89: ;; it with both physics objects which in turn rlm@89: ;; will register the joint with the physics system rlm@89: ;; when the simulation is started. rlm@87: (do rlm@87: (println-repl "creating joint between" rlm@87: (.getName obj-a) "and" (.getName obj-b)) rlm@87: (joint-dispatch constraints rlm@87: control-a control-b rlm@87: pivot-a pivot-b rlm@87: joint-rotation)) rlm@87: (println-repl "could not find joint meta-data!")))) rlm@87: rlm@130: rlm@130: rlm@130: rlm@78: (defn assemble-creature [#^Node pieces joints] rlm@78: (dorun rlm@78: (map rlm@78: (fn [geom] rlm@78: (let [physics-control rlm@78: (RigidBodyControl. rlm@78: (HullCollisionShape. rlm@78: (.getMesh geom)) rlm@78: (if-let [mass (meta-data geom "mass")] rlm@78: (do rlm@78: (println-repl rlm@78: "setting" (.getName geom) "mass to" (float mass)) rlm@78: (float mass)) rlm@78: (float 1)))] rlm@78: rlm@78: (.addControl geom physics-control))) rlm@78: (filter #(isa? (class %) Geometry ) rlm@78: (node-seq pieces)))) rlm@78: (dorun rlm@78: (map rlm@78: (fn [joint] rlm@133: (let [[obj-a obj-b] (joint-targets pieces joint)] rlm@88: (connect obj-a obj-b joint))) rlm@78: joints)) rlm@78: pieces) rlm@74: rlm@116: (declare blender-creature) rlm@74: rlm@78: (def hand "Models/creature1/one.blend") rlm@74: rlm@78: (def worm "Models/creature1/try-again.blend") rlm@78: rlm@90: (defn worm-model [] (load-blender-model worm)) rlm@90: rlm@80: (defn x-ray [#^ColorRGBA color] rlm@80: (doto (Material. (asset-manager) rlm@80: "Common/MatDefs/Misc/Unshaded.j3md") rlm@80: (.setColor "Color" color) rlm@80: (-> (.getAdditionalRenderState) rlm@80: (.setDepthTest false)))) rlm@80: rlm@91: (defn colorful [] rlm@91: (.getChild (worm-model) "worm-21")) rlm@90: rlm@90: (import jme3tools.converters.ImageToAwt) rlm@90: rlm@90: (import ij.ImagePlus) rlm@90: rlm@94: rlm@109: rlm@111: (defn test-eye [] rlm@117: (.getChild rlm@117: (.getChild (worm-model) "eyes") rlm@117: "eye")) rlm@111: rlm@111: rlm@123: rlm@128: ;; lower level --- nodes rlm@128: ;; closest-node "parse/compile-x" -> makes organ, which is spatial, fn pair rlm@128: rlm@128: ;; higher level -- organs rlm@128: ;; rlm@128: rlm@128: ;; higher level --- sense/effector rlm@128: ;; these are the functions that provide world i/o, chinese-room style rlm@128: rlm@128: rlm@134: rlm@116: rlm@116: (defn blender-creature rlm@116: "Return a creature with all joints in place." rlm@116: [blender-path] rlm@116: (let [model (load-blender-model blender-path) rlm@134: joints (creature-joints model)] rlm@134: (assemble-creature model joints))) rlm@116: rlm@126: (defn gray-scale [num] rlm@126: (+ num rlm@126: (bit-shift-left num 8) rlm@126: (bit-shift-left num 16))) rlm@126: rlm@130: (defn debug-touch-window rlm@103: "creates function that offers a debug view of sensor data" rlm@103: [] rlm@103: (let [vi (view-image)] rlm@103: (fn rlm@103: [[coords sensor-data]] rlm@103: (let [image (points->image coords)] rlm@103: (dorun rlm@103: (for [i (range (count coords))] rlm@103: (.setRGB image ((coords i) 0) ((coords i) 1) rlm@126: (gray-scale (sensor-data i))))) rlm@126: rlm@126: rlm@103: (vi image))))) rlm@103: rlm@118: (defn debug-vision-window rlm@118: "creates function that offers a debug view of sensor data" rlm@118: [] rlm@118: (let [vi (view-image)] rlm@118: (fn rlm@118: [[coords sensor-data]] rlm@118: (let [image (points->image coords)] rlm@118: (dorun rlm@118: (for [i (range (count coords))] rlm@118: (.setRGB image ((coords i) 0) ((coords i) 1) rlm@118: (sensor-data i)))) rlm@118: (vi image))))) rlm@118: rlm@123: (defn debug-hearing-window rlm@123: "view audio data" rlm@123: [height] rlm@123: (let [vi (view-image)] rlm@123: (fn [[coords sensor-data]] rlm@123: (let [image (BufferedImage. (count coords) height rlm@123: BufferedImage/TYPE_INT_RGB)] rlm@123: (dorun rlm@123: (for [x (range (count coords))] rlm@123: (dorun rlm@123: (for [y (range height)] rlm@123: (let [raw-sensor (sensor-data x)] rlm@126: (.setRGB image x y (gray-scale raw-sensor))))))) rlm@126: rlm@123: (vi image))))) rlm@123: rlm@106: (defn test-creature [thing] rlm@106: (let [x-axis rlm@106: (box 1 0.01 0.01 :physical? false :color ColorRGBA/Red) rlm@106: y-axis rlm@106: (box 0.01 1 0.01 :physical? false :color ColorRGBA/Green) rlm@106: z-axis rlm@106: (box 0.01 0.01 1 :physical? false :color ColorRGBA/Blue) rlm@106: creature (blender-creature thing) rlm@106: touch-nerves (touch creature) rlm@130: touch-debug-windows (map (fn [_] (debug-touch-window)) touch-nerves) rlm@121: [init-vision-fns vision-data] (vision creature) rlm@121: vision-debug (map (fn [_] (debug-vision-window)) vision-data) rlm@118: me (sphere 0.5 :color ColorRGBA/Blue :physical? false) rlm@123: [init-hearing-fns hearing-senses] (hearing creature) rlm@123: hearing-windows (map (fn [_] (debug-hearing-window 50)) rlm@123: hearing-senses) rlm@124: bell (AudioNode. (asset-manager) rlm@128: "Sounds/pure.wav" false) rlm@130: prop (proprioception creature) rlm@135: prop-debug (proprioception-debug-window) rlm@148: rlm@148: muscle-fns (enable-muscles creature) rlm@123: ;; dream rlm@123: rlm@106: ] rlm@143: rlm@143: rlm@143: (apply rlm@143: world rlm@143: (with-movement rlm@143: (.getChild creature "worm-21") rlm@143: ["key-r" "key-t" rlm@143: "key-f" "key-g" rlm@143: "key-v" "key-b"] rlm@143: [10 10 10 10 1 1] rlm@143: [(nodify [creature rlm@143: (box 10 2 10 :position (Vector3f. 0 -9 0) rlm@143: :color ColorRGBA/Gray :mass 0) rlm@143: x-axis y-axis z-axis rlm@143: me rlm@143: ]) rlm@143: (merge standard-debug-controls rlm@143: {"key-return" rlm@143: (fn [_ value] rlm@143: (if value rlm@143: (do rlm@143: (println-repl "play-sound") rlm@148: (.play bell)))) rlm@148: "key-h" rlm@148: (fn [_ value] rlm@148: (if value rlm@148: (do rlm@148: (println-repl "muscle activating!") rlm@148: ((first muscle-fns) 199)))) rlm@148: rlm@148: }) rlm@143: (fn [world] rlm@143: (light-up-everything world) rlm@143: (enable-debug world) rlm@143: (dorun (map #(% world) init-vision-fns)) rlm@143: (dorun (map #(% world) init-hearing-fns)) rlm@143: rlm@143: (add-eye world rlm@143: (attach-eye creature (test-eye)) rlm@143: (comp (view-image) BufferedImage!)) rlm@143: rlm@143: (add-eye world (.getCamera world) no-op) rlm@145: ;;(set-gravity world (Vector3f. 0 0 0)) rlm@143: ;;(com.aurellem.capture.Capture/captureVideo rlm@143: ;; world (file-str "/home/r/proj/ai-videos/hand")) rlm@143: ;;(.setTimer world (RatchetTimer. 60)) rlm@143: (speed-up world) rlm@148: (set-gravity world (Vector3f. 0 0 0)) rlm@143: ) rlm@143: (fn [world tpf] rlm@143: ;;(dorun rlm@143: ;; (map #(%1 %2) touch-nerves (repeat (.getRootNode world)))) rlm@143: rlm@143: (prop-debug (prop)) rlm@143: rlm@143: (dorun rlm@143: (map #(%1 (%2 (.getRootNode world))) rlm@143: touch-debug-windows touch-nerves)) rlm@143: rlm@143: (dorun rlm@143: (map #(%1 (%2)) rlm@143: vision-debug vision-data)) rlm@143: (dorun rlm@143: (map #(%1 (%2)) hearing-windows hearing-senses)) rlm@143: rlm@143: rlm@143: ;;(println-repl (vision-data)) rlm@143: (.setLocalTranslation me (.getLocation (.getCamera world))) rlm@143: rlm@143: rlm@143: )] rlm@106: ;;(let [timer (atom 0)] rlm@106: ;; (fn [_ _] rlm@106: ;; (swap! timer inc) rlm@106: ;; (if (= (rem @timer 60) 0) rlm@106: ;; (println-repl (float (/ @timer 60)))))) rlm@143: )))) rlm@83: rlm@109: rlm@116: rlm@116: ;; the camera will stay in its initial position/rotation with relation rlm@116: ;; to the spatial. rlm@116: rlm@116: rlm@117: (defn follow-test rlm@117: "show a camera that stays in the same relative position to a blue cube." rlm@117: [] rlm@116: (let [camera-pos (Vector3f. 0 30 0) rlm@116: rock (box 1 1 1 :color ColorRGBA/Blue rlm@116: :position (Vector3f. 0 10 0) rlm@116: :mass 30 rlm@116: ) rlm@118: rot (.getWorldRotation rock) rlm@116: rlm@116: table (box 3 1 10 :color ColorRGBA/Gray :mass 0 rlm@116: :position (Vector3f. 0 -3 0))] rlm@116: rlm@116: (world rlm@116: (nodify [rock table]) rlm@116: standard-debug-controls rlm@116: (fn [world] rlm@116: (let rlm@116: [cam (doto (.clone (.getCamera world)) rlm@116: (.setLocation camera-pos) rlm@116: (.lookAt Vector3f/ZERO rlm@116: Vector3f/UNIT_X))] rlm@123: (bind-sense rock cam) rlm@116: rlm@116: (.setTimer world (RatchetTimer. 60)) rlm@116: (add-eye world cam (comp (view-image) BufferedImage!)) rlm@116: (add-eye world (.getCamera world) no-op)) rlm@116: ) rlm@118: (fn [_ _] (println-repl rot))))) rlm@116: rlm@118: rlm@123: rlm@87: #+end_src rlm@83: rlm@87: #+results: body-1 rlm@133: : #'cortex.silly/follow-test rlm@78: rlm@78: rlm@78: * COMMENT purgatory rlm@78: #+begin_src clojure rlm@74: rlm@77: (defn bullet-trans* [] rlm@77: (let [obj-a (box 1.5 0.5 0.5 :color ColorRGBA/Red rlm@77: :position (Vector3f. 5 0 0) rlm@77: :mass 90) rlm@77: obj-b (sphere 0.5 :color ColorRGBA/Blue rlm@77: :position (Vector3f. -5 0 0) rlm@77: :mass 0) rlm@77: control-a (.getControl obj-a RigidBodyControl) rlm@77: control-b (.getControl obj-b RigidBodyControl) rlm@77: move-up? (atom nil) rlm@77: move-down? (atom nil) rlm@77: move-left? (atom nil) rlm@77: move-right? (atom nil) rlm@77: roll-left? (atom nil) rlm@77: roll-right? (atom nil) rlm@77: force 100 rlm@77: swivel rlm@77: (.toRotationMatrix rlm@77: (doto (Quaternion.) rlm@77: (.fromAngleAxis (/ Math/PI 2) rlm@77: Vector3f/UNIT_X))) rlm@77: x-move rlm@77: (doto (Matrix3f.) rlm@77: (.fromStartEndVectors Vector3f/UNIT_X rlm@77: (.normalize (Vector3f. 1 1 0)))) rlm@77: rlm@77: timer (atom 0)] rlm@77: (doto rlm@77: (ConeJoint. rlm@77: control-a control-b rlm@77: (Vector3f. -8 0 0) rlm@77: (Vector3f. 2 0 0) rlm@77: ;;swivel swivel rlm@77: ;;Matrix3f/IDENTITY Matrix3f/IDENTITY rlm@77: x-move Matrix3f/IDENTITY rlm@77: ) rlm@77: (.setCollisionBetweenLinkedBodys false) rlm@77: (.setLimit (* 1 (/ Math/PI 4)) ;; twist rlm@77: (* 1 (/ Math/PI 4)) ;; swing span in X-Y plane rlm@77: (* 0 (/ Math/PI 4)))) ;; swing span in Y-Z plane rlm@77: (world (nodify rlm@77: [obj-a obj-b]) rlm@77: (merge standard-debug-controls rlm@77: {"key-r" (fn [_ pressed?] (reset! move-up? pressed?)) rlm@77: "key-t" (fn [_ pressed?] (reset! move-down? pressed?)) rlm@77: "key-f" (fn [_ pressed?] (reset! move-left? pressed?)) rlm@77: "key-g" (fn [_ pressed?] (reset! move-right? pressed?)) rlm@77: "key-v" (fn [_ pressed?] (reset! roll-left? pressed?)) rlm@77: "key-b" (fn [_ pressed?] (reset! roll-right? pressed?))}) rlm@77: rlm@77: (fn [world] rlm@77: (enable-debug world) rlm@77: (set-gravity world Vector3f/ZERO) rlm@77: ) rlm@77: rlm@77: (fn [world _] rlm@77: rlm@77: (if @move-up? rlm@77: (.applyForce control-a rlm@77: (Vector3f. force 0 0) rlm@77: (Vector3f. 0 0 0))) rlm@77: (if @move-down? rlm@77: (.applyForce control-a rlm@77: (Vector3f. (- force) 0 0) rlm@77: (Vector3f. 0 0 0))) rlm@77: (if @move-left? rlm@77: (.applyForce control-a rlm@77: (Vector3f. 0 force 0) rlm@77: (Vector3f. 0 0 0))) rlm@77: (if @move-right? rlm@77: (.applyForce control-a rlm@77: (Vector3f. 0 (- force) 0) rlm@77: (Vector3f. 0 0 0))) rlm@77: rlm@77: (if @roll-left? rlm@77: (.applyForce control-a rlm@77: (Vector3f. 0 0 force) rlm@77: (Vector3f. 0 0 0))) rlm@77: (if @roll-right? rlm@77: (.applyForce control-a rlm@77: (Vector3f. 0 0 (- force)) rlm@77: (Vector3f. 0 0 0))) rlm@77: rlm@77: (if (zero? (rem (swap! timer inc) 100)) rlm@77: (.attachChild rlm@77: (.getRootNode world) rlm@77: (sphere 0.05 :color ColorRGBA/Yellow rlm@77: :physical? false :position rlm@77: (.getWorldTranslation obj-a))))) rlm@77: ) rlm@77: )) rlm@77: rlm@106: (defn test-joint [joint] rlm@106: (let [[origin top bottom floor] (world-setup joint) rlm@106: control (.getControl top RigidBodyControl) rlm@106: move-up? (atom false) rlm@106: move-down? (atom false) rlm@106: move-left? (atom false) rlm@106: move-right? (atom false) rlm@106: roll-left? (atom false) rlm@106: roll-right? (atom false) rlm@106: timer (atom 0)] rlm@106: rlm@106: (world rlm@106: (nodify [top bottom floor origin]) rlm@106: (merge standard-debug-controls rlm@106: {"key-r" (fn [_ pressed?] (reset! move-up? pressed?)) rlm@106: "key-t" (fn [_ pressed?] (reset! move-down? pressed?)) rlm@106: "key-f" (fn [_ pressed?] (reset! move-left? pressed?)) rlm@106: "key-g" (fn [_ pressed?] (reset! move-right? pressed?)) rlm@106: "key-v" (fn [_ pressed?] (reset! roll-left? pressed?)) rlm@106: "key-b" (fn [_ pressed?] (reset! roll-right? pressed?))}) rlm@106: rlm@106: (fn [world] rlm@106: (light-up-everything world) rlm@106: (enable-debug world) rlm@106: (set-gravity world (Vector3f. 0 0 0)) rlm@106: ) rlm@106: rlm@106: (fn [world _] rlm@106: (if (zero? (rem (swap! timer inc) 100)) rlm@106: (do rlm@106: ;; (println-repl @timer) rlm@106: (.attachChild (.getRootNode world) rlm@106: (sphere 0.05 :color ColorRGBA/Yellow rlm@106: :position (.getWorldTranslation top) rlm@106: :physical? false)) rlm@106: (.attachChild (.getRootNode world) rlm@106: (sphere 0.05 :color ColorRGBA/LightGray rlm@106: :position (.getWorldTranslation bottom) rlm@106: :physical? false)))) rlm@106: rlm@106: (if @move-up? rlm@106: (.applyTorque control rlm@106: (.mult (.getPhysicsRotation control) rlm@106: (Vector3f. 0 0 10)))) rlm@106: (if @move-down? rlm@106: (.applyTorque control rlm@106: (.mult (.getPhysicsRotation control) rlm@106: (Vector3f. 0 0 -10)))) rlm@106: (if @move-left? rlm@106: (.applyTorque control rlm@106: (.mult (.getPhysicsRotation control) rlm@106: (Vector3f. 0 10 0)))) rlm@106: (if @move-right? rlm@106: (.applyTorque control rlm@106: (.mult (.getPhysicsRotation control) rlm@106: (Vector3f. 0 -10 0)))) rlm@106: (if @roll-left? rlm@106: (.applyTorque control rlm@106: (.mult (.getPhysicsRotation control) rlm@106: (Vector3f. -1 0 0)))) rlm@106: (if @roll-right? rlm@106: (.applyTorque control rlm@106: (.mult (.getPhysicsRotation control) rlm@106: (Vector3f. 1 0 0)))))))) rlm@99: #+end_src rlm@99: rlm@99: rlm@99: * COMMENT generate source rlm@99: #+begin_src clojure :tangle ../src/cortex/silly.clj rlm@99: <> rlm@99: #+end_src rlm@99: rlm@99: rlm@94: rlm@94: