Beispiel #1
0
//--------------------------------------------------------------
void Mission1::update()
{
    if(start) {
        p.y -= 30;
    }
    
    // each 1 second
	if (ofGetElapsedTimeMillis() - getSharedData().lastUpdate > 1000)
	{
		getSharedData().counter++;
		getSharedData().lastUpdate = ofGetElapsedTimeMillis();
        
        // 時間がたったら次へ
        //if (getSharedData().counter > 21) {
        if (getSharedData().counter > 10) {
            sendSerial(0);    // 0の信号を送る
            
            // initialize
            x = 0;
            xx = 0;
            p.set(ofGetWidth()/2-90, 1920);

            changeState("Mission2");
        }
	}
    
}
void Scene5::stateEnter(){
    getSharedData().vidGrabber.setDeviceID(0);
	getSharedData().vidGrabber.setDesiredFrameRate(60);
	getSharedData().vidGrabber.initGrabber(camWidth,camHeight);
    
    ofResetElapsedTimeCounter();
}
Beispiel #3
0
void Mission1::draw()
{
    ofSetColor(255);
    img.resize(ofGetWidth(), ofGetHeight());
    img.draw(0, 0);

    // set a timer
    if (ofGetElapsedTimeMillis() - getSharedData().lastUpdate > 1000){
        getSharedData().counter++;
        getSharedData().lastUpdate = ofGetElapsedTimeMillis();
        if (getSharedData().counter > 2) {
            timePast = true;
        }
    }
    
    if(timePast){
        ofEnableAlphaBlending();
        flight.draw(p.x, p.y);
        ofDisableAlphaBlending();
        
        ofSetColor(255, 102, 102);
        if(p.y < -2000){
            timePast = false;
            changeState("Mission2");
        } else if(p.y > 0){
            ofTriangle(p.x+47, p.y+90, 0, ofGetHeight(), ofGetWidth(), ofGetHeight());
        }else{
            x+=5;
            ofTriangle(p.x+47, p.y+90, -x, ofGetHeight(), ofGetWidth()+x, ofGetHeight());
        }
    }

}
//--------------------------------------------------------------
void ArsUITitleState::stateEnter()
{
    cout << "incoming port: " << getSharedData().incomingPort << endl;
    ofxOscMessage msg;
    msg.setAddress("/gianteyes/hello");
    msg.addIntArg(getSharedData().incomingPort);
    getSharedData().oscSenderToServer.sendMessage(msg);
}
Beispiel #5
0
void Start::update()
{
	if (ofGetElapsedTimeMillis() - getSharedData().lastUpdate > 1000)
	{
		//getSharedData().counter--;
		getSharedData().lastUpdate = ofGetElapsedTimeMillis();
	}
}
Beispiel #6
0
void MoveTile::keyPressed(int key){
    if (key == OF_KEY_UP) {
        getSharedData().tileDiv++;
    }
    if (key == OF_KEY_DOWN) {
        if (getSharedData().tileDiv > 1) {
            getSharedData().tileDiv--;
        }
    }
}
Beispiel #7
0
void MoveTile::update(){
    
    width = SCREEN_WIDTH / float(getSharedData().tileDiv) / 3.0;
    height = SCREEN_HEIGHT / float(getSharedData().tileDiv);
    
    tilePos--;
    if (tilePos < -height) {
        tilePos += height;
    }
}
Beispiel #8
0
void Measure1::update()
{
	if (ofGetElapsedTimeMillis() - getSharedData().lastUpdate > 1000)
	{
		getSharedData().counter--;
		getSharedData().lastUpdate = ofGetElapsedTimeMillis();
	}
    
    float dt = 1.0f / ofGetFrameRate();
    pos.update( dt );
    
}
Beispiel #9
0
void Scene2::stateEnter(){
    if (getSharedData().vidGrabber.listDevices().size() > 1) {
        
        getSharedData().vidGrabber.setDeviceID(1);
        getSharedData().vidGrabber.initGrabber(getSharedData().camWidth, getSharedData().camHeight);
        
        
    } else {
        getSharedData().vidGrabber.setDeviceID(0);
        getSharedData().vidGrabber.initGrabber(getSharedData().camWidth, getSharedData().camHeight);
    }
    ofResetElapsedTimeCounter();
    kosuri = getSharedData().kosuri;
}
void AnimateAutomatonState::draw() {
    ofBackground(0,0,0,255);
    
	ofSetColor(255,255,255);
    calculateBitmap();
    
    // copies pixel into output image
    output.setFromPixels( getSharedData().pixels, getSharedData().screenWidthPixels, getSharedData().screenHeightPixels, OF_IMAGE_COLOR );
    // draw output image to screen
    output.draw(0,0);
    
    glFlush();

}
Beispiel #11
0
void End::update()
{
    // timer for each 1 second
	if (ofGetElapsedTimeMillis() - getSharedData().lastUpdate > 1000)
	{
		getSharedData().counter++;
		getSharedData().lastUpdate = ofGetElapsedTimeMillis();
        
        if (getSharedData().counter > 5) {
            init();
            changeCamera(getSharedData().qrcodeCamId);
            changeState("Start");
        }
    }
}
Beispiel #12
0
void Measure2::draw()
{
    int weight = 27;
    int maxWeight = 32;
    
    ofSetColor(255);
    longImg.draw(0, -1990+17*pos.val());
    //longImg.draw(0, -2200+25*pos.val());
    
    ofRect(116, 764, 365, -450);
    ofSetColor(0.0, 0.0, 200);
    ofRect(116, 764, 365, - pos.val()* 4.5 * weight/maxWeight); //

    
    // 画像を描画
    ofEnableAlphaBlending();
    ofSetColor(255);
    img.resize(ofGetWidth(), ofGetHeight());
    img.draw(0, 0);
    ofDisableAlphaBlending();
    
    // number
    if(pos.hasFinishedAnimating() == true)
    {
        ofSetColor(255,75,145);
    }else{
        ofSetColor(190);
    }
    font.drawString(ofToString((int)((pos.val())*weight/100)), 190, 530);
    
    // 残りの重さ
    int num = maxWeight - pos.val()*weight/100;
    font2.drawString(ofToString(num), 220, 930);


    if(num == maxWeight-weight){
        // set a timer
        if (ofGetElapsedTimeMillis() - getSharedData().lastUpdate > 1000){
            getSharedData().counter++;
            getSharedData().lastUpdate = ofGetElapsedTimeMillis();
            if (getSharedData().counter > 2) {
                getSharedData().counter = 0;
                changeState("Mission1");
            }
        }
    }
    
}
Beispiel #13
0
void StFftRibbon::draw(){
    app->drawFbo->fbo.begin();
    ofDisableAlphaBlending();
    ofClear(0,0,0);
    cam.begin();
    glEnable(GL_DEPTH_TEST);
    //ofEnableBlendMode(OF_BLENDMODE_ADD);
    ofEnableBlendMode(OF_BLENDMODE_ALPHA);
    ofPushMatrix();
    ofScale(1.0, 1.0, 1.0);
    ofRotateX(ofGetElapsedTimef() * 1.1);
    ofRotateY(ofGetElapsedTimef() * 1.3);
    ofRotateZ(ofGetElapsedTimef() * 1.2);
    //ofNoFill();
    for (int i=0; i  < fft_size-2; i+=2) {
        ribbons[i]->draw();
    }
    //ofFill();
    ofPopMatrix();
    glDisable(GL_DEPTH_TEST);
    //ofEnableBlendMode(OF_BLENDMODE_ADD);
    ofDisableAlphaBlending();
    cam.end();
    app->drawFbo->fbo.end();
    
    gui->setVisible(getSharedData().guiVisible);
}
Beispiel #14
0
void StFftSphereRibbon::update(){
    ofxUISlider *gnoisescale = (ofxUISlider *)gui->getWidget("NOISE SCALE"); float noisescale = gnoisescale->getValue();
    ofxUISlider *gshiftspeed = (ofxUISlider *)gui->getWidget("SHIFT SPEED"); float shiftspeed = gshiftspeed->getValue();
    ofxUISlider *ginterp = (ofxUISlider *)gui->getWidget("INTERPORATION"); float interp = ginterp->getValue();
    ofxUISlider *gthickness = (ofxUISlider *)gui->getWidget("RIBBON WIDTH"); float thickness = gthickness->getValue();
    
    float distortionStrength = ofMap(app->oscControl->controlVal[4], 0, 127, 2, 10);
    
    float fftSum = 0;
    for (int i = 0; i < app->fft->drawBins.size(); i++) {
        fftSum += app->fft->drawBins[i];
    }
    for (int i = 0; i < mesh.getVertices().size(); i++) {
        float noiseX = ofMap(currentVertex[i].x, 0, ofGetWidth(), 0, noisescale);
        float noiseY = ofMap(currentVertex[i].y, 0, ofGetWidth(), 0, noisescale);
        float noiseZ = ofMap(currentVertex[i].y, 0, ofGetWidth(), 0, noisescale);
        float offset = ofNoise(noiseX + ofGetElapsedTimef() * shiftspeed, noiseY + ofGetElapsedTimef() * shiftspeed);
        currentVertex[i] = currentVertex[i].normalize() * (offset * fftSum * distortionStrength);
        float randStrength = distortionStrength * 5.0;
        currentVertex[i] +=  ofVec3f(ofRandom(-randStrength, randStrength), ofRandom(-randStrength, randStrength), ofRandom(-randStrength, randStrength));
        mesh.setVertex(i, currentVertex[i]);
        interplateVertex[i] += (currentVertex[i] - interplateVertex[i]) * interp;
        ribbons[i]->thickness = thickness;
        ribbons[i]->update(interplateVertex[i]);
    }
    
    gui->setVisible(getSharedData().guiVisible);
}
Beispiel #15
0
void StFftDistortNotex::update(){
    ofxUISlider *gnoisescale = (ofxUISlider *)gui->getWidget("NOISE SCALE"); float noisescale = gnoisescale->getValue();
    ofxUISlider *gshiftspeed = (ofxUISlider *)gui->getWidget("SHIFT SPEED"); float shiftspeed = gshiftspeed->getValue();
    
    float distortionStrength = ofMap(app->oscControl->controlVal[4], 0, 127, 1, 8);
    
    float fftSum = 0;
    for (int i = 0; i < app->fft->drawBins.size(); i++) {
        fftSum += app->fft->drawBins[i];
    }
    
    int i = 0;
    for(int y = 1; y + 1 < ySteps; y++) {
        for(int x = 1; x + 1 < xSteps; x++) {
            int i = y * xSteps + x;
            float noiseX = ofMap(currentVertex[i].x, 0, ofGetWidth(), 0, noisescale);
            float noiseY = ofMap(currentVertex[i].y, 0, ofGetWidth(), 0, noisescale);
            float offset = ofNoise(noiseX + ofGetElapsedTimef() * shiftspeed, noiseY + ofGetElapsedTimef() * shiftspeed);
            currentVertex[i].z = offset * distortionStrength * fftSum;
            mesh.setVertex(i, currentVertex[i]);
            i++;
        }
    }
    
    gui->setVisible(getSharedData().guiVisible);
}
Beispiel #16
0
void StCvOpMesh::draw() {
    ofxUIIntSlider *gmax = (ofxUIIntSlider *)gui->getWidget("MAX");
    int max = gmax->getValue();
    ofxUISlider *gradius = (ofxUISlider *)gui->getWidget("RADIUS");
    float radius = gradius->getValue();
    ofxUIIntSlider *gfade = (ofxUIIntSlider *)gui->getWidget("FADE");
    int fade = gfade->getValue();
    ofxUIToggle *gclear = (ofxUIToggle *)gui->getWidget("CLEAR BACKGROUND");
    bool clear = gclear->getValue();
    ofPixelsRef pix = ((ofApp*)ofGetAppPtr())->blackmagic->colorPixels;

    app->drawFbo->fbo.begin();
    app->drawFbo->blendMode = 0;
    ofTranslate(0, -app->drawFbo->top);
    ofEnableBlendMode(OF_BLENDMODE_ALPHA);
    ofSetColor(0, 0, 0, fade);
    ofRect(0, 0, ofGetWidth(), ofGetHeight());

    mesh.clear();
    for (int i = 0; i < particles.size(); i++) {
        mesh.addVertex(ofVec3f(particles[i]->position.x,
                               particles[i]->position.y, 0));
        mesh.addColor(ofFloatColor(particles[i]->col.r/255.0, particles[i]->col.g/255.0, particles[i]->col.b/255.0));
    }

    ofEnableBlendMode(OF_BLENDMODE_ADD);
    ofSetColor(255);
    glPointSize(radius);
    mesh.draw();

    ofDisableBlendMode();
    app->drawFbo->fbo.end();

    gui->setVisible(getSharedData().guiVisible);
}
Beispiel #17
0
void StKaleidoscopeGJ::draw(){
    ofxUISlider *gsat = (ofxUISlider *)gui->getWidget("SAT"); float sat = gsat->getValue();
    ofxUISlider *gbr = (ofxUISlider *)gui->getWidget("BR"); float br = gbr->getValue();
    ofxUISlider *gzoom = (ofxUISlider *)gui->getWidget("ZOOM"); float zoom = gzoom->getValue();
    
    float hue =ofMap(app->oscControl->controlVal[5], 0, 127, 0.0, 1.0);
    app->drawFbo->fbo.begin();
    app->drawFbo->blendMode = 0;
    ofEnableBlendMode(OF_BLENDMODE_ALPHA);
    ofSetColor(0, 0, 0, 20);
    ofRect(0, 0, ofGetWidth(), ofGetHeight());
    ofTranslate(0, -app->drawFbo->top);
    //ofEnableBlendMode(OF_BLENDMODE_ADD);
    ofTranslate(0, -app->drawFbo->top);

    ofScale(1.0 / fxRatio, 1.0 / fxRatio);
    post->begin(cam);
    ofPushMatrix();
    ofScale(zoom, zoom);
    ofColor col; col.setHsb(hue * 255, sat * 255, br * 255);
    ofSetColor(col);
    ofRotateZ(ofGetElapsedTimef() * 40.0);
    app->blackmagic->colorTexture.draw(-app->blackmagic->width/2, -app->blackmagic->height/2, app->blackmagic->width, app->blackmagic->height);
    ofPopMatrix();
    post->end();
    app->drawFbo->fbo.end();
    ofDisableBlendMode();
    
    gui->setVisible(getSharedData().guiVisible);
}
Beispiel #18
0
void StCvOpSparkle::update(){
    //CV params
    ofxUISlider *p = (ofxUISlider *)gui->getWidget("PYR SCALE"); pyrScale = p->getValue();
    ofxUIIntSlider *l = (ofxUIIntSlider *)gui->getWidget("LEVELS"); levels = l->getValue();
    ofxUIIntSlider *w = (ofxUIIntSlider *)gui->getWidget("WIN SIZE"); winsize = w->getValue();
    ofxUIIntSlider *it = (ofxUIIntSlider *)gui->getWidget("ITERATION"); iterations = it->getValue();
    ofxUIToggle *gs = (ofxUIToggle *)gui->getWidget("GAUSS"); OPTFLOW_FARNEBACK_GAUSSIAN = gs->getValue();
    polyN = 7;
    polySigma = 1.5;
    
    ofPixelsRef pix = ((ofApp*)ofGetAppPtr())->blackmagic->colorPixels;
    pix.resize(160, 90);
    //pix.resize(40, 22);
    flow.setPyramidScale(pyrScale);
    flow.setNumLevels(levels);
    flow.setWindowSize(winsize);
    flow.setNumIterations(iterations);
    flow.setPolyN(polyN);
    flow.setPolySigma(polySigma);
    flow.setUseGaussian(OPTFLOW_FARNEBACK_GAUSSIAN);
    if (pix.size() > 0) {
        flow.calcOpticalFlow(pix);
    }
    
    for (int i = 0; i < particles.size(); i++) {
        particles[i]->update();
    }
    
    gui->setVisible(getSharedData().guiVisible);
}
void Scene5::draw(){
    getSharedData().vidGrabber.draw(camWidth, 0, -camWidth, camHeight);
    
        clearWord.drawString("OK!", i1X, i1Y-300);
        clearWord.drawString("きれいになったね!", i2X, i2Y-250);
        clearWord.drawString("正しいてあらいを", i3X, i3Y+50);
        clearWord.drawString("みんなにおしえてあげよう!", i4X, i3Y+100);
}
void flowState::update() {
    getSharedData().updateCamera(dimFac);
    farneback.calcOpticalFlow(getSharedData().smallFrame);
    if(farneback.getFlow().rows > 1 && locs.size() == 0) {
        Mat flow = farneback.getFlow();
        for(int x=0; x < flow.cols; x++) {
            for(int y=0; y < flow.rows; y++) {
                Integrator<ofVec2f> *newInt = new Integrator<ofVec2f>();
                newInt->attraction = 0.3;
                newInt->damping = 0.5;
                locs.push_back(newInt);
                mesh.addVertex(ofVec2f(x, y));
                mesh.addVertex(ofVec2f(x, y));
            }
        }
    }
    updateLocs();
}
Beispiel #21
0
void Print::update()
{
    float dt = 1.0f / ofGetFrameRate();
    pos.update( dt );


    // timer
	if (ofGetElapsedTimeMillis() - getSharedData().lastUpdate > 1000)
	{
		getSharedData().counter++;
		getSharedData().lastUpdate = ofGetElapsedTimeMillis();
        
        if (getSharedData().counter > 5) {
            init();
            changeState("End");
        }
    }
}
Beispiel #22
0
void Tile::draw(){
    ((ofApp*)ofGetAppPtr())->syphonIO.fbo.begin();
    ofBackground(0);
    for (int i = 0; i < 3; i++) {
        for (int y = 0; y < getSharedData().tileDiv; y++) {
            for (int x = 0; x < getSharedData().tileDiv; x++) {
                float width = SCREEN_WIDTH / float(getSharedData().tileDiv) / 3.0;
                float height = SCREEN_HEIGHT / float(getSharedData().tileDiv);
                ((ofApp*)ofGetAppPtr())->syphonIO.texture.draw(x * width + i * SCREEN_WIDTH / 3.0, y * height, width, height);
            }
        }
    }
    ((ofApp*)ofGetAppPtr())->syphonIO.fbo.end();
    ofSetColor(255);
    ((ofApp*)ofGetAppPtr())->syphonIO.fbo.draw(0, 0);
    ((ofApp*)ofGetAppPtr())->syphonIO.server.publishTexture(&((ofApp*)ofGetAppPtr())->syphonIO.fbo.getTextureReference());
    //((ofApp*)ofGetAppPtr())->syphonIO.server.publishScreen();
}
Beispiel #23
0
//--------------------------------------------------------------
void Print::init()
{
    vel = 20;
    _count = 2;
    p.set(250, 900);
    pp.set(ofGetWidth()/2,-100);
    width_x = 0;
    xx = 0;
    getSharedData().counter = 0;
}
Beispiel #24
0
/**
 * Gets a default compute projection. Default compute projection will include all nodes
 * in remote grid. Selection of node that will be connected to perform operations will be
 * done according to {@link GridClientLoadBalancer} provided in client configuration or
 * according to affinity if projection call involves affinity key.
 * <p>
 * More restricted projection configurations may be created with {@link GridClientCompute} methods.
 *
 * @return Default compute projection.
 *
 * @see GridClientCompute
 */
TGridClientComputePtr GridClientImpl::compute() {
    if (mainComputePrj.get() == NULL) {
        TGridClientSharedDataPtr sd = getSharedData();

        GridClientComputeProjectionImpl* p = new GridClientComputeProjectionImpl(sd, *this, TGridClientNodePredicatePtr(),
                TGridClientLoadBalancerPtr(), threadPool);

        mainComputePrj.reset(p);
    }

    return mainComputePrj;
}
void Scene5::update(){
    getSharedData().vidGrabber.update();

    if(ofGetElapsedTimef() > 8.0f){
        //5秒ほど表示したら元に戻る
        //しばらく人が来ても受け付けない処理とかも必要かも
        ofxOscMessage sendReset;
        sendReset.setAddress("/leap/sendReset");
        sendReset.addIntArg(0);
        sender.sendMessage(sendReset);
    }
}
Beispiel #26
0
void Scene2::update(){
    //人がいなくなったら、0に戻る処理も必要
    if(ofGetElapsedTimef() < 1.5f){
        kosuri = getSharedData().kosuri;
//        printf("kosuri:%d\n",kosuri);
    }
////    printf("SharedData x0:%d, y0:%d, scene:%d\n", getSharedData().palmPosX[0], getSharedData().palmPosY[0],getSharedData().scene);
//    palmPosX[0] = getSharedData().palmPosX[0];
//    palmPosY[0] = getSharedData().palmPosY[0];
//
//    // Adding temporal Force
//    ofPoint m = ofPoint(palmPosX[0], palmPosY[0]);
////    ofPoint m = ofPoint(mouseX, mouseY);
//    ofPoint d = (m - oldM)*10.0;
//    oldM = m;
//    ofPoint c = ofPoint(ofGetWidth()/2, ofGetHeight()/2) - m;
//    c.normalize();
//    //紫
//    //    fluid.addTemporalForce(m, d, ofFloatColor(100,70,255), fogDensity);
//    //青
//    fluid.addTemporalForce(m, d, ofFloatColor(10,70,255), fogDensity);
//    
//    //  Update
//    getSharedData().vidGrabber.update();
//    fluid.update();
//    printf("kosuri_leap:%d\n", getSharedData().kosuri);
    
    if(getSharedData().kosuri > kosuri + 200){
        ofxOscMessage sendReset;
        sendReset.setAddress("/leap/sendReset");
        sendReset.addIntArg(ofRandom(3,4));
        sender.sendMessage(sendReset);
        printf("sendReset\n");
    }
    
    //バクテリアupdate
    bacteria[0].update(true);
    bacteria[1].update(true);
}
void Scene4::update(){
    
    printf("SharedData x0:%d, y0:%d, scene:%d\n", getSharedData().fingerPosX[0], getSharedData().fingerPosY[0],getSharedData().scene);
    fingerPosX[0] = getSharedData().fingerPosX[0];
    fingerPosY[0] = getSharedData().fingerPosY[0];
    
    // Adding temporal Force
    ofPoint m = ofPoint(fingerPosX[0], fingerPosY[0]);
    //    ofPoint m = ofPoint(mouseX, mouseY);
    ofPoint d = (m - oldM)*10.0;
    oldM = m;
    ofPoint c = ofPoint(ofGetWidth()/2, ofGetHeight()/2) - m;
    c.normalize();
    //紫
    //    fluid.addTemporalForce(m, d, ofFloatColor(100,70,255), fogDensity);
    //青
    fluid.addTemporalForce(m, d, ofFloatColor(10,70,255), fogDensity);
    
    //  Update
    //
    getSharedData().vidGrabber.update();
    fluid.update();
}
Beispiel #28
0
void GreenState::draw()
{
    float time = ofGetElapsedTimef();
    
    // Clear with alpha, so we can capture via syphon and composite elsewhere should we want.
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    // Syphon Stuff
    getSharedData().mClient.draw(50, 50);
    
    ofEnableDepthTest();
    
    shader.begin();
        shader.setUniform1f("time", time);
        shader.setUniform1f("number", number);
        shader.setUniform1f("len", len);
        shader.setUniform1f("speed", speed);
        shader.setUniform2fv("resolution", resolution);
        
        //my_vbo.draw(GL_LINES, 0, n_vert);
        
        glBegin(GL_QUADS);
        glVertex2f(0, 0);
        glVertex2f(ofGetWidth(), 0);
        glVertex2f(ofGetWidth(), ofGetHeight());
        glVertex2f(0, ofGetHeight());
        glEnd();
        
        getSharedData().mainOutputSyphonServer.publishScreen();
    shader.end();
    
    // GUI
    ofDisableDepthTest();
    gui.draw();
}
Beispiel #29
0
void StCvOpDistort::update(){
    //CV params
    ofxUISlider *p = (ofxUISlider *)gui->getWidget("PYR SCALE"); pyrScale = p->getValue();
    ofxUIIntSlider *l = (ofxUIIntSlider *)gui->getWidget("LEVELS"); levels = l->getValue();
    ofxUIIntSlider *w = (ofxUIIntSlider *)gui->getWidget("WIN SIZE"); winsize = w->getValue();
    ofxUIIntSlider *it = (ofxUIIntSlider *)gui->getWidget("ITERATION"); iterations = it->getValue();
    ofxUIToggle *gs = (ofxUIToggle *)gui->getWidget("GAUSS"); OPTFLOW_FARNEBACK_GAUSSIAN = gs->getValue();
    ofxUISlider *gthresh = (ofxUISlider *)gui->getWidget("THRESH"); float thresh = gthresh->getValue();
    ofxUIIntSlider *gskip = (ofxUIIntSlider *)gui->getWidget("SKIP"); int skip = gskip->getValue();
    
    polyN = 7;
    polySigma = 1.5;
    
    ofPixelsRef pix = ((ofApp*)ofGetAppPtr())->blackmagic->colorPixels;
    pix.resize(160, 90);
    flow.setPyramidScale(pyrScale);
    flow.setNumLevels(levels);
    flow.setWindowSize(winsize);
    flow.setNumIterations(iterations);
    flow.setPolyN(polyN);
    flow.setPolySigma(polySigma);
    flow.setUseGaussian(OPTFLOW_FARNEBACK_GAUSSIAN);
    
    
    flow.calcOpticalFlow(pix);
    
    int i = 0;
    
    float distortionStrength = ofMap(app->oscControl->controlVal[2], 0, 127, 0, 300);
    
    ofVec2f scale = ofVec2f(flow.getWidth() / float(ofGetWidth()), flow.getHeight() / float(ofGetHeight()));
    for(int y = 1; y + 1 < ySteps; y++) {
        for(int x = 1; x + 1 < xSteps; x++) {
            int i = y * xSteps + x;
            ofVec2f position(x * stepSize * scale.x, y * stepSize * scale.y);
            ofRectangle area(position - ofVec2f(stepSize * scale.x, stepSize * scale.y) / 2.0, stepSize * scale.x, stepSize * scale.y);
            ofVec2f offset;
            offset = flow.getAverageFlowInRegion(area);
            if (offset.length() < thresh && ofGetFrameNum() % skip == 0) {
                currentVertex[i] += ((position + distortionStrength * offset) / scale - currentVertex[i]) * 0.3;
            }
            mesh.setVertex(i, currentVertex[i]);
            i++;
        }
    }
    
    gui->setVisible(getSharedData().guiVisible);
}
Beispiel #30
0
void Scene3::stateExit(){
    getSharedData().vidGrabber.close();
    
    for(int i=0;i<4;i++){
        getSharedData().tearai[i].setVolume(0.0);
    }
    kosuri_internal = 0;
    getSharedData().frameCount = 0;
    getSharedData().BGMSound.setVolume(0.0);
    getSharedData().BGMSound2.setVolume(0.0);
    for(int i=0;i<4;i++){
        getSharedData().tearai[i].setVolume(0.0);
    }
}