Skip to content

Instantly share code, notes, and snippets.

@madhephaestus
Last active January 2, 2016 03:04
Show Gist options
  • Save madhephaestus/b291a2ae501250be018d to your computer and use it in GitHub Desktop.
Save madhephaestus/b291a2ae501250be018d to your computer and use it in GitHub Desktop.
(import '[eu.mihosoft.vrl.v3d STL Cube Cylinder Extrude RoundedCube Sphere Vector3d Transform])
(defn move-x
[obj n]
(.transformed obj (.translateX (Transform/unity) n)))
(defn move-y
[obj n]
(.transformed obj (.translateY (Transform/unity) n)))
(defn union-all [& objs]
(reduce (fn [a b] (.union a b)) objs))
(let [size 40.0
cube (.toCSG (Cube. size size size))
cylinder (.toCSG (Cylinder. (/ size 4) (/ size 2) size 80))
sphere (.toCSG (Sphere. (* 12.5 (/ size 20))))
rounded-cube (.toCSG
(doto (RoundedCube. size size size)
(.cornerRadius (/ size 10))))]
(union-all
cube
(move-y sphere (* 1.5 size))
(move-y (.union cube sphere) (* 3 size))
(move-y (.difference cube sphere) (* 5 size))
(move-y (.intersect cube sphere) (* 7 size))
(move-x cylinder (* size 3))
(move-x rounded-cube (* size 8))
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment