Last active
April 26, 2016 18:48
-
-
Save arnaudjuracek/8766cde42b0a4e3f7c88fd3dce1e64f3 to your computer and use it in GitHub Desktop.
Toxiclibs<>HE_mesh : convert TriangleMesh to HE_mesh, and HE_mesh to TriangleMesh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Iterator; | |
import java.util.List; | |
import wblut.processing.*; | |
import wblut.core.*; | |
import wblut.hemesh.*; | |
import wblut.geom.*; | |
import toxi.geom.*; | |
import toxi.geom.mesh.*; | |
import toxi.processing.*; | |
TriangleMesh hemeshToToxi(HE_Mesh m){ | |
m.triangulate(); | |
TriangleMesh tmesh = new TriangleMesh(); | |
Iterator<HE_Face> fItr = m.fItr(); | |
HE_Face f; | |
while(fItr.hasNext()){ | |
f = fItr.next(); | |
List<HE_Vertex> v = f.getFaceVertices(); | |
tmesh.addFace( | |
new Vec3D(v.get(0).xf(), v.get(0).yf(), v.get(0).zf()), | |
new Vec3D(v.get(1).xf(), v.get(1).yf(), v.get(1).zf()), | |
new Vec3D(v.get(2).xf(), v.get(2).yf(), v.get(2).zf())); | |
} | |
return tmesh; | |
} | |
HE_Mesh toxiToHemesh(TriangleMesh m){ | |
String path = "/tmp/processing_toxiToHemesh"; | |
m.saveAsOBJ(path); | |
return new HE_Mesh(new HEC_FromOBJFile(path)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
source :
https://forum.processing.org/two/discussion/5565/a-simple-he-mesh-to-toxiclibs-trianglemesh-conversion-function