From 248db762ac76d422e4fde7c4fa77caaa96a9f617 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Fri, 3 May 2024 13:22:43 +0100 Subject: [PATCH] Added makehuman-bridge, but it doesn't work yet (and may never) --- README.md | 2 +- project.clj | 5 +- .../simulated_genetics/makehuman_bridge.clj | 55 +++++++++++++++++++ .../journeyman/simulated_genetics/utils.clj | 24 ++++++++ 4 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 src/cc/journeyman/simulated_genetics/makehuman_bridge.clj diff --git a/README.md b/README.md index 7052da2..80f93f5 100644 --- a/README.md +++ b/README.md @@ -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. | | 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 diff --git a/project.clj b/project.clj index 82d7d52..cc21e9f 100644 --- a/project.clj +++ b/project.clj @@ -3,13 +3,12 @@ :url "http://example.com/FIXME" :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"} - :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 [jme-clj "0.1.13"] [org.clojure/clojure "1.11.1"] [org.clojure/tools.cli "1.1.230"] - [org.jmonkeyengine/jme3-core "3.6.1-stable"] - [cnuernber/libpython-clj "1.36"]] + [org.jmonkeyengine/jme3-core "3.6.1-stable"]] :main ^:skip-aot cc.journeyman.simulated-genetics.launcher :target-path "target/%s" :profiles {:uberjar {:aot :all diff --git a/src/cc/journeyman/simulated_genetics/makehuman_bridge.clj b/src/cc/journeyman/simulated_genetics/makehuman_bridge.clj new file mode 100644 index 0000000..47cbe17 --- /dev/null +++ b/src/cc/journeyman/simulated_genetics/makehuman_bridge.clj @@ -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()" + ])) \ No newline at end of file diff --git a/src/cc/journeyman/simulated_genetics/utils.clj b/src/cc/journeyman/simulated_genetics/utils.clj index e25e197..f95ffc5 100644 --- a/src/cc/journeyman/simulated_genetics/utils.clj +++ b/src/cc/journeyman/simulated_genetics/utils.clj @@ -1,6 +1,30 @@ (ns cc.journeyman.simulated-genetics.utils (: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 "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