<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>W:Blut He_Mesh</title>
	<atom:link href="http://hemesh.wblut.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://hemesh.wblut.com</link>
	<description>A Processing library for mesh creation and manipulation</description>
	<lastBuildDate>Tue, 06 Mar 2012 13:56:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>HE_Mesh: a 3D library for Processing</title>
		<link>http://hemesh.wblut.com/2011/09/19/he_mesh-a-3d-library-for-processing/</link>
		<comments>http://hemesh.wblut.com/2011/09/19/he_mesh-a-3d-library-for-processing/#comments</comments>
		<pubDate>Sun, 18 Sep 2011 22:20:58 +0000</pubDate>
		<dc:creator>Frederik</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://hemesh.wblut.com/?p=8</guid>
		<description><![CDATA[Download the latest version here. Coded, recoded, lost, recoded and recoded … HE_Mesh, 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 [...]]]></description>
			<content:encoded><![CDATA[<div style="float:left; width:500px;">
<p>Download the latest version  <a href="http://code.google.com/p/hemesh2010/downloads/list">here</a>.</p>
<blockquote><p>Coded, recoded, lost, recoded and recoded … <em>HE_Mesh</em>, 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 it holds potential for growth.</p>
</blockquote>
<p>At least, that’s what I wrote more than a year ago. Some of the basement turned out mouldy, the first floor is somewhat basic but liveable. The second floor is taking shape and the garden is filled with a variety of half-finished sheds… No doubt about it, I’m a <a href="http://www.flickr.com/photos/50456832@N06/5041673417/" title="Koterij in België">belgian</a>.</p>
</p>
<h3>What is <em>HE_Mesh</em>?</h3>
<p><em>HE_Mesh</em> is an implementation of a <a href="http://www.cgafaq.info/wiki/Half_edge_general">half-edge datastructure</a> for manipulating 3D meshes in Processing. Basically it’s a toolset to extend my Processing sandbox to a proper playground.</p>
<p>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 <a href="http://www.cgafaq.info/wiki/Half_edge_general">half-edge mesh</a>.</p>
<h3>What can <em>HE_Mesh</em> do?</h3>
<p>The library is currently focused on the stuff I coded it for: generative/degenerative geometry. So with <em>HE_Mesh</em> we can create and manipulate 3D meshes. Several primitives are built-in, but any kind of <a href="http://en.wikipedia.org/wiki/2-manifold">2-manifold</a> 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.</p>
<p>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.)</p>
<h3>What <em>HE_Mesh</em> can’t do…</h3>
<p>The half-edge datastructure has <a href="http://www.cgafaq.info/wiki/Half_edge_capabilities">a few limitations</a> 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.
</p>
<p>The initial intent of <em>HE_Mesh</em> 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…</p>
<p>HE_Mesh doesn’t turn Processing into RhinoJava or 3D Studio Processing. It does not provide a GUI to manipulate meshes on-screen. Neither was it conceived as a modelling library. Still, HE_Mesh provides the elements needed to build such an application if needed.</p>
<h3>Getting <em>HE_Mesh</em></h3>
<p>The library is maintained at <a href="http://code.google.com/p/hemesh2010/">code.google.com</a>. <em>HE_Mesh</em> is currently at beta version 1.5.0. Download and extract the  <a href="http://code.google.com/p/hemesh2010/downloads/list">archive</a> inside the Processing ‘libraries’ folder. The ‘reference’ and ‘tutorial’ subfolders contain several examples.</p>
<h3>Future</h3>
<p>At this time, the library reflects my current interests. If you want it to do something else, have a suggestion or <em>HE_Mesh</em> goes haywire on you, let <a href="http://www.wblut.com/about/">me</a> know! </p>
</div>
<div style="float:right; width:400px;">
<pre><code>
import wblut.hemesh.modifiers.*;
import wblut.core.processing.*;
import wblut.hemesh.creators.*;
import wblut.hemesh.core.*;

HE_Mesh mesh;
WB_Render render;

void setup() {
&nbsp;&nbsp;size(800, 800, P3D);
&nbsp;&nbsp;createMesh();

&nbsp;&nbsp;HEM_SphereInversion modifier=new HEM_SphereInversion();
&nbsp;&nbsp;modifier.setRadius(200);
&nbsp;&nbsp;modifier.setCenter(50, 0, 0);
&nbsp;&nbsp;modifier.setCutoff(1000);
&nbsp;&nbsp;modifier.setLinear(false);
&nbsp;&nbsp;mesh.modify(modifier);

&nbsp;&nbsp;render=new WB_Render(this);
}

void draw() {
&nbsp;&nbsp;background(120);
&nbsp;&nbsp;directionalLight(255, 255, 255, 1, 1, -1);
&nbsp;&nbsp;directionalLight(127, 127, 127, -1, -1, 1);
&nbsp;&nbsp;translate(400, 400, 0);
&nbsp;&nbsp;rotateY(mouseX*1.0f/width*TWO_PI);
&nbsp;&nbsp;rotateX(mouseY*1.0f/height*TWO_PI);
&nbsp;&nbsp;fill(255);
&nbsp;&nbsp;noStroke();
&nbsp;&nbsp;render.drawFaces(mesh);
&nbsp;&nbsp;stroke(0);
&nbsp;&nbsp;render.drawEdges(mesh);
}

void createMesh() {
&nbsp;&nbsp;HEC_Cube creator=new HEC_Cube(300, 1,1, 1);
&nbsp;&nbsp;mesh=new HE_Mesh(creator);
&nbsp;&nbsp;mesh.modify(new HEM_Extrude().setDistance(300));
&nbsp;&nbsp;mesh=new HE_Mesh(new HEC_FromFrame().setFrame(mesh).setMaximumStrutLength(20));
}

</code></pre></p>
</div>
<div style="clear:both"></div>
<div style="float:left; width:500px;">
<h3>Did you code all of <em>HE_Mesh</em>?</h3>
<p>Sometimes you get wrapped up in writing a piece of code, getting it to work your only purpose. Inevitably you turn to existing code, ripping and tearing through it to get at its beating heart.</p>
<p>With the internet providing access to such an amount of information, it can be easy to forget where a particular solution came from. On the other hand, including complete generic libraries to benefit from a few classes in specific instances would quickly bloat any project. I tried to compile a list of code that was ravaged for the good of HE_Mesh:</p>
<ol>
<li><a href="http://javolution.org/">Javolution</a> is included in the  HE_Mesh distribution. This high-performance library offers fast, reliable alternatives for many of JAVA’s basic classes. Without FastTable and FastMap,  HE_Mesh would be a lot slower.</li>
<li><a href="http://www.savarese.com/software/libssrckdtree-j/">libssrckdtree-j Generic k-d tree Java library</a>: only a barebone skeleton remains of this truly generic k-d tree implementation, wblut.tree.WB_KDTree and wblut.tree.WB_KDNeighbor. It provides lightning-fast closest-point calculation and degenerate-vertex checking. Although k-d tree algorithms are well-described, implementing a fast one yourself is a less than trivial task.</li>
<li><a href="http://www.cs.gmu.edu/~sean/research/">Sean Luke’s fast Mersenne Twister random number generator</a> is my preferred RNG throughout hemesh. For (my) convenience it is exposed through wblut.math.WB_MTRandom, WB_RandomDisc and WB_RandomSphere.</li>
<li>Marius Watz’ <a href="http://workshop.evolutionzone.com/unlekkerlib/">unlekkerLib</a> provided the foundation for the wblut.hemesh.HE_Mesh.saveToSTL function.</li>
<li>The Fortune’s sweep algorithm for 2D Voronoi is often discussed but rarely implemented. wblut.geom.WB_Voronoi2D is a bare-bones adaptation of <a href="http://shaneosullivan.wordpress.com/2007/04/05/fortunes-sweep-line-voronoi-algorithm-implemented-in-java/">Zhenyu Pan’s JAVA transcription</a> of Shane O’Sullivan’s C implementation
</li>
<li> <a href="http://www.cs.ubc.ca/~lloyd/java/quickhull3d.html">John Lloyd’s QuickHull3D pack­age</a> makes a reappearance as a convex hull generator for the wblut.hemesh.modifiers.HEM_Wireframe joints.
</li>
</ol>
<p>Not only code is scavenged without mercy, a whole range of reference material on algorithms is scoured:</p>
<ol>
<li>The<a href="http://local.wasp.uwa.edu.au/~pbourke/"> über-reference Paul Bourke</a>. Invaluable for many geometric algorithms, especially in HEC_IsoSurface.</li>
<li><a href="http://www.amazon.com/exec/obidos/tg/detail/-/1558607323?tag=realtimecolli-20">Christer Ericson’s Real-time Collision Detection</a> for many of the geometric datastructures and intersection algorithms in wblut.geom.</li>
<li><a href="http://www.cs.umbc.edu/~squire/">Code provided by Jon Squire</a> served as the starting point for the basic platonic solid creators in wblut.hemesh.</li>
<li> <a href="http://www.flickr.com/photos/onecm/5142412580/">Scloopy</a>‘s reference to <a href="http://repository.tamu.edu/bitstream/handle/1969.1/548/etd-tamu-2004A-VIZA-mandal-1.pdf">a paper by Mandal and Esan</a> proved just the thing I needed for wblut.hemesh.modifiers.HEM_Wireframe.</li>
<li> A thousand page tome has added its burden to my desk: <a href="http://www.amazon.com/Geometric-Computer-Graphics-Morgan-Kaufmann/dp/1558605940">Geometric Tools for Computer Graphics</a> by Philip Schneider and David Eberly. Its contents are increasingly implemented in  HE_Mesh’s geometric backbone. If  HE_Mesh turns out to be stable, this book deserves the praise. If not,  it’s me that messed up somewhere…</li>
<li><a href="http://www.flickr.com/photos/imagedesmaths/">David Marec</a> was so gracious to provide me with meticulously compiled vertex and connectitivity data for a whole host of polyhedra. Not only was the data flawless, it was also almost directly usable. A rare fortune indeed.
</li>
</ol>
<p>While  HE_Mesh grows into different areas, these lists will undoubtedly expand. I just hope the need for proper bookkeeping won’t spoil the fun of coding… </p>
</div>
<div style="clear:both;"></div>
]]></content:encoded>
			<wfw:commentRss>http://hemesh.wblut.com/2011/09/19/he_mesh-a-3d-library-for-processing/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

