# HG changeset patch # User Robert McIntyre # Date 1328380185 25200 # Node ID deac7b708750e20030e96bcb7b9a6be6a634cc91 # Parent 66fbab414d45bf1d186a2ad15e55dccbf15d6395 cleaned up test-creature.org and renamed to integreation.org. diff -r 66fbab414d45 -r deac7b708750 org/integration.org --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org/integration.org Sat Feb 04 11:29:45 2012 -0700 @@ -0,0 +1,347 @@ +#+title: First attempt at a creature! +#+author: Robert McIntyre +#+email: rlm@mit.edu +#+description: +#+keywords: simulation, jMonkeyEngine3, clojure +#+SETUPFILE: ../../aurellem/org/setup.org +#+INCLUDE: ../../aurellem/org/level-0.org + + + + +* Intro +So far, I've made the following senses -- + - Vision + - Hearing + - Touch + - Proprioception + +And one effector: + - Movement + +However, the code so far has only enabled these senses, but has not +actually implemented them. For example, there is still a lot of work +to be done for vision. I need to be able to create an /eyeball/ in +simulation that can be moved around and see the world from different +angles. I also need to determine weather to use log-polar or cartesian +for the visual input, and I need to determine how/wether to +disceritise the visual input. + +I also want to be able to visualize both the sensors and the +effectors in pretty pictures. This semi-retarted creature will be my +first attempt at bringing everything together. + +* The creature's body + +Still going to do an eve-like body in blender, but due to problems +importing the joints, etc into jMonkeyEngine3, I'm going to do all +the connecting here in clojure code, using the names of the individual +components and trial and error. Later, I'll maybe make some sort of +creature-building modifications to blender that support whatever +discritized senses I'm going to make. + +#+name: integration +#+begin_src clojure +(ns cortex.integration + "let's play!" + {:author "Robert McIntyre"} + (:use (cortex world util body + hearing touch vision sense proprioception movement)) + (:import (com.jme3.math ColorRGBA Vector3f)) + (:import com.jme3.audio.AudioNode) + (:import com.aurellem.capture.RatchetTimer)) + +(def hand "Models/creature1/one.blend") + +(def worm "Models/creature1/try-again.blend") + +(defn test-creature [thing] + (let [x-axis + (box 1 0.01 0.01 :physical? false :color ColorRGBA/Red) + y-axis + (box 0.01 1 0.01 :physical? false :color ColorRGBA/Green) + z-axis + (box 0.01 0.01 1 :physical? false :color ColorRGBA/Blue) + + me (sphere 0.5 :color ColorRGBA/Blue :physical? false) + bell (AudioNode. (asset-manager) + "Sounds/pure.wav" false) + + fix-display + (runonce (fn [world] + (add-camera! world (.getCamera world) no-op))) + creature (doto (load-blender-model thing) (body!)) + + ;;;;;;;;;;;; Sensors/Effectors ;;;;;;;;;;;;;;;;;;;;;;;;;;;; + touch (touch! creature) + touch-display (view-touch) + + vision (vision! creature) + vision-display (view-vision) + + hearing (hearing! creature) + hearing-display (view-hearing) + + prop (proprioception! creature) + prop-display (view-proprioception) + + muscle-exertion (atom 0) + muscles (movement! creature) + muscle-display (view-movement)] + + (apply + world + (with-movement + (.getChild creature "worm-21") + ["key-r" "key-t" + "key-f" "key-g" + "key-v" "key-b"] + [10 10 10 10 1 1] + [(nodify [creature + (box 10 2 10 :position (Vector3f. 0 -9 0) + :color ColorRGBA/Gray :mass 0) + x-axis y-axis z-axis + me]) + (merge standard-debug-controls + {"key-return" + (fn [_ value] + (if value + (do + (println-repl "play-sound") + (.play bell)))) + "key-h" + (fn [_ value] + (if value + (swap! muscle-exertion (partial + 20)))) + "key-n" + (fn [_ value] + (if value + (swap! muscle-exertion (fn [v] (- v 20)))))}) + (fn [world] + (light-up-everything world) + (enable-debug world) + (add-camera! world + (add-eye! creature + (.getChild + (.getChild creature "eyes") "eye")) + (comp (view-image) BufferedImage!)) + (.setTimer world (RatchetTimer. 60)) + (speed-up world) + (set-gravity world (Vector3f. 0 0 0)) + (comment + (com.aurellem.capture.Capture/captureVideo + world (file-str "/home/r/proj/ai-videos/hand")))) + (fn [world tpf] + (prop-display (prop)) + (touch-display (map #(% (.getRootNode world)) touch)) + (vision-display (map #(% world) vision)) + (hearing-display (map #(% world) hearing)) + (muscle-display (map #(% @muscle-exertion) muscles)) + (.setLocalTranslation me (.getLocation (.getCamera world))) + (fix-display world))])))) +#+end_src + +#+results: body-1 +: #'cortex.silly/follow-test + + +* COMMENT purgatory +#+begin_src clojure + +(defn bullet-trans* [] + (let [obj-a (box 1.5 0.5 0.5 :color ColorRGBA/Red + :position (Vector3f. 5 0 0) + :mass 90) + obj-b (sphere 0.5 :color ColorRGBA/Blue + :position (Vector3f. -5 0 0) + :mass 0) + control-a (.getControl obj-a RigidBodyControl) + control-b (.getControl obj-b RigidBodyControl) + move-up? (atom nil) + move-down? (atom nil) + move-left? (atom nil) + move-right? (atom nil) + roll-left? (atom nil) + roll-right? (atom nil) + force 100 + swivel + (.toRotationMatrix + (doto (Quaternion.) + (.fromAngleAxis (/ Math/PI 2) + Vector3f/UNIT_X))) + x-move + (doto (Matrix3f.) + (.fromStartEndVectors Vector3f/UNIT_X + (.normalize (Vector3f. 1 1 0)))) + + timer (atom 0)] + (doto + (ConeJoint. + control-a control-b + (Vector3f. -8 0 0) + (Vector3f. 2 0 0) + ;;swivel swivel + ;;Matrix3f/IDENTITY Matrix3f/IDENTITY + x-move Matrix3f/IDENTITY + ) + (.setCollisionBetweenLinkedBodys false) + (.setLimit (* 1 (/ Math/PI 4)) ;; twist + (* 1 (/ Math/PI 4)) ;; swing span in X-Y plane + (* 0 (/ Math/PI 4)))) ;; swing span in Y-Z plane + (world (nodify + [obj-a obj-b]) + (merge standard-debug-controls + {"key-r" (fn [_ pressed?] (reset! move-up? pressed?)) + "key-t" (fn [_ pressed?] (reset! move-down? pressed?)) + "key-f" (fn [_ pressed?] (reset! move-left? pressed?)) + "key-g" (fn [_ pressed?] (reset! move-right? pressed?)) + "key-v" (fn [_ pressed?] (reset! roll-left? pressed?)) + "key-b" (fn [_ pressed?] (reset! roll-right? pressed?))}) + + (fn [world] + (enable-debug world) + (set-gravity world Vector3f/ZERO) + ) + + (fn [world _] + + (if @move-up? + (.applyForce control-a + (Vector3f. force 0 0) + (Vector3f. 0 0 0))) + (if @move-down? + (.applyForce control-a + (Vector3f. (- force) 0 0) + (Vector3f. 0 0 0))) + (if @move-left? + (.applyForce control-a + (Vector3f. 0 force 0) + (Vector3f. 0 0 0))) + (if @move-right? + (.applyForce control-a + (Vector3f. 0 (- force) 0) + (Vector3f. 0 0 0))) + + (if @roll-left? + (.applyForce control-a + (Vector3f. 0 0 force) + (Vector3f. 0 0 0))) + (if @roll-right? + (.applyForce control-a + (Vector3f. 0 0 (- force)) + (Vector3f. 0 0 0))) + + (if (zero? (rem (swap! timer inc) 100)) + (.attachChild + (.getRootNode world) + (sphere 0.05 :color ColorRGBA/Yellow + :physical? false :position + (.getWorldTranslation obj-a))))) + ) + )) + +(defn test-joint [joint] + (let [[origin top bottom floor] (world-setup joint) + control (.getControl top RigidBodyControl) + move-up? (atom false) + move-down? (atom false) + move-left? (atom false) + move-right? (atom false) + roll-left? (atom false) + roll-right? (atom false) + timer (atom 0)] + + (world + (nodify [top bottom floor origin]) + (merge standard-debug-controls + {"key-r" (fn [_ pressed?] (reset! move-up? pressed?)) + "key-t" (fn [_ pressed?] (reset! move-down? pressed?)) + "key-f" (fn [_ pressed?] (reset! move-left? pressed?)) + "key-g" (fn [_ pressed?] (reset! move-right? pressed?)) + "key-v" (fn [_ pressed?] (reset! roll-left? pressed?)) + "key-b" (fn [_ pressed?] (reset! roll-right? pressed?))}) + + (fn [world] + (light-up-everything world) + (enable-debug world) + (set-gravity world (Vector3f. 0 0 0)) + ) + + (fn [world _] + (if (zero? (rem (swap! timer inc) 100)) + (do + ;; (println-repl @timer) + (.attachChild (.getRootNode world) + (sphere 0.05 :color ColorRGBA/Yellow + :position (.getWorldTranslation top) + :physical? false)) + (.attachChild (.getRootNode world) + (sphere 0.05 :color ColorRGBA/LightGray + :position (.getWorldTranslation bottom) + :physical? false)))) + + (if @move-up? + (.applyTorque control + (.mult (.getPhysicsRotation control) + (Vector3f. 0 0 10)))) + (if @move-down? + (.applyTorque control + (.mult (.getPhysicsRotation control) + (Vector3f. 0 0 -10)))) + (if @move-left? + (.applyTorque control + (.mult (.getPhysicsRotation control) + (Vector3f. 0 10 0)))) + (if @move-right? + (.applyTorque control + (.mult (.getPhysicsRotation control) + (Vector3f. 0 -10 0)))) + (if @roll-left? + (.applyTorque control + (.mult (.getPhysicsRotation control) + (Vector3f. -1 0 0)))) + (if @roll-right? + (.applyTorque control + (.mult (.getPhysicsRotation control) + (Vector3f. 1 0 0)))))))) + +(defn follow-test + "Show a camera that stays in the same relative position to a blue cube." + [] + (let [camera-pos (Vector3f. 0 30 0) + rock (box 1 1 1 :color ColorRGBA/Blue + :position (Vector3f. 0 10 0) + :mass 30 + ) + rot (.getWorldRotation rock) + + table (box 3 1 10 :color ColorRGBA/Gray :mass 0 + :position (Vector3f. 0 -3 0))] + + (world + (nodify [rock table]) + standard-debug-controls + (fn [world] + (let + [cam (doto (.clone (.getCamera world)) + (.setLocation camera-pos) + (.lookAt Vector3f/ZERO + Vector3f/UNIT_X))] + (bind-sense rock cam) + + (.setTimer world (RatchetTimer. 60)) + (add-camera! world cam (comp (view-image) BufferedImage!)) + (add-camera! world (.getCamera world) no-op)) + ) + (fn [_ _] (println-repl rot))))) +#+end_src + + +* COMMENT generate source +#+begin_src clojure :tangle ../src/cortex/integration.clj +<> +#+end_src + + + + diff -r 66fbab414d45 -r deac7b708750 org/test-creature.org --- a/org/test-creature.org Sat Feb 04 11:02:19 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,454 +0,0 @@ -#+title: First attempt at a creature! -#+author: Robert McIntyre -#+email: rlm@mit.edu -#+description: -#+keywords: simulation, jMonkeyEngine3, clojure -#+SETUPFILE: ../../aurellem/org/setup.org -#+INCLUDE: ../../aurellem/org/level-0.org - - - - -* Intro -So far, I've made the following senses -- - - Vision - - Hearing - - Touch - - Proprioception - -And one effector: - - Movement - -However, the code so far has only enabled these senses, but has not -actually implemented them. For example, there is still a lot of work -to be done for vision. I need to be able to create an /eyeball/ in -simulation that can be moved around and see the world from different -angles. I also need to determine weather to use log-polar or cartesian -for the visual input, and I need to determine how/wether to -disceritise the visual input. - -I also want to be able to visualize both the sensors and the -effectors in pretty pictures. This semi-retarted creature will be my -first attempt at bringing everything together. - -* The creature's body - -Still going to do an eve-like body in blender, but due to problems -importing the joints, etc into jMonkeyEngine3, I'm going to do all -the connecting here in clojure code, using the names of the individual -components and trial and error. Later, I'll maybe make some sort of -creature-building modifications to blender that support whatever -discritized senses I'm going to make. - -#+name: body-1 -#+begin_src clojure -(ns cortex.silly - "let's play!" - {:author "Robert McIntyre"}) - -;; TODO remove this! -(require 'cortex.import) -(cortex.import/mega-import-jme3) -(use '(cortex world util body hearing touch vision sense - proprioception movement)) - -(rlm.rlm-commands/help) -(import java.awt.image.BufferedImage) -(import javax.swing.JPanel) -(import javax.swing.SwingUtilities) -(import java.awt.Dimension) -(import javax.swing.JFrame) -(import java.awt.Dimension) -(import com.aurellem.capture.RatchetTimer) - -(use 'clojure.contrib.def) - -(defn load-blender-model - "Load a .blend file using an asset folder relative path." - [^String model] - (.loadModel - (doto (asset-manager) - (.registerLoader BlenderModelLoader (into-array String ["blend"]))) - model)) - -(def hand "Models/creature1/one.blend") - -(def worm "Models/creature1/try-again.blend") - -(defn worm-model [] (load-blender-model worm)) - -(defn x-ray [#^ColorRGBA color] - (doto (Material. (asset-manager) - "Common/MatDefs/Misc/Unshaded.j3md") - (.setColor "Color" color) - (-> (.getAdditionalRenderState) - (.setDepthTest false)))) - -(defn colorful [] - (.getChild (worm-model) "worm-21")) - -(import jme3tools.converters.ImageToAwt) - -(import ij.ImagePlus) - - - -(defn test-eye [] - (.getChild - (.getChild (worm-model) "eyes") - "eye")) - - - -;; lower level --- nodes -;; closest-node "parse/compile-x" -> makes organ, which is spatial, fn pair - -;; higher level -- organs -;; - -;; higher level --- sense/effector -;; these are the functions that provide world i/o, chinese-room style - -(defn debug-hearing-window - "view audio data" - [height] - (let [vi (view-image)] - (fn [[coords sensor-data]] - (let [image (BufferedImage. (count coords) height - BufferedImage/TYPE_INT_RGB)] - (dorun - (for [x (range (count coords))] - (dorun - (for [y (range height)] - (let [raw-sensor (sensor-data x)] - (.setRGB image x y (gray raw-sensor))))))) - - (vi image))))) - -(defn test-creature [thing] - (let [x-axis - (box 1 0.01 0.01 :physical? false :color ColorRGBA/Red) - y-axis - (box 0.01 1 0.01 :physical? false :color ColorRGBA/Green) - z-axis - (box 0.01 0.01 1 :physical? false :color ColorRGBA/Blue) - - creature (doto (load-blender-model thing) (body!)) - - touch (touch! creature) - touch-display (view-touch) - - vision (vision! creature) - vision-display (view-vision) - - hearing (hearing! creature) - hearing-display (view-hearing) - - prop (proprioception! creature) - prop-display (view-proprioception) - - muscle-exertion (atom 0) - muscles (movement! creature) - muscle-display (view-movement) - - me (sphere 0.5 :color ColorRGBA/Blue :physical? false) - bell (AudioNode. (asset-manager) - "Sounds/pure.wav" false) - - fix-display (runonce - (fn [world] (add-camera! world (.getCamera world) no-op))) - ] - - - (apply - world - (with-movement - (.getChild creature "worm-21") - ["key-r" "key-t" - "key-f" "key-g" - "key-v" "key-b"] - [10 10 10 10 1 1] - [(nodify [creature - (box 10 2 10 :position (Vector3f. 0 -9 0) - :color ColorRGBA/Gray :mass 0) - x-axis y-axis z-axis - me - ]) - (merge standard-debug-controls - {"key-return" - (fn [_ value] - (if value - (do - (println-repl "play-sound") - (.play bell)))) - "key-h" - (fn [_ value] - (if value - (swap! muscle-exertion (partial + 20)))) - "key-n" - (fn [_ value] - (if value - (swap! muscle-exertion (fn [v] (- v 20))))) - - }) - (fn [world] - (light-up-everything world) - (enable-debug world) - ;;(dorun (map #(% world) init-vision-fns)) - ;;(dorun (map #(% world) init-hearing-fns)) - - (add-camera! world - (add-eye! creature (test-eye)) - (comp (view-image) BufferedImage!)) - - - ;;(set-gravity world (Vector3f. 0 0 0)) - ;;(com.aurellem.capture.Capture/captureVideo - ;; world (file-str "/home/r/proj/ai-videos/hand")) - ;;(.setTimer world (RatchetTimer. 60)) - (speed-up world) - (set-gravity world (Vector3f. 0 0 0)) - ) - (fn [world tpf] - ;;(dorun - ;; (map #(%1 %2) touch-nerves (repeat (.getRootNode world)))) - - (prop-display (prop)) - - (touch-display (map #(% (.getRootNode world)) touch)) - - (vision-display (map #(% world) vision)) - - (hearing-display (map #(% world) hearing)) - - (muscle-display (map #(% @muscle-exertion) muscles)) - - ;;(println-repl (vision-data)) - (.setLocalTranslation me (.getLocation (.getCamera world))) - (fix-display world) - - )] - ;;(let [timer (atom 0)] - ;; (fn [_ _] - ;; (swap! timer inc) - ;; (if (= (rem @timer 60) 0) - ;; (println-repl (float (/ @timer 60)))))) - )))) - - - -;; the camera will stay in its initial position/rotation with relation -;; to the spatial. - - -;;dylan (defn follow-sense, adjoin-sense, attach-stimuli, -;;anchor-qualia, augment-organ, with-organ - -(defn follow-test - "show a camera that stays in the same relative position to a blue cube." - [] - (let [camera-pos (Vector3f. 0 30 0) - rock (box 1 1 1 :color ColorRGBA/Blue - :position (Vector3f. 0 10 0) - :mass 30 - ) - rot (.getWorldRotation rock) - - table (box 3 1 10 :color ColorRGBA/Gray :mass 0 - :position (Vector3f. 0 -3 0))] - - (world - (nodify [rock table]) - standard-debug-controls - (fn [world] - (let - [cam (doto (.clone (.getCamera world)) - (.setLocation camera-pos) - (.lookAt Vector3f/ZERO - Vector3f/UNIT_X))] - (bind-sense rock cam) - - (.setTimer world (RatchetTimer. 60)) - (add-camera! world cam (comp (view-image) BufferedImage!)) - (add-camera! world (.getCamera world) no-op)) - ) - (fn [_ _] (println-repl rot))))) - - - -#+end_src - -#+results: body-1 -: #'cortex.silly/follow-test - - -* COMMENT purgatory -#+begin_src clojure - -(defn bullet-trans* [] - (let [obj-a (box 1.5 0.5 0.5 :color ColorRGBA/Red - :position (Vector3f. 5 0 0) - :mass 90) - obj-b (sphere 0.5 :color ColorRGBA/Blue - :position (Vector3f. -5 0 0) - :mass 0) - control-a (.getControl obj-a RigidBodyControl) - control-b (.getControl obj-b RigidBodyControl) - move-up? (atom nil) - move-down? (atom nil) - move-left? (atom nil) - move-right? (atom nil) - roll-left? (atom nil) - roll-right? (atom nil) - force 100 - swivel - (.toRotationMatrix - (doto (Quaternion.) - (.fromAngleAxis (/ Math/PI 2) - Vector3f/UNIT_X))) - x-move - (doto (Matrix3f.) - (.fromStartEndVectors Vector3f/UNIT_X - (.normalize (Vector3f. 1 1 0)))) - - timer (atom 0)] - (doto - (ConeJoint. - control-a control-b - (Vector3f. -8 0 0) - (Vector3f. 2 0 0) - ;;swivel swivel - ;;Matrix3f/IDENTITY Matrix3f/IDENTITY - x-move Matrix3f/IDENTITY - ) - (.setCollisionBetweenLinkedBodys false) - (.setLimit (* 1 (/ Math/PI 4)) ;; twist - (* 1 (/ Math/PI 4)) ;; swing span in X-Y plane - (* 0 (/ Math/PI 4)))) ;; swing span in Y-Z plane - (world (nodify - [obj-a obj-b]) - (merge standard-debug-controls - {"key-r" (fn [_ pressed?] (reset! move-up? pressed?)) - "key-t" (fn [_ pressed?] (reset! move-down? pressed?)) - "key-f" (fn [_ pressed?] (reset! move-left? pressed?)) - "key-g" (fn [_ pressed?] (reset! move-right? pressed?)) - "key-v" (fn [_ pressed?] (reset! roll-left? pressed?)) - "key-b" (fn [_ pressed?] (reset! roll-right? pressed?))}) - - (fn [world] - (enable-debug world) - (set-gravity world Vector3f/ZERO) - ) - - (fn [world _] - - (if @move-up? - (.applyForce control-a - (Vector3f. force 0 0) - (Vector3f. 0 0 0))) - (if @move-down? - (.applyForce control-a - (Vector3f. (- force) 0 0) - (Vector3f. 0 0 0))) - (if @move-left? - (.applyForce control-a - (Vector3f. 0 force 0) - (Vector3f. 0 0 0))) - (if @move-right? - (.applyForce control-a - (Vector3f. 0 (- force) 0) - (Vector3f. 0 0 0))) - - (if @roll-left? - (.applyForce control-a - (Vector3f. 0 0 force) - (Vector3f. 0 0 0))) - (if @roll-right? - (.applyForce control-a - (Vector3f. 0 0 (- force)) - (Vector3f. 0 0 0))) - - (if (zero? (rem (swap! timer inc) 100)) - (.attachChild - (.getRootNode world) - (sphere 0.05 :color ColorRGBA/Yellow - :physical? false :position - (.getWorldTranslation obj-a))))) - ) - )) - -(defn test-joint [joint] - (let [[origin top bottom floor] (world-setup joint) - control (.getControl top RigidBodyControl) - move-up? (atom false) - move-down? (atom false) - move-left? (atom false) - move-right? (atom false) - roll-left? (atom false) - roll-right? (atom false) - timer (atom 0)] - - (world - (nodify [top bottom floor origin]) - (merge standard-debug-controls - {"key-r" (fn [_ pressed?] (reset! move-up? pressed?)) - "key-t" (fn [_ pressed?] (reset! move-down? pressed?)) - "key-f" (fn [_ pressed?] (reset! move-left? pressed?)) - "key-g" (fn [_ pressed?] (reset! move-right? pressed?)) - "key-v" (fn [_ pressed?] (reset! roll-left? pressed?)) - "key-b" (fn [_ pressed?] (reset! roll-right? pressed?))}) - - (fn [world] - (light-up-everything world) - (enable-debug world) - (set-gravity world (Vector3f. 0 0 0)) - ) - - (fn [world _] - (if (zero? (rem (swap! timer inc) 100)) - (do - ;; (println-repl @timer) - (.attachChild (.getRootNode world) - (sphere 0.05 :color ColorRGBA/Yellow - :position (.getWorldTranslation top) - :physical? false)) - (.attachChild (.getRootNode world) - (sphere 0.05 :color ColorRGBA/LightGray - :position (.getWorldTranslation bottom) - :physical? false)))) - - (if @move-up? - (.applyTorque control - (.mult (.getPhysicsRotation control) - (Vector3f. 0 0 10)))) - (if @move-down? - (.applyTorque control - (.mult (.getPhysicsRotation control) - (Vector3f. 0 0 -10)))) - (if @move-left? - (.applyTorque control - (.mult (.getPhysicsRotation control) - (Vector3f. 0 10 0)))) - (if @move-right? - (.applyTorque control - (.mult (.getPhysicsRotation control) - (Vector3f. 0 -10 0)))) - (if @roll-left? - (.applyTorque control - (.mult (.getPhysicsRotation control) - (Vector3f. -1 0 0)))) - (if @roll-right? - (.applyTorque control - (.mult (.getPhysicsRotation control) - (Vector3f. 1 0 0)))))))) -#+end_src - - -* COMMENT generate source -#+begin_src clojure :tangle ../src/cortex/silly.clj -<> -#+end_src - - - - diff -r 66fbab414d45 -r deac7b708750 org/util.org --- a/org/util.org Sat Feb 04 11:02:19 2012 -0700 +++ b/org/util.org Sat Feb 04 11:29:45 2012 -0700 @@ -102,7 +102,7 @@ (:import javax.swing.JPanel) (:import javax.swing.JFrame) (:import javax.swing.SwingUtilities) - + (:import com.jme3.scene.plugins.blender.BlenderModelLoader) (:import (java.util.logging Level Logger))) (defvar println-repl @@ -318,15 +318,15 @@ :shape (Sphere. 32 32 (float r)))))) ([] (sphere 0.5))) -(defn green-x-ray - "A usefull material for debuging -- it can be seen no matter what - object occuldes it." - [] - (doto (Material. (asset-manager) - "Common/MatDefs/Misc/Unshaded.j3md") - (.setColor "Color" ColorRGBA/Green) - (-> (.getAdditionalRenderState) - (.setDepthTest false)))) +(defn x-ray + "A usefull material for debuging -- it can be seen no matter what + object occuldes it." + [#^ColorRGBA color] + (doto (Material. (asset-manager) + "Common/MatDefs/Misc/Unshaded.j3md") + (.setColor "Color" color) + (-> (.getAdditionalRenderState) + (.setDepthTest false)))) (defn node-seq "Take a node and return a seq of all its children @@ -344,6 +344,14 @@ node)) ([children] (nodify "" children))) +(defn load-blender-model + "Load a .blend file using an asset folder relative path." + [^String model] + (.loadModel + (doto (asset-manager) + (.registerLoader BlenderModelLoader + (into-array String ["blend"]))) model)) + #+end_src