Hemesh : a 3D mesh library for Processing

UPDATE : He_Mesh has grown enough to give it its own site: http://hemesh.wblut.com/. In time, the new site will con­tain tuto­ri­als and in-depth explanations.

Coded, recoded, lost, recoded and recoded … hemesh, the half-edge mesh library for Processing has slowly accreted to a state that war­rants a release. A release in more than one way. In ret­ro­spect, the cur­rent func­tion­al­ity looks depress­ingly small, espe­cially com­pared to the hun­dreds of hours that already went into cod­ing it. But like a broke home-owner with a base­ment and a half-finished first floor, I com­fort myself with the thought that at least it holds poten­tial for growth.

What is hemesh?

hemesh is an imple­men­ta­tion of a half-edge datastructure for manip­u­lat­ing 3D meshes in Processing. Basically it’s a toolset to extend my Processing sand­box to a proper playground.

Generating and dis­play­ing a mesh requires noth­ing more than a list of ver­tices and a list of faces con­nect­ing them. This hardly requires a spe­cial dataset. However, manip­u­lat­ing a mesh in any but a triv­ial way requires a lot of con­nec­tiv­ity infor­ma­tion: neigh­bor­ing ver­tices, neigh­bor­ing faces, shared edges,… Keeping track of this in a sim­ple facelist type struc­ture is dif­fi­cult. Hence the need for a datas­truc­ture that incor­po­rates con­nec­tiv­ity infor­ma­tion in an effi­cient way: the half-edge mesh.

What can hemesh do?

The library is cur­rently focused on the stuff I coded it for: 3D voronoi and ran­dom plane divi­sions. So with hemesh we can cre­ate 3D meshes. Several prim­i­tives are built-in, but any kind of 2-manifold mesh can be turned into a half-edge mesh from its ver­tices and facelist. The weight of the imple­men­ta­tion lies in closed meshes but open sur­faces are han­dled as well.

Creating meshes is cool (for a given amount of cool) but destroy­ing them is cooler. Several mod­i­fiers are pro­vided, either as part of the basic mesh func­tion­al­ity or as sep­a­rate mod­i­fier classes. Subdividors are a spe­cial class of mod­i­fier ori­ented towards sub­di­vi­sions. (The names might not be orig­i­nal but I guess it’s eas­ier to remem­ber than quaghot and umpsink.)

What hemesh can’t do…

The half-edge datas­truc­ture has a few limitations in itself. In prac­tice, each edge in a mesh can be shared by at most two faces. The imple­men­ta­tion is strongly face-based, iso­lated ver­tices and edges are not sup­ported and will lead to ouchie.

The ini­tial intent of hemesh was to build a sys­tem to pro­to­type geo­met­ric play. So large-scale sys­tems were never a goal. Several imple­mented algo­rithms are O(n²) and use a lot of stor­age. Connaiseurs and lec­tors in com­pu­ta­tional geom­e­try are advised to avoid perus­ing the code, bleed­ing eyes often offend. On the pos­i­tive side, there’s room for improvement…

Getting hemesh

The library is main­tained at code.google.com. hemesh is cur­rently at beta ver­sion Download and extract the archive inside the Processing ‘libraries’ folder. The ‘hemesh’ sub­folder con­tains sev­eral exam­ples. A Processing ver­sion sup­port­ing JAVA 1.5 syn­tax is rec­om­mended, Rev 180 or higher. In the com­ing days, I’ll post some tuto­ri­als and spiel­erei to illus­trate fur­ther use.


At this time, the library reflects my cur­rent inter­ests. If you want it to do some­thing else, have a sug­ges­tion or hemesh goes hay­wire on you, let me know! One major addi­tion is already planned: boolean mesh oper­a­tions. This is a small step away from completion.

Please enable Javascript and Flash to view this Flash video.

import processing.opengl.*;
import wblut.hemesh.*;
import wblut.geom.*;

HE_Mesh box;

void setup(){
  HEC_Box boxCreator=new HEC_Box(this)
  box=new HE_Mesh(boxCreator);
  HEM_Lattice lattice=new HEM_Lattice().setDepth(10)

void draw(){


  1. Nice! This will be really use­ful.
    Hello remesh­ing, dec­i­ma­tion and mesh smooth­ing…

  2. Pingback: designplaygrounds.com » Archive » Processing Libraries

  3. Pingback: Blog de Maestria en AE

  4. Pingback: Code & form » Shakerag workshop – summary and links

  5. Pingback: ГРАФЬЯ И ПРОЧАЯ ТОПОЛОГИЯ | Altsoph The Honest

  6. Looks really great, but I couldn’t use it in my work­flow because of the fol­low­ing prob­lem. Right now all you can get are quad faces, but these are very cum­ber­some to com­bine within a greater project where tri­an­gles are used/required. I tried the func­tions getVer­tice­sAs­Point() and get­Face­sAsInt(), but obvi­ously the last returns the indexes for quads. I tried tri­an­gu­la­tion myself, but didn’t work out 😉 I’m sure it’s pos­si­ble, but unfor­tu­nately don’t have the time right now to work on it. So I would really like to see tri­an­gu­la­tion added (i.e. get­Tri­an­gu­lat­ed­Face­sAsInt or some­thing) so this library would be much more flex­i­ble and eas­ier to use with other projects/libraries.

  7. Hi Amon,

    actu­ally hemesh is general-polygon-based. So there’s no pref­er­ence for quads or tris.
    Triangulation is imple­mented as tri­an­gu­late­Faces(). Have fun.

  8. Excellent! Will try it out some more then, this really helps. Thanks for the quick reply :)

  9. Hi,

    I tried to do a check­out with “svn check­out http://hemesh2010.googlecode.com/svn/trunk/ hemesh2010-read-only”, but this resulted in the fol­low­ing error:

    svn: URL ‘http://hemesh2010.googlecode.com/svn/trunk’ doesn’t exist

    Is the source code (at least the read only) still avail­able somewhere?



  10. Pingback: Sunflow & Processing « Amnon P5 – Experiments with Processing by Amnon Owed

  11. Pingback: “I’m not impressed at all…” « HIDIHO!

  12. Are the Voronoi fea­tures in HeMesh actu­ally 3d voronoi? They look like it but the set­Points oper­a­tor in HEMC_VoronoiCells seem to only take points with (X,Y) coor­di­nates, I’ve been wad­ing through the library and a lot of it is over my head.….. so my apolo­gies if I’ve mis­un­der­stood. The results you’ve got­ten from your cod­ing are thrilling and it’s great to see Processing being pushed to this level of ren­der­ing but I’m won­der­ing if I mis­read the documentation.

    I’m try­ing to fig­ure out on my own how to imple­ment Fortune’s algo­rithm in 3d to quickly gen­er­ate voronoi vol­umes from a given set of points but that’s a few orders of mag­ni­tude more math & pro­gram­ming than I’ve attempted before :) Any advice or tips on using Hemesh for pass­ing an array of points to be turned into Voronoi vol­umes would be appre­ci­ated, if you have the time, of course.


  13. This is a fan­tas­tic library and qual­ity addi­tion to the Processing com­mu­nity. Thanks for this and look­ing for­ward to you mak­ing it to Paris to present your work some day :–)
    Big well done to Amnon too for get­ting this plugged in with ControlP5 & Sunflow.

    regards from Paname.


  14. Pingback: Hemesh : a 3D mesh library for Processing | W:Blut « atcalapadom

  15. Pingback: Exportación de objetos 3d con processing (Parte 2) « Emiliusvgs Projects

  16. Pingback: Hemesh | Mr. mid

  17. Pingback: Gian Carlo Mingati » Blog Archive » 3D shapes with Hemesh

  18. Pingback: < Biomimetic Computation

  19. Pingback: Code & form » Interactive Parametrics – Workshop w/ Studio Mode and MakerBot

  20. Pingback: modeLab

  21. Pingback: Peter Gabriel – New Blood Tour Visuals 2011 | Journal | Stefan Goodchild

  22. Pingback: Lowpoly Lamp « introspector

  23. Pingback: Share&&Tell « introspector

  24. Thanks for this and look­ing for­ward to you mak­ing it to Paris to present your work some day!!

  25. Pingback: Half-Edge Mesh « Quotidien

  26. I can’t seem to down­load the cur­rent ver­sion of the library on http://code.google.com/p/hemesh2010/.

    Is there another way to get it?

    I get this. I’m in the US.

    403. That’s an error.
    Your client does not have per­mis­sion to get URL /files/hemesh_b1_50a.zip from this server. (Client IP address:

    You are access­ing this page from a for­bid­den coun­try. That’s all we know.

  27. Very nice library! Using it for an intern­ship project. Just won­der­ing if it’s pos­si­ble to import stl files to a HE_Mesh? (I can only find an exporter (HET_Export))

  28. Pingback: Algo-fashions, chains of knowledge in creative communities and Jonathan McCabe, fountain of ethereal knowledge | Simple agents in a multiplicity

  29. Pingback: Digital Natives by Matthew Plummer Fernandez | UR Design Magazine

  30. Amazing job! This library looks great!

    I have one ques­tion how­ever, From a list of ver­tices can you gen­er­ate the faces and edges. Or rather could you just explain how the array of faces to array of ver­tices cor­re­late? I’ve gen­er­ated grids using the diamond-square algo­rithm and per­lin noise and would love to try to mesh them out. The 5th tuto­r­ial sort’ve explains how to do this but I’m not quite sure how the faces to ver­tices bit works. Is there a doxy­gen or any­thing of the sort up yet?


  31. Hi

    It looks like a very inter­est­ing tool to dive deeper into, thanks for sharing.

    I do have a bugreport:

    import wblut.hemesh.options.*;
    is caus­ing an error, since this pack­age is not inside your pro­vided jars (I assume — at least not in hemesh.jar)

    And in /spielerei/Collapse
    import java.util.*;
    is miss­ing since you are using Iterator somewhere…



  32. Pingback: Processing and 3D printing resources to research…

  33. Pingback: designplaygrounds.com » Archive » Digital Natives by Matthew Plummer-Fernandez

  34. Pingback: Generative Art Initiative — transforming code into art

  35. Hi,

    This looks like a great library.
    Can it now also do boolean mesh operations?

    I need this for a cur­rent project. I would like to script the gen­er­a­tion of text, then extrude this text and use a boolean union to merge it with a (flat) object, which I then want to 3d print to make it phys­i­cal. Any ideas or tips are very much appreciated.



  36. Pingback: Geodesic Sphere with Processing and Makerbot Replicator 2 | Funbie Studios

  37. Pingback: Exportación de objetos 3d con processing (Parte 2) | EmiliusvgsEmiliusvgs

  38. Pingback: 3D shapes with Hemesh | Gian Carlo Mingati

  39. Pingback: Digital Natives - 3D printed glitch art - Remote Presence Magazine

Leave a Reply

Your email address will not be published.