diff org/integration.org @ 73:257a86328adb

saving progress
author Robert McIntyre <rlm@mit.edu>
date Wed, 28 Dec 2011 00:00:23 -0700
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/org/integration.org	Wed Dec 28 00:00:23 2011 -0700
     1.3 @@ -0,0 +1,80 @@
     1.4 +
     1.5 +
     1.6 +* TODO goals for today
     1.7 + - [X] create falling cube in blender
     1.8 + - [ ] record falling cube animation in blender
     1.9 + - [ ] import falling cube in jMonkeyEngine
    1.10 + - [ ] record jmonkeyEngine cube animation
    1.11 +
    1.12 +
    1.13 +#+name: integration
    1.14 +#+begin_src clojure
    1.15 +(ns cortex.integration
    1.16 +  "Enable loading creatures with senses from blender."
    1.17 +  {:author "Robert McIntyre"})
    1.18 +
    1.19 +;; TODO remove this!
    1.20 +(require 'cortex.import)
    1.21 +(cortex.import/mega-import-jme3)
    1.22 +(use '(cortex world util))
    1.23 +
    1.24 +(rlm.rlm-commands/help)
    1.25 +
    1.26 +
    1.27 +
    1.28 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    1.29 +
    1.30 +;; this could be a good way to give objects special properties like
    1.31 +;; being eyes and the like
    1.32 +(defn load-blender-model
    1.33 +  "Load a .blend file using an asset folder relative path."
    1.34 +  [^String model]
    1.35 +  (.loadModel
    1.36 +   (doto (asset-manager)
    1.37 +     (.registerLoader BlenderModelLoader (into-array String ["blend"])))
    1.38 +   model))
    1.39 +
    1.40 +(defn scene []
    1.41 +  (load-blender-model "Models/property/test.blend"))
    1.42 +
    1.43 +(defn test-GET! []
    1.44 +  (.getUserData 
    1.45 +   (.getChild
    1.46 +    (scene) 0)
    1.47 +    "properties"))
    1.48 +
    1.49 +(defn make-eye []
    1.50 +  (println "hi"))
    1.51 +
    1.52 +(defn test-eval-prop []
    1.53 +  (eval (read-string (.findValue (test-GET!) "form"))))
    1.54 +
    1.55 +;; the properties are saved along with the blender file.
    1.56 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    1.57 +
    1.58 +
    1.59 +
    1.60 +;; Sensors are thunk-functions that return sensory data.
    1.61 +;; Effectors take data and cause changes in the results of the sensor
    1.62 +;; functions. 
    1.63 +
    1.64 +(defrecord Creature [sensors effectors])
    1.65 +
    1.66 +
    1.67 +
    1.68 +
    1.69 +
    1.70 +
    1.71 +
    1.72 +
    1.73 +
    1.74 +#+end_src
    1.75 +
    1.76 +
    1.77 +
    1.78 +#+begin_src clojure :tangle ../src/cortex/integration.clj
    1.79 +<<integration>>
    1.80 +#+end_src
    1.81 +
    1.82 +
    1.83 +