Added makehuman-bridge, but it doesn't work yet

(and may never)
This commit is contained in:
Simon Brooke 2024-05-03 13:22:43 +01:00
parent ba9ecd91a2
commit 248db762ac
4 changed files with 82 additions and 4 deletions

View file

@ -29,7 +29,7 @@ My hunch is that a 64 bit genome is more than sufficient, if we code it carefull
| Gracility/Robustness | 3 | Slenderness to stockiness of skeleton/armature build, with [000] being very slender and [111] being very broad/heavy. | | Gracility/Robustness | 3 | Slenderness to stockiness of skeleton/armature build, with [000] being very slender and [111] being very broad/heavy. |
| Age-related change | 3 | People get white haired at different ages; some men go bald and some do not. The sons of the daughter of a bald man should have a chance of inheriting age-related baldness, although their mother won't express that gene. So I'm allowing here for eight different profiles for age related change, although I'm not yet clear what the exact values would mean. | | Age-related change | 3 | People get white haired at different ages; some men go bald and some do not. The sons of the daughter of a bald man should have a chance of inheriting age-related baldness, although their mother won't express that gene. So I'm allowing here for eight different profiles for age related change, although I'm not yet clear what the exact values would mean. |
That's twenty-nine of our sixty-four bits, leaving plenty for face models, gender That's twenty-nine of our sixty-four bits, leaving plenty for face models, gender and so on.
### What's not included in the genome ### What's not included in the genome

View file

@ -3,13 +3,12 @@
:url "http://example.com/FIXME" :url "http://example.com/FIXME"
:license {:name "GNU General Public License,version 2.0 or (at your option) any later version" :license {:name "GNU General Public License,version 2.0 or (at your option) any later version"
:url "https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html"} :url "https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html"}
:dependencies [[cnuernber/libpython-clj "1.33"] :dependencies [[clj-python/libpython-clj "2.025"]
[com.taoensso/telemere "1.0.0-beta3"] ;; Peter Taoussanis' new replacement for Timbre [com.taoensso/telemere "1.0.0-beta3"] ;; Peter Taoussanis' new replacement for Timbre
[jme-clj "0.1.13"] [jme-clj "0.1.13"]
[org.clojure/clojure "1.11.1"] [org.clojure/clojure "1.11.1"]
[org.clojure/tools.cli "1.1.230"] [org.clojure/tools.cli "1.1.230"]
[org.jmonkeyengine/jme3-core "3.6.1-stable"] [org.jmonkeyengine/jme3-core "3.6.1-stable"]]
[cnuernber/libpython-clj "1.36"]]
:main ^:skip-aot cc.journeyman.simulated-genetics.launcher :main ^:skip-aot cc.journeyman.simulated-genetics.launcher
:target-path "target/%s" :target-path "target/%s"
:profiles {:uberjar {:aot :all :profiles {:uberjar {:aot :all

View file

@ -0,0 +1,55 @@
(ns cc.journeyman.simulated-genetics.makehuman-bridge
"Bridge to MakeHuman, in an attempt to use it to generate character models."
(:require [libpython-clj2.require :refer [require-python]]
[libpython-clj2.python
:refer [as-python as-jvm
->python ->jvm
get-attr call-attr call-attr-kw
get-item initialize!
run-simple-string
add-module module-dict
import-module
py. py.. py.-
python-type
;; dir
]
:as py]
[taoensso.telemere :refer [error! trace!]]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;
;;;; Bridge to MakeHuman, in an attempt to use it to generate character models.
;;;;
;;;; This program is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU General Public License
;;;; as published by the Free Software Foundation; either version 2
;;;; of the License, or (at your option) any later version.
;;;;
;;;; This program is distributed in the hope that it will be useful,
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;;; GNU General Public License for more details.
;;;;
;;;; You should have received a copy of the GNU General Public License
;;;; along with this program; if not, write to the Free Software
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
;;;; USA.
;;;;
;;;; Copyright (C) 2024 Simon Brooke
;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn initialise-makehuman!
"Initialise the local instance of MakeHuman. `mh-path` should be a valid
path to the directory in which MakeHuman is installed, i.e. the directory
which contains `makehuman.py`."
[^String mh-path]
(initialize!)
(map #(trace! (run-simple-string %))
["import sys"
(format "sys.path.append('%s')" mh-path)
(format "exec(open('%s/makehuman.py').read())" mh-path)
"from lib.core import G"
"G.app.mhapi.internals.getHuman()"
]))

View file

@ -1,6 +1,30 @@
(ns cc.journeyman.simulated-genetics.utils (ns cc.journeyman.simulated-genetics.utils
(:require [taoensso.telemere :refer [error! trace!]])) (:require [taoensso.telemere :refer [error! trace!]]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;
;;;; Utility functions.
;;;;
;;;; This program is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU General Public License
;;;; as published by the Free Software Foundation; either version 2
;;;; of the License, or (at your option) any later version.
;;;;
;;;; This program is distributed in the hope that it will be useful,
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;;; GNU General Public License for more details.
;;;;
;;;; You should have received a copy of the GNU General Public License
;;;; along with this program; if not, write to the Free Software
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
;;;; USA.
;;;;
;;;; Copyright (C) 2024 Simon Brooke
;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def ^:const bits-in-genome (def ^:const bits-in-genome
"Number of bits we're actually using. **NOTE THAT** as this implementation "Number of bits we're actually using. **NOTE THAT** as this implementation
is based on Java longs, this number must not be more than 63 or else we've is based on Java longs, this number must not be more than 63 or else we've