Sketch 2015-05-27
void ofApp::setupAnim() {
ofEnableSmoothing();
numPerDimension = 3;
for(int x = 0; x < numPerDimension; x++) {
for(int y = 0; y < numPerDimension; y++) {
for(int z = 0; z < numPerDimension; z++) {
cube = ofxShapeSystem();
cube.setupCube(2, ofRandom(100, 200), ofColor(ofColor::red, 255));
cube.setRotation(ofRandom(360), ofRandom(360), ofRandom(360));
cube.positionX(ofMap(x, 0, numPerDimension-1, 0, width));
cube.positionY(ofMap(y, 0, numPerDimension-1, 0, height));
cube.positionZ(ofMap(z, 0, numPerDimension, 250, -250));
cubes.push_back(cube);
}
}
}
}
void ofApp::updateAnim() {
for(int i = 0; i < cubes.size(); i++) {
cubes.at(i).incrementRotateX(2);
cubes.at(i).incrementRotateY(2);
cubes.at(i).incrementRotateZ(2);
}
}
void ofApp::drawAnim() {
ofBackground(0, 0, 0);
ofEnableAlphaBlending();
rotateScreen(ofGetFrameNum() * 2);
for(int i = 0; i < cubes.size(); i++) {
cubes.at(i).draw();
}
if(ofGetFrameNum() == 180) renderGif();
}
void ofApp::rotateScreen(float degrees) {
ofTranslate(halfWidth, halfHeight, 0);
ofRotateX(degrees);
ofTranslate(-halfWidth, -halfHeight, 0);
}
Hmm. Cubes.