Skip to content

Instantly share code, notes, and snippets.

Created September 10, 2015 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/beed972250370256653a to your computer and use it in GitHub Desktop.
Save anonymous/beed972250370256653a to your computer and use it in GitHub Desktop.
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