Created
July 16, 2014 14:57
-
-
Save dropmeaword/545a7354b388c6b680be to your computer and use it in GitHub Desktop.
OF aplication to play three videos in a star shaped arrangement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ofApp.h" | |
//-------------------------------------------------------------- | |
void ofApp::setup(){ | |
ofBackground(255,255,255); | |
ofSetVerticalSync(true); | |
frameByframe = false; | |
ofLogLevel(OF_LOG_VERBOSE); | |
// Uncomment this to show movies with alpha channels | |
// finger1.setPixelFormat(OF_PIXELS_RGBA); | |
bCenter = true; | |
finger1.loadMovie("movies/fingers.mov"); | |
finger1.play(); | |
finger1.setLoopState(OF_LOOP_NORMAL); | |
finger2.loadMovie("movies/fingers.mov"); | |
finger2.play(); | |
finger2.setLoopState(OF_LOOP_NORMAL); | |
finger3.loadMovie("movies/fingers.mov"); | |
finger3.play(); | |
finger3.setLoopState(OF_LOOP_NORMAL); | |
} | |
//-------------------------------------------------------------- | |
void ofApp::update(){ | |
finger1.update(); | |
finger2.update(); | |
finger3.update(); | |
} | |
//-------------------------------------------------------------- | |
void ofApp::draw(){ | |
ofSetHexColor(0xFFFFFF); | |
// distribute the video players in a circle | |
float r = ofGetViewportHeight() - (finger1.height*2); | |
//ofLogNotice() << "radius = " << r << endl; | |
float angle = 2 * PI / 3; | |
float yp = ofGetHeight()/2; | |
float xp = ofGetWidth()/2; | |
if(bCenter) { | |
ofSetRectMode(OF_RECTMODE_CENTER); | |
} else { | |
ofSetRectMode(OF_RECTMODE_CORNER); | |
} | |
float theta = angle; | |
float rot = PI/2; | |
ofPushMatrix(); | |
ofTranslate(xp, yp, 0); | |
//ofRotate(ofGetFrameNum() * 0.1, 0, 0, 1);//rotate from centre | |
ofPushMatrix(); | |
ofTranslate(r*cos(theta), r*sin(theta), 0); | |
ofRotate(ofRadToDeg(rot), 0, 0, 1); | |
finger1.draw(0, 0); | |
ofPopMatrix(); | |
theta += angle; | |
rot += angle; | |
ofPushMatrix(); | |
ofTranslate(r*cos(theta), r*sin(theta), 0); | |
ofRotate(ofRadToDeg(rot), 0, 0, 1); | |
finger2.draw(0, 0); | |
ofPopMatrix(); | |
theta += angle; | |
rot += angle; | |
ofPushMatrix(); | |
ofTranslate(r*cos(theta), r*sin(theta), 0); | |
ofRotate(ofRadToDeg(rot), 0, 0, 1); | |
finger3.draw(0, 0); | |
ofPopMatrix(); | |
ofPopMatrix(); | |
/* | |
ofSetHexColor(0x000000); | |
unsigned char * pixels = finger1.getPixels(); | |
int nChannels = finger1.getPixelsRef().getNumChannels(); | |
// let's move through the "RGB(A)" char array | |
// using the red pixel to control the size of a circle. | |
for (int i = 4; i < 320; i+=8){ | |
for (int j = 4; j < 240; j+=8){ | |
unsigned char r = pixels[(j * 320 + i)*nChannels]; | |
float val = 1 - ((float)r / 255.0f); | |
ofCircle(400 + i,20+j,10*val); | |
} | |
} | |
ofSetHexColor(0x000000); | |
ofDrawBitmapString("press f to change",20,320); | |
if(frameByframe) ofSetHexColor(0xCCCCCC); | |
ofDrawBitmapString("mouse speed position",20,340); | |
if(!frameByframe) ofSetHexColor(0xCCCCCC); else ofSetHexColor(0x000000); | |
ofDrawBitmapString("keys <- -> frame by frame " ,190,340); | |
ofSetHexColor(0x000000); | |
ofDrawBitmapString("frame: " + ofToString(finger1.getCurrentFrame()) + "/"+ofToString(finger1.getTotalNumFrames()),20,380); | |
ofDrawBitmapString("duration: " + ofToString(finger1.getPosition()*finger1.getDuration(),2) + "/"+ofToString(finger1.getDuration(),2),20,400); | |
ofDrawBitmapString("speed: " + ofToString(finger1.getSpeed(),2),20,420); | |
if(finger1.getIsMovieDone()){ | |
ofSetHexColor(0xFF0000); | |
ofDrawBitmapString("end of movie",20,440); | |
} | |
*/ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::keyPressed (int key){ | |
switch(key){ | |
case 'f': | |
frameByframe=!frameByframe; | |
finger1.setPaused(frameByframe); | |
break; | |
case 'c': | |
bCenter = !bCenter; | |
break; | |
case OF_KEY_LEFT: | |
finger1.previousFrame(); | |
break; | |
case OF_KEY_RIGHT: | |
finger1.nextFrame(); | |
break; | |
case '0': | |
finger1.firstFrame(); | |
break; | |
} | |
} | |
//-------------------------------------------------------------- | |
void ofApp::keyReleased(int key){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseMoved(int x, int y ){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseDragged(int x, int y, int button){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mousePressed(int x, int y, int button){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseReleased(int x, int y, int button){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::windowResized(int w, int h){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::gotMessage(ofMessage msg){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::dragEvent(ofDragInfo dragInfo){ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment