Mercurial > cortex
comparison org/body.org @ 51:2a6ede6d8ad8
problem was that the skeleton was not 'ready'
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 14 Nov 2011 19:44:30 -0700 |
parents | b1b90c4ab0bf |
children | 00d0e1639d4b |
comparison
equal
deleted
inserted
replaced
50:b1b90c4ab0bf | 51:2a6ede6d8ad8 |
---|---|
55 | 55 |
56 (defn worm-blender | 56 (defn worm-blender |
57 [] | 57 [] |
58 (first (seq (.getChildren (load-blender-model | 58 (first (seq (.getChildren (load-blender-model |
59 "Models/anim2/worm3.blend"))))) | 59 "Models/anim2/worm3.blend"))))) |
60 | |
61 | 60 |
62 (defprotocol Textual | 61 (defprotocol Textual |
63 (text [something] | 62 (text [something] |
64 "Display a detailed textual analysis of the given object.")) | 63 "Display a detailed textual analysis of the given object.")) |
65 | 64 |
106 (.addControl node krc) | 105 (.addControl node krc) |
107 (.setRagdollMode krc)) | 106 (.setRagdollMode krc)) |
108 node | 107 node |
109 ) | 108 ) |
110 | 109 |
110 (defn | |
111 green-x-ray [] | |
112 (doto (Material. (asset-manager) | |
113 "Common/MatDefs/Misc/Unshaded.j3md") | |
114 (.setColor "Color" ColorRGBA/Green) | |
115 (-> (.getAdditionalRenderState) (.setDepthTest | |
116 false)))) | |
117 | |
111 (defn view-skeleton [node] | 118 (defn view-skeleton [node] |
112 (let [sd | 119 (let [sd |
120 | |
113 (doto | 121 (doto |
114 (SkeletonDebugger. "aurellem-skel-debug" (skel node)) | 122 (SkeletonDebugger. "aurellem-skel-debug" |
115 (.setMaterial | 123 (skel node)) |
116 (doto (Material. (asset-manager) | 124 (.setMaterial (green-x-ray)))] |
117 "Common/MatDefs/Misc/Unshaded.j3md") | 125 (view (doto (Node. "view node") |
118 (-> (.getAdditionalRenderState) (.setDepthTest | 126 (.attachChild sd) |
119 false)))))] | 127 |
120 | 128 |
121 (.attachChild debug-node sd))) | 129 |
122 | 130 |
131 ;;(.attachChild node) | |
132 )))) | |
133 | |
123 | 134 |
124 (defn init-debug-skel-node | 135 (defn init-debug-skel-node |
125 [f debug-node skeleton] | 136 [f debug-node skeleton] |
126 (let [bones | 137 (let [bones |
127 (map #(.getBone skeleton %) | 138 (map #(.getBone skeleton %) |
129 (dorun (map #(.setUserControl % true) bones)) | 140 (dorun (map #(.setUserControl % true) bones)) |
130 (dorun (map (fn [b] | 141 (dorun (map (fn [b] |
131 (println (.getName b) | 142 (println (.getName b) |
132 " -- " (f b))) | 143 " -- " (f b))) |
133 bones)) | 144 bones)) |
134 | 145 |
135 (dorun | 146 (dorun |
136 (map #(.attachChild | 147 (map #(.attachChild |
137 debug-node | 148 debug-node |
138 (sphere 0.1 | 149 (doto |
139 :position (f %) | 150 (sphere 0.1 |
140 :rotation (.getWorldBindRotation %) | 151 :position (f %) |
141 :physical? false)) | 152 :physical? false) |
153 (.setMaterial (green-x-ray)))) | |
142 bones))) | 154 bones))) |
143 debug-node) | 155 debug-node) |
144 | 156 |
145 (defn skel [node] | 157 (defn skel [node] |
146 (.getSkeleton (.getControl node SkeletonControl))) | 158 (doto |
159 (.getSkeleton | |
160 (.getControl node SkeletonControl)) | |
161 ;; this is necessary to force the skeleton to have accurate world | |
162 ;; transforms before it is rendered to the screen. | |
163 (.resetAndUpdate))) | |
164 | |
147 | 165 |
148 | 166 |
149 | 167 |
150 | 168 |
151 (view | 169 (view |