Coded, recoded, lost, recoded and recoded … hemesh, the half-edge mesh library for Processing has slowly accreted to a state that warrants a release. A release in more than one way. In retrospect, the current functionality looks depressingly small, especially compared to the hundreds of hours that already went into coding it. But like a broke home-owner with a basement and a half-finished first floor, I comfort myself with the thought that at least it holds potential for growth.
hemesh is an implementation of a half-edge datastructure for manipulating 3D meshes in Processing. Basically it’s a toolset to extend my Processing sandbox to a proper playground.
Generating and displaying a mesh requires nothing more than a list of vertices and a list of faces connecting them. This hardly requires a special dataset. However, manipulating a mesh in any but a trivial way requires a lot of connectivity information: neighboring vertices, neighboring faces, shared edges,… Keeping track of this in a simple facelist type structure is difficult. Hence the need for a datastructure that incorporates connectivity information in an efficient way: the half-edge mesh.
The library is currently focused on the stuff I coded it for: 3D voronoi and random plane divisions. So with hemesh we can create 3D meshes. Several primitives are built-in, but any kind of 2-manifold mesh can be turned into a half-edge mesh from its vertices and facelist. The weight of the implementation lies in closed meshes but open surfaces are handled as well.
Creating meshes is cool (for a given amount of cool) but destroying them is cooler. Several modifiers are provided, either as part of the basic mesh functionality or as separate modifier classes. Subdividors are a special class of modifier oriented towards subdivisions. (The names might not be original but I guess it’s easier to remember than quaghot and umpsink.)
The half-edge datastructure has a few limitations in itself. In practice, each edge in a mesh can be shared by at most two faces. The implementation is strongly face-based, isolated vertices and edges are not supported and will lead to ouchie.
The initial intent of hemesh was to build a system to prototype geometric play. So large-scale systems were never a goal. Several implemented algorithms are O(n²) and use a lot of storage. Connaiseurs and lectors in computational geometry are advised to avoid perusing the code, bleeding eyes often offend. On the positive side, there’s room for improvement…
The library is maintained at code.google.com. hemesh is currently at beta version 1.1.0 Download and extract the archive inside the Processing ‘libraries’ folder. The ‘hemesh’ subfolder contains several examples. A Processing version supporting JAVA 1.5 syntax is recommended, Rev 180 or higher. In the coming days, I’ll post some tutorials and spielerei to illustrate further use.
At this time, the library reflects my current interests. If you want it to do something else, have a suggestion or hemesh goes haywire on you, let me know! One major addition is already planned: boolean mesh operations. This is a small step away from completion.
import processing.opengl.*;
import wblut.hemesh.*;
import wblut.geom.*;
HE_Mesh box;
void setup(){
size(600,600,OPENGL);
hint(ENABLE_OPENGL_4X_SMOOTH);
HEC_Box boxCreator=new HEC_Box(this).setWidth(400).setWidthSegments(10)
.setHeight(200).setHeightSegments(4)
.setDepth(200).setDepthSegments(4);
boxCreator.setCenter(100,100,0).setAxis(1,1,1);
box=new HE_Mesh(boxCreator);
HEM_Lattice lattice=new HEM_Lattice().setDepth(10).setWidth(10)
.setFuse(true).setThresholdAngle(HALF_PI);
box.modify(lattice);
}
void draw(){
background(120);
lights();
translate(300,300,0);
rotateY(mouseX*1.0f/width*TWO_PI);
rotateX(mouseY*1.0f/height*TWO_PI);
noStroke();
box.drawFaces();
stroke(0);
box.drawEdges();
}
thanks again for the superb and hard work!
super!
regards,
corneel
Looks pretty damn nice. Look forward to playing with it!
Amazing job. Great open source library.
Thanks
Nice! This will be really useful.
Hello remeshing, decimation and mesh smoothing…
Thanks.
[…] Hemesh: An implementation of a half-edge datastructure for manipulating 3D meshes in Processing. […]
[…] lograr hacer un ‘mesh’ en el cubo para futuras alteraciones con randomSeed(). Encontré ‘Hemesh‘ que salió el 4 de Mayo (Hace menos de un mes! Que […]
[…] model viewer — unwrappingLib for polygon unwrapping — Unfold Fab project for 3D printing ceramics — Hemesh library for complex 3D […]
[…] Hemesh — реализация half-edge structures под язык Processing. Красивые […]
Looks really great, but I couldn’t use it in my workflow because of the following problem. Right now all you can get are quad faces, but these are very cumbersome to combine within a greater project where triangles are used/required. I tried the functions getVerticesAsPoint() and getFacesAsInt(), but obviously the last returns the indexes for quads. I tried triangulation myself, but didn’t work out
I’m sure it’s possible, but unfortunately don’t have the time right now to work on it. So I would really like to see triangulation added (i.e. getTriangulatedFacesAsInt or something) so this library would be much more flexible and easier to use with other projects/libraries.
Hi Amon,
actually hemesh is general-polygon-based. So there’s no preference for quads or tris.
Triangulation is implemented as triangulateFaces(). Have fun.
Excellent! Will try it out some more then, this really helps. Thanks for the quick reply