changeset 73:257a86328adb

saving progress
author Robert McIntyre <rlm@mit.edu>
date Wed, 28 Dec 2011 00:00:23 -0700
parents 6f1c86126d51
children fb810a2c50c2
files assets/Models/creature1/hand.png assets/Models/creature1/one.bk.blend assets/Models/creature1/one.blend assets/Models/property/test.blend org/body.org org/integration.org org/test-creature.org org/util.org
diffstat 8 files changed, 165 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
     1.1 Binary file assets/Models/creature1/hand.png has changed
     2.1 Binary file assets/Models/creature1/one.bk.blend has changed
     3.1 Binary file assets/Models/creature1/one.blend has changed
     4.1 Binary file assets/Models/property/test.blend has changed
     5.1 --- a/org/body.org	Wed Dec 14 17:41:19 2011 -0700
     5.2 +++ b/org/body.org	Wed Dec 28 00:00:23 2011 -0700
     5.3 @@ -740,7 +740,7 @@
     5.4  
     5.5  
     5.6  
     5.7 -* COMMENT generate Source.
     5.8 +* COMMENT generate Source
     5.9  #+begin_src clojure :tangle ../src/cortex/body.clj
    5.10  <<proprioception>>
    5.11  <<motor-control>>
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/org/integration.org	Wed Dec 28 00:00:23 2011 -0700
     6.3 @@ -0,0 +1,80 @@
     6.4 +
     6.5 +
     6.6 +* TODO goals for today
     6.7 + - [X] create falling cube in blender
     6.8 + - [ ] record falling cube animation in blender
     6.9 + - [ ] import falling cube in jMonkeyEngine
    6.10 + - [ ] record jmonkeyEngine cube animation
    6.11 +
    6.12 +
    6.13 +#+name: integration
    6.14 +#+begin_src clojure
    6.15 +(ns cortex.integration
    6.16 +  "Enable loading creatures with senses from blender."
    6.17 +  {:author "Robert McIntyre"})
    6.18 +
    6.19 +;; TODO remove this!
    6.20 +(require 'cortex.import)
    6.21 +(cortex.import/mega-import-jme3)
    6.22 +(use '(cortex world util))
    6.23 +
    6.24 +(rlm.rlm-commands/help)
    6.25 +
    6.26 +
    6.27 +
    6.28 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    6.29 +
    6.30 +;; this could be a good way to give objects special properties like
    6.31 +;; being eyes and the like
    6.32 +(defn load-blender-model
    6.33 +  "Load a .blend file using an asset folder relative path."
    6.34 +  [^String model]
    6.35 +  (.loadModel
    6.36 +   (doto (asset-manager)
    6.37 +     (.registerLoader BlenderModelLoader (into-array String ["blend"])))
    6.38 +   model))
    6.39 +
    6.40 +(defn scene []
    6.41 +  (load-blender-model "Models/property/test.blend"))
    6.42 +
    6.43 +(defn test-GET! []
    6.44 +  (.getUserData 
    6.45 +   (.getChild
    6.46 +    (scene) 0)
    6.47 +    "properties"))
    6.48 +
    6.49 +(defn make-eye []
    6.50 +  (println "hi"))
    6.51 +
    6.52 +(defn test-eval-prop []
    6.53 +  (eval (read-string (.findValue (test-GET!) "form"))))
    6.54 +
    6.55 +;; the properties are saved along with the blender file.
    6.56 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    6.57 +
    6.58 +
    6.59 +
    6.60 +;; Sensors are thunk-functions that return sensory data.
    6.61 +;; Effectors take data and cause changes in the results of the sensor
    6.62 +;; functions. 
    6.63 +
    6.64 +(defrecord Creature [sensors effectors])
    6.65 +
    6.66 +
    6.67 +
    6.68 +
    6.69 +
    6.70 +
    6.71 +
    6.72 +
    6.73 +
    6.74 +#+end_src
    6.75 +
    6.76 +
    6.77 +
    6.78 +#+begin_src clojure :tangle ../src/cortex/integration.clj
    6.79 +<<integration>>
    6.80 +#+end_src
    6.81 +
    6.82 +
    6.83 +
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/org/test-creature.org	Wed Dec 28 00:00:23 2011 -0700
     7.3 @@ -0,0 +1,81 @@
     7.4 +#+title: First attempt at a creature!
     7.5 +#+author: Robert McIntyre
     7.6 +#+email: rlm@mit.edu
     7.7 +#+description: 
     7.8 +#+keywords: simulation, jMonkeyEngine3, clojure
     7.9 +#+SETUPFILE: ../../aurellem/org/setup.org
    7.10 +#+INCLUDE: ../../aurellem/org/level-0.org
    7.11 +
    7.12 +* Intro 
    7.13 +So far, I've made the following senses -- 
    7.14 + - Vision
    7.15 + - Hearing
    7.16 + - Touch
    7.17 + - Proprioception
    7.18 +
    7.19 +And one effector: 
    7.20 + - Movement
    7.21 +
    7.22 +However, the code so far has only enabled these senses, but has not
    7.23 +actually implemented them.  For example, there is still a lot of work
    7.24 +to be done for vision. I need to be able to create an /eyeball/ in
    7.25 +simulation that can be moved around and see the world from different
    7.26 +angles. I also need to determine weather to use log-polar or cartesian
    7.27 +for the visual input, and I need to determine how/wether to
    7.28 +disceritise the visual input.
    7.29 +
    7.30 +I also want to be able to visualize both the sensors and the
    7.31 +effectors in pretty pictures. This semi-retarted creature will by my
    7.32 +first attempt at bringing everything together.
    7.33 +
    7.34 +* The creature's body
    7.35 +
    7.36 +Still going to do an eve-like body in blender, but due to problems
    7.37 +importing the joints, etc into jMonkeyEngine3, I',m going to do all
    7.38 +the connecting here in clojure code, using the names of the individual
    7.39 +components and trial and error. Later, I'll maybe make some sort of
    7.40 +creature-building modifications to blender that support whatever
    7.41 +discreitized senses I'm going to make.
    7.42 +
    7.43 +#+name: body-1
    7.44 +#+begin_src clojure 
    7.45 +(ns cortex.silly
    7.46 +  "let's play!"
    7.47 +  {:author "Robert McIntyre"})
    7.48 +
    7.49 +;; TODO remove this!
    7.50 +(require 'cortex.import)
    7.51 +(cortex.import/mega-import-jme3)
    7.52 +(use '(cortex world util body hearing touch vision))
    7.53 +
    7.54 +(use '[clojure.contrib [seq :only [find-first]]])
    7.55 +
    7.56 +
    7.57 +(rlm.rlm-commands/help)
    7.58 +
    7.59 +(defn load-blender-model
    7.60 +  "Load a .blend file using an asset folder relative path."
    7.61 +  [^String model]
    7.62 +  (.loadModel
    7.63 +   (doto (asset-manager)
    7.64 +     (.registerLoader BlenderModelLoader (into-array String ["blend"])))
    7.65 +   model))
    7.66 +
    7.67 +
    7.68 +(defn apply-skeleton
    7.69 +  "Given an imported blender model, apply the armature using the
    7.70 +  following pattern: if two bones are connected and have the same
    7.71 +  names as two shapes, connect the shapes with a joint constraint."
    7.72 +  [armature-name creature]
    7.73 +  
    7.74 +
    7.75 +
    7.76 +#+end_src
    7.77 +
    7.78 +
    7.79 +
    7.80 +* COMMENT generate source
    7.81 +#+begin_src clojure :tangle ../src/cortex/silly.clj
    7.82 +<<body-1>>
    7.83 +#+end_src
    7.84 +
     8.1 --- a/org/util.org	Wed Dec 14 17:41:19 2011 -0700
     8.2 +++ b/org/util.org	Wed Dec 28 00:00:23 2011 -0700
     8.3 @@ -188,7 +188,7 @@
     8.4  
     8.5  #+results: util
     8.6  : #'cortex.util/apply-map
     8.7 -
     8.8 +    
     8.9  
    8.10  *** Creating Basic Shapes
    8.11  
    8.12 @@ -250,7 +250,8 @@
    8.13                 (doto (GImpactCollisionShape. 
    8.14                        (.getMesh geom))
    8.15                   (.createJmeMesh)
    8.16 -                 (.setMargin 0))
    8.17 +                 ;;(.setMargin 0)
    8.18 +                 )
    8.19                 (float (:mass d)))
    8.20                ;; otherwise use jme3's default
    8.21                (RigidBodyControl. (float (:mass d))))]