#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup() {
ofSetFrameRate(25);
ofSetWindowTitle("openframeworks");
ofBackground(39);
ofEnableDepthTest();
ofSetLineWidth(3);
}
//--------------------------------------------------------------
void ofApp::update() {
}
//--------------------------------------------------------------
void ofApp::draw() {
this->cam.begin();
int width = 150;
int height = 150;
int len = 10;
for (int x = -150; x <= 0; x += 300) {
for (int z = -20; z <= 20; z += 2) {
ofPushMatrix();
ofTranslate(0, 0, z);
ofRotate(ofMap(ofNoise((z + 100) * 0.01 + ofGetFrameNum() * 0.005), 0, 1, -1440, 1440));
ofFill();
ofSetColor(0, ofMap(z, -20, 20, 0, 255));
ofBeginShape();
ofVertex(glm::vec2(x + width * -0.5, height * -0.5));
ofVertex(glm::vec2(x + width * 0.5, height * -0.5));
ofVertex(glm::vec2(x + width * 0.5, height * 0.5));
ofVertex(glm::vec2(x + width * -0.5, height * 0.5));
ofNextContour(true);
ofVertex(glm::vec2(x + width * -0.5 + len, height * -0.5 + len));
ofVertex(glm::vec2(x + width * 0.5 - len, height * -0.5 + len));
ofVertex(glm::vec2(x + width * 0.5 - len, height * 0.5 - len));
ofVertex(glm::vec2(x + width * -0.5 + len, height * 0.5 - len));
ofEndShape(true);
ofNoFill();
ofSetColor(255, ofMap(z, -20, 20, 0, 255));
ofBeginShape();
ofVertex(glm::vec2(x + width * -0.5, height * -0.5));
ofVertex(glm::vec2(x + width * 0.5, height * -0.5));
ofVertex(glm::vec2(x + width * 0.5, height * 0.5));
ofVertex(glm::vec2(x + width * -0.5, height * 0.5));
ofNextContour(true);
ofVertex(glm::vec2(x + width * -0.5 + len, height * -0.5 + len));
ofVertex(glm::vec2(x + width * 0.5 - len, height * -0.5 + len));
ofVertex(glm::vec2(x + width * 0.5 - len, height * 0.5 - len));
ofVertex(glm::vec2(x + width * -0.5 + len, height * 0.5 - len));
ofEndShape(true);
ofPopMatrix();
}
}
this->cam.end();
/*
int start = 500;
if (ofGetFrameNum() > start) {
ostringstream os;
os << setw(4) << setfill('0') << ofGetFrameNum() - start;
ofImage image;
image.grabScreen(0, 0, ofGetWidth(), ofGetHeight());
image.saveImage("image/cap/img_" + os.str() + ".jpg");
if (ofGetFrameNum() - start >= 25 * 20) {
std::exit(1);
}
}
*/
}
//--------------------------------------------------------------
int main() {
ofSetupOpenGL(720, 720, OF_WINDOW);
ofRunApp(new ofApp());
}