# HG changeset patch # User Robert McIntyre # Date 1328274082 25200 # Node ID bb235258f8357d81f5e8072ad56c418dfe422431 # Parent c951799079512da57e11af693134c8da9139d08e deleted code from purgatory diff -r c95179907951 -r bb235258f835 org/test-creature.org --- a/org/test-creature.org Fri Feb 03 05:59:32 2012 -0700 +++ b/org/test-creature.org Fri Feb 03 06:01:22 2012 -0700 @@ -1038,34 +1038,6 @@ * COMMENT purgatory #+begin_src clojure -(defn bullet-trans [] - (let [obj-a (sphere 0.5 :color ColorRGBA/Red - :position (Vector3f. -10 5 0)) - obj-b (sphere 0.5 :color ColorRGBA/Blue - :position (Vector3f. -10 -5 0) - :mass 0) - control-a (.getControl obj-a RigidBodyControl) - control-b (.getControl obj-b RigidBodyControl) - swivel - (.toRotationMatrix - (doto (Quaternion.) - (.fromAngleAxis (/ Math/PI 2) - Vector3f/UNIT_X)))] - (doto - (ConeJoint. - control-a control-b - (Vector3f. 0 5 0) - (Vector3f. 0 -5 0) - swivel swivel) - (.setLimit (* 0.6 (/ Math/PI 4)) - (/ Math/PI 4) - (* Math/PI 0.8))) - (world (nodify - [obj-a obj-b]) - standard-debug-controls - enable-debug - no-op))) - (defn bullet-trans* [] (let [obj-a (box 1.5 0.5 0.5 :color ColorRGBA/Red @@ -1159,124 +1131,6 @@ ) )) -(defn transform-trianglesdsd - "Transform that converts each vertex in the first triangle - into the corresponding vertex in the second triangle." - [#^Triangle tri-1 #^Triangle tri-2] - (let [in [(.get1 tri-1) - (.get2 tri-1) - (.get3 tri-1)] - out [(.get1 tri-2) - (.get2 tri-2) - (.get3 tri-2)]] - (let [translate (doto (Matrix4f.) (.setTranslation (.negate (in 0)))) - in* [(.mult translate (in 0)) - (.mult translate (in 1)) - (.mult translate (in 2))] - final-translation - (doto (Matrix4f.) - (.setTranslation (out 1))) - - rotate-1 - (doto (Matrix3f.) - (.fromStartEndVectors - (.normalize - (.subtract - (in* 1) (in* 0))) - (.normalize - (.subtract - (out 1) (out 0))))) - in** [(.mult rotate-1 (in* 0)) - (.mult rotate-1 (in* 1)) - (.mult rotate-1 (in* 2))] - scale-factor-1 - (.mult - (.normalize - (.subtract - (out 1) - (out 0))) - (/ (.length - (.subtract (out 1) - (out 0))) - (.length - (.subtract (in** 1) - (in** 0))))) - scale-1 (doto (Matrix4f.) (.setScale scale-factor-1)) - in*** [(.mult scale-1 (in** 0)) - (.mult scale-1 (in** 1)) - (.mult scale-1 (in** 2))] - - - - - - ] - - (dorun (map println in)) - (println) - (dorun (map println in*)) - (println) - (dorun (map println in**)) - (println) - (dorun (map println in***)) - (println) - - )))) - - -(defn world-setup [joint] - (let [joint-position (Vector3f. 0 0 0) - joint-rotation - (.toRotationMatrix - (.mult - (doto (Quaternion.) - (.fromAngleAxis - (* 1 (/ Math/PI 4)) - (Vector3f. -1 0 0))) - (doto (Quaternion.) - (.fromAngleAxis - (* 1 (/ Math/PI 2)) - (Vector3f. 0 0 1))))) - top-position (.mult joint-rotation (Vector3f. 8 0 0)) - - origin (doto - (sphere 0.1 :physical? false :color ColorRGBA/Cyan - :position top-position)) - top (doto - (sphere 0.1 :physical? false :color ColorRGBA/Yellow - :position top-position) - - (.addControl - (RigidBodyControl. - (CapsuleCollisionShape. 0.5 1.5 1) (float 20)))) - bottom (doto - (sphere 0.1 :physical? false :color ColorRGBA/DarkGray - :position (Vector3f. 0 0 0)) - (.addControl - (RigidBodyControl. - (CapsuleCollisionShape. 0.5 1.5 1) (float 0)))) - table (box 10 2 10 :position (Vector3f. 0 -20 0) - :color ColorRGBA/Gray :mass 0) - a (.getControl top RigidBodyControl) - b (.getControl bottom RigidBodyControl)] - - (cond - (= joint :cone) - - (doto (ConeJoint. - a b - (world-to-local top joint-position) - (world-to-local bottom joint-position) - joint-rotation - joint-rotation - ) - - - (.setLimit (* (/ 10) Math/PI) - (* (/ 4) Math/PI) - 0))) - [origin top bottom table])) - (defn test-joint [joint] (let [[origin top bottom floor] (world-setup joint) control (.getControl top RigidBodyControl) @@ -1341,35 +1195,6 @@ (.applyTorque control (.mult (.getPhysicsRotation control) (Vector3f. 1 0 0)))))))) - - - -(defprotocol Frame - (frame [this])) - -(extend-type BufferedImage - Frame - (frame [image] - (merge - (apply - hash-map - (interleave - (doall (for [x (range (.getWidth image)) y (range (.getHeight image))] - (vector x y))) - (doall (for [x (range (.getWidth image)) y (range (.getHeight image))] - (let [data (.getRGB image x y)] - (hash-map :r (bit-shift-right (bit-and 0xff0000 data) 16) - :g (bit-shift-right (bit-and 0x00ff00 data) 8) - :b (bit-and 0x0000ff data))))))) - {:width (.getWidth image) :height (.getHeight image)}))) - - -(extend-type ImagePlus - Frame - (frame [image+] - (frame (.getBufferedImage image+)))) - - #+end_src