> For 3D calculations, (verlet) physics and more there's the java library
> toxiclibs (http://toxiclibs.org), whose author is currently
porting/wrapping
> to Clojure. It's not really a cut-and-dried solution, but it's pretty
> flexible and has a simple API unlike a lot of 3D projects which focus
> very narrowly on games development.

Hi guys,

the Clojure version of toxiclibs is NOT going to be a wrapper of the
existing Java version, but a complete re-write & opportunity to re-think
the current architecture and benefit from Clojure's qualities (e.g.
protocols & concurrency). Also, both the Java and the upcoming Clojure
version are actually only focussed on generic operations & data structures
for 2d/3d geometry tasks, interpolation, verlet physics simulation, voxels,
color theory and related concepts. Neither deals with rendering/displaying
the results.

So far the Clojure version is still very alpha, and only parts of the core
library have been implemented (geometry tools, mesh & OBJ export)...

The repository is here (but lacking any documentation, check the tests,
though, for general usage):
http://hg.postspectacular.com/toxiclibs.clj/
http://hg.postspectacular.com/toxiclibs.clj/src/tip/test/toxi/test/geom.clj

A recent version is also on Clojars:

[org.toxiclibs/toxiclibs-clj "0.2.0-SNAPSHOT"]

As mentioned, am making heavy use of protocols (and defrecords). Here's a
slightly outdated map to show the overall structure:

http://flickr.com/photos/toxi/7002599609

To give you a better idea, below is also a little example to generate a 3D
cog mesh and export it as OBJ model (e.g. for 3D printing or use with other
3D tools):  The fn creates a circle, converts it to a polygon, deforms the
perimeter to create teeth based on a user provided profile, then tesselates
& extrudes the polygon into a triangle mesh...

(use 'toxi.geom.core 'toxi.geom.polygon2d 'toxi.geom.mesh.objexport)

(defn cog
  [radius teeth profile depth]
  (let[nump (count profile)
       parts (->
               (circle radius)
               (->polygon2d (* teeth nump))
               :vertices
               (->> (partition nump)))
       poly (->
              (map (fn[_] (map (fn[v s] (scale-n v s)) _ profile)) parts)
              flatten
              polygon2d)
       mesh (tesselate poly)
       mesh (add-meshes mesh
              [(-> mesh flip (transform (translate (matrix4x4) 0 0 depth)))
               (extrude poly (vec3d 0 0 1) depth)])]
    mesh))

(spit "cog.obj" (->obj (cog 100 10 [1 1.25 1.25 1] 20)))

Result: http://flickr.com/photos/toxi/6856447350/

Best,
K.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to