Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
197.119 HE_Mesh example (2015)
/* Import all the HE_Mesh libraries */
import wblut.processing.*;
import wblut.hemesh.*;
import wblut.geom.*;
import wblut.math.*;
import java.util.List;
WB_Render render;
HE_Mesh mesh;
void setup(){
size( 800, 600, P3D );
// Making a Sphere
HEC_Sphere creator = new HEC_Sphere();
creator.setRadius(200);
mesh = new HE_Mesh(creator);
/*
// This snippet takes the mesh and adds noise to the vertices, randomising the shape.
HEM_Noise modifier=new HEM_Noise();
modifier.setDistance(30);
mesh.modify(modifier);
*/
render = new WB_Render( this);
}
void draw(){
background( 0 );
lights();
translate( width/2, height/2 );
rotateX( mouseY*1.0 / width * TWO_PI );
rotateY( mouseX*1.0 / height * TWO_PI );
noStroke();
fill(255);
render.drawFaces(mesh);
}
// Save when 'p' key is pressed. Goes into sketch folder.
void keyPressed() {
if (key=='p') {
mesh.triangulate(); // This step makes sure all the faces are generated correctly
HET_Export.saveToSTL( mesh, sketchPath(""), "mesh.stl" );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.