jeonghopark
4/19/2016 - 6:47 PM

IL 2016 SS

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 = 100;

PShape s;

void setup() {
    
  size(1280, 700, P3D);
  
  colorMode(HSB);
  
  cam = new PeasyCam(this, 3500);
  moonImg = loadImage("LDEM_16.jpg");
  cam.setMinimumDistance(50);
  cam.setMaximumDistance(5500);

  noStroke();

  int _sumNum = moonImg.width * moonImg.height;
  colorData = new float[_sumNum];

  for (int j=0; j<moonImg.height; j+=stepSize) {
    for (int i=0; i<moonImg.width; i+=stepSize) {
      int _index = i + j * moonImg.width;
      color _c = moonImg.get(i, j);
      //float _sum = red(_c) + green(_c) + blue(_c);
      colorData[_index] = saturation(_c);
    }
  }


  float _height = 0.5;

  s = createShape();
  s.beginShape();
  s.texture(moonImg);
  for (int j=0; j<moonImg.height-stepSize; j+=stepSize) {
    for (int i=0; i<moonImg.width-stepSize; i+=stepSize) {
      s.vertex(i, j, red(moonImg.get(i, j))*_height, i, j);
      s.vertex(i, j+moonImg.width*stepSize, red(moonImg.get(i, j+moonImg.width*stepSize))*_height, i, j+moonImg.width*stepSize);
      s.vertex(i+stepSize, j+moonImg.width*stepSize, red(moonImg.get(i+stepSize, j+moonImg.width*stepSize))*_height, i+stepSize, j+moonImg.width*stepSize);
      s.vertex(i+stepSize, j, red(moonImg.get(i+stepSize, j))*_height, i+stepSize, j);
    }
  }
  s.endShape();
  
}


void draw() {

  background(0);

  translate(-moonImg.width * 0.5, -moonImg.height * 0.5);
  shape(s);
  
}