Sketch 2015-06-06
void ofApp::setupAnim() {
ofDisableArbTex();
setupImage("surface.png", &img, &tex);
plane.setResolution(2, 2);
offset.set(1, 0.04);
}
void ofApp::setupImage(string file, ofImage *img, ofTexture *tex) {
img->loadImage(file);
*tex = img->getTextureReference();
tex->setTextureWrap(GL_MIRRORED_REPEAT, GL_MIRRORED_REPEAT);
}
void ofApp::drawLayer(ofTexture *tex) {
tx0 = offset.x;
ty0 = offset.y;
tx1 = tx0 - 0.66666668;
ty1 = ty0 - 1;
plane.setPosition(halfWidth, halfHeight, 0);
plane.set(width, height);
plane.mapTexCoords(tx0, ty0, tx1, ty1);
plane.mapTexCoords(tx1, ty1, tx0, ty0);
tex->bind();
plane.draw();
tex->unbind();
}
void ofApp::drawLayer2(ofTexture *tex) {
tx0 = offset.x - (0.66666668 * 0.5);
ty0 = offset.y -0.5;
tx1 = tx0 - (0.66666668 * 0.5);
ty1 = ty0 - 0.5;
plane.setPosition(halfWidth*0.5, halfHeight*0.5, 0);
plane.set(halfWidth, halfHeight);
plane.mapTexCoords(tx0, ty0, tx1, ty1);
plane.mapTexCoords(tx1, ty1, tx0, ty0);
tex->bind();
plane.draw();
tex->unbind();
}
void ofApp::rotateScreen(float degrees, int amount) {
ofTranslate(amount, amount, 0);
ofRotate(degrees);
ofTranslate(-amount, -amount, 0);
}
void ofApp::updateAnim(){
offset.x += 0.02;
}
void ofApp::drawAnim() {
ofBackground(ofColor::black);
ofSetColor(ofColor::wheat);
offset.y = 0.02;
drawLayer(&tex);
rotateScreen(90, halfWidth);
drawLayer(&tex);
rotateScreen(90, halfHeight);
drawLayer(&tex);
rotateScreen(90, halfWidth);
drawLayer(&tex);
rotateScreen(90, halfHeight);
drawLayer2(&tex); //cover up
if(ofGetFrameNum() == 100) {
renderGif();
}
}
Folded like the top of a cardbaord box