Created
April 4, 2018 21:39
-
-
Save n1ckfg/f0810e3a48a05d6741f5affb6cca7be9 to your computer and use it in GitHub Desktop.
example using nervoussystem ObjExport
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 nervoussystem.obj.*; | |
PImage img; | |
boolean record = false; | |
void setup() { | |
size(600, 400, P3D); | |
img = loadImage("fox.png"); | |
img.loadPixels(); | |
noStroke(); | |
} | |
void draw() { | |
if(record) { | |
beginRecord("nervoussystem.obj.OBJExport", "fox.obj"); | |
} | |
background(255); | |
lights(); | |
translate(width/2, height/2); | |
scale(5); | |
rotateX(mouseY * 0.01); | |
rotateY(mouseX * 0.01); | |
//image(img, 0, 0); | |
for(int x=0; x<100; x++) { | |
for(int y=0; y<100; y++) { | |
int imgx = (int)map(x, 0, 100, 0, img.width); | |
int imgy = (int)map(y, 0, 100, 0, img.height); | |
float bri = brightness(img.get(imgx, imgy)); | |
if(bri > 50) { | |
pushMatrix(); | |
translate(x, y); | |
box(bri/100.0); | |
popMatrix(); | |
} | |
} | |
} | |
if(record) { | |
endRecord(); | |
record = false; | |
} | |
} | |
void keyPressed() { | |
if(key == 's' || key == 'S') { | |
record = true; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment