IL 2016 SS
import peasy.*;
import peasy.org.apache.commons.math.*;
import peasy.org.apache.commons.math.geometry.*;
import peasy.test.*;
PeasyCam cam;
PImage moonImg;
float[] colorData;
int stepSize = 7;
PShape s;
void setup() {
size(500, 500, P3D);
cam = new PeasyCam(this, 500);
moonImg = loadImage("415183808_9d19a12439.jpg");
cam.setMinimumDistance(50);
cam.setMaximumDistance(500);
noStroke();
int _sumNum = 500 * 500;
colorData = new float[_sumNum];
for (int j=0; j<500; j+=stepSize) {
for (int i=0; i<500; i+=stepSize) {
int _index = i + j * 500;
color _c = moonImg.get(i, j);
float _sum = red(_c) + green(_c) + blue(_c);
colorData[_index] = _sum / 3.0;
}
}
float _height = 0.5;
s = createShape();
s.beginShape();
s.texture(moonImg);
for (int j=0; j<500-stepSize; j+=stepSize) {
for (int i=0; i<500-stepSize; i+=stepSize) {
s.vertex(i, j, red(moonImg.get(i, j))*_height, i, j);
s.vertex(i, j+500*stepSize, red(moonImg.get(i, j+500*stepSize))*_height, i, j+500*stepSize);
s.vertex(i+stepSize, j+500*stepSize, red(moonImg.get(i+stepSize, j+500*stepSize))*_height, i+stepSize, j+500*stepSize);
s.vertex(i+stepSize, j, red(moonImg.get(i+stepSize, j))*_height, i+stepSize, j);
}
}
s.endShape(CLOSE);
}
void draw() {
background(0);
translate(-250, -250);
shape(s);
}