Created
June 9, 2017 01:53
-
-
Save echophon/3be2b82b27657146cbe59dc84108aaac to your computer and use it in GitHub Desktop.
This file contains hidden or 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 wblut.processing.*; | |
import wblut.hemesh.*; | |
import wblut.geom.*; | |
import wblut.math.*; | |
HE_Mesh mesh; | |
WB_Render render; | |
int frames = 120; | |
float t = 0.0; | |
float[] s = new float[64*6]; //face segements * cube sides, for retaining our random selections | |
void setup() { | |
size(1000, 1000,P3D); | |
smooth(8); | |
render=new WB_Render(this); | |
// populate selections | |
for (int i=0; i<(64*6); i++){ | |
s[i] = random(100); | |
} | |
} | |
void draw() { | |
background(55); | |
t = ((float)(frameCount%frames) / frames) * TWO_PI; | |
HEC_Box creator = new HEC_Box(); | |
float size = 200 + (50*sin(t)); | |
creator.setWidth(size).setHeight(size).setDepth(size); | |
creator.setWidthSegments(8).setHeightSegments(8).setDepthSegments(8); | |
mesh = new HE_Mesh(creator); | |
// make a selection | |
HE_Selection selection = new HE_Selection(mesh); | |
HE_FaceIterator fItr = mesh.fItr(); | |
HE_Face f; | |
int i=0; | |
while(fItr.hasNext()) { | |
f=fItr.next(); | |
if (s[i] < 20){ | |
selection.add(f); | |
} | |
i++; | |
} | |
HEM_Extrude extrude = new HEM_Extrude().setDistance(120*abs(sin(t))); | |
selection.modify(extrude); | |
pushMatrix(); | |
translate(width/2, height/2, 0); | |
rotateX(sin(t)*0.5); | |
rotateY(cos(t)*0.5); | |
stroke(0); | |
render.drawEdges(mesh); | |
noStroke(); | |
render.drawFaces(mesh); | |
popMatrix(); | |
if (frameCount <= frames){ | |
saveFrame("frames/image-#####.png"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment