Skip to content

Instantly share code, notes, and snippets.

@tnoborio
Created May 23, 2010 07:33
Show Gist options
  • Save tnoborio/410729 to your computer and use it in GitHub Desktop.
Save tnoborio/410729 to your computer and use it in GitHub Desktop.
(ns test3d.core
(:import java.applet.Applet
java.awt.BorderLayout
[javax.media.j3d BranchGroup TransformGroup
Transform3D]
javax.vecmath.AxisAngle4d
[com.sun.j3d.utils
applet.MainFrame universe.SimpleUniverse
geometry.ColorCube]))
(defn config []
(SimpleUniverse/getPreferredConfiguration))
(defn root-scene []
(let [scene (BranchGroup.)
t3d (Transform3D.)
rotY (Transform3D.)]
(.setRotation t3d (AxisAngle4d. 0.57 0.57 -0.57 (/ (Math/PI) 4.0)))
(let [trans (TransformGroup. t3d)]
(.addChild scene trans)
(.addChild trans (ColorCube. 0.4))
scene)))
(defn universe [c]
(let [univ (SimpleUniverse. c)]
(.. univ
getViewingPlatform
setNominalViewingTransform)
(.addBranchGraph univ (root-scene))
univ))
(defn canvas []
(let [c (Canvas3D. (config))]
(universe c)
c))
(defn applet []
(let [ap (proxy [Applet] []
(paint [g]
(.drawLine g 100 100 300 400)))]
(prn ap)
(.setLayout ap (BorderLayout.))
(.add ap (canvas) BorderLayout/CENTER)
ap))
; (applet)
(MainFrame. (applet) 500, 500)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment