Beispiel #1
0
//--------------------------------------------------------------
void testApp::setup(){
	ofSetCircleResolution(50);
	ofSetFrameRate(60);
	ofSetWindowShape(1024, 768);
	ofBackground(255, 255, 255);
	ofSetVerticalSync(true);
	ofEnableSmoothing();
	ofSetFullscreen(false);
	
	counter = 0;
	int bufferSize		= 512;
	sampleRate 			= 44100;
	phase 				= 0;
	phaseAdder 			= 0.0f;
	phaseAdderTarget 	= 0.0f;
	volume				= 0.1f;
	bNoise 				= false;
	targetFrequency = 587.33;
	phaseAdderTarget = (targetFrequency / (float) sampleRate) * TWO_PI;
	
	lAudio.assign(bufferSize, 0.0);
	rAudio.assign(bufferSize, 0.0);
	
	//soundStream.listDevices();
	
	//if you want to set the device id to be different than the default
	//soundStream.setDeviceID(1); 	//note some devices are input only and some are output only 
	
	soundStream.setup(this, 2, 0, sampleRate, bufferSize, 4);
	
	w = 0;
	h = 0;	// set in update()
	
	// listen on the given port
	cout << "listening for osc messages on port " << PORT << "\n";
	receiver.setup( PORT );
}
Beispiel #2
0
//--------------------------------------------------------------
void testApp::keyPressed  (int key)
{
	if (debugOutput) {printf("Pressed key number: %i\n", key);}
	if ( key == ' ' )
	{
		if ( m_run )
		{
			m_run = false;
			ofxOscMessage m;
			m.setAddress("/stop");
			m.addIntArg(0);
			sender.sendMessage ( m );
			setOscDebugMessage(m);
		}
		else
		{
			m_run = true;
			ofxOscMessage m;
			m.setAddress("/start");
			m.addIntArg(1);
			sender.sendMessage ( m );
			setOscDebugMessage(m);
		}
	}
	else if (key == 'r' || key == 'R')
	{
		m_numSamples[m_currentSample] = 0;
		m_sampleVector[m_currentSample].clear();
	}
	else if (key == 'z')
	{
		if (m_numSamples[m_currentSample] > 0)
		{
			--m_numSamples[m_currentSample];
			m_sampleVectorPopped[m_currentSample].push_back(m_sampleVector[m_currentSample].back());
			m_sampleVector[m_currentSample].pop_back();
		}
	}
	else if (key == 'Z')
	{
		if (m_sampleVectorPopped[m_currentSample].size() > 0) {
			m_sampleVector[m_currentSample].push_back(m_sampleVectorPopped[m_currentSample].back());
			m_sampleVectorPopped[m_currentSample].pop_back();
			++m_numSamples[m_currentSample];
		}
	}
	else if ( key == 'c' )
	{
		// clear all samples
		for (int i = 0; i < MAX_SAMPLES; ++i) {
			m_numSamples[i] = 0;
			m_sampleVector[i].clear();
		}
	}
	else if ( key == 'C' )
	{
		clearAll();
	}
	else if ( key == 'F' )
	{
		isFullScreen = !isFullScreen;
		ofSetFullscreen(isFullScreen);
	}
	else if (key >= 48 && key <=57)
	{
		m_currentSample = key - 48;
		if (debugOutput) {printf("set sample: %i\n", m_currentSample);}
	}
	else if (key == 'd')
	{
		if (debugOutput) {printf("debug mode\n");}
		debugMode = !debugMode;
	}
	else if (key == 'f')
	{
		showColors = !showColors;
	}
	else if (key == 'g')
	{
		for (int i = 0; i < MAX_SAMPLES; ++i) {
			m_sampleColors[i].r = ofRandom(0, 255);
			m_sampleColors[i].g = ofRandom(0, 255);
			m_sampleColors[i].b = ofRandom(0, 255);
			m_sampleColors[i].a = 127;
		}
	}
	else if (key == 'h')
	{
		if (debugOutput) {printf("help mode\n");}
		helpMode = !helpMode;
		usageMode = false;
	}
	else if (key == 'm')
	{
		showOscDebugPosition = !showOscDebugPosition;
	}
	else if (key == OF_KEY_UP)
	{
		if (m_currentState == 0) {
			nPtsBackup = nPts;
			for (int i = 0; i < MAX_N_PTS; ++i) {
				ptsBackup[i] = 0;
			}

			for (int i = 0; i < nPts; ++i) {
				ptsBackup[i] = pts[i];
			}
			for (int i = 0; i < MAX_SAMPLES; ++i) {
				m_sampleVectorBackup[i] = m_sampleVector[i];
				m_numSamplesBackup[i] = m_numSamples[i];
				m_playStatusesBackup[i] = m_playStatuses[i];
			}
		}
		++m_currentState;

		if (m_currentState > XMLstates.getNumTags("STATE"))
		{
			m_currentState = 0;
		}
		loadState(m_currentState);
		if (debugOutput) {printf("current state : %i\n", m_currentState);}

	}
	else if (key == OF_KEY_DOWN)
	{
		if (m_currentState == 0) {
			nPtsBackup = nPts;
			for (int i = 0; i < MAX_N_PTS; ++i) {
				ptsBackup[i] = 0;
			}

			for (int i = 0; i < nPts; ++i) {
				ptsBackup[i] = pts[i];
			}
			for (int i = 0; i < MAX_SAMPLES; ++i) {
				m_sampleVectorBackup[i] = m_sampleVector[i];
				m_numSamplesBackup[i] = m_numSamples[i];
				m_playStatusesBackup[i] = m_playStatuses[i];
			}
		}
		--m_currentState;
		if (m_currentState < 0)
		{
			m_currentState =  XMLstates.getNumTags("STATE");
		}
		loadState(m_currentState);
		if (debugOutput) {printf("current state : %i\n", m_currentState);}
	}
	else if (key == OF_KEY_RETURN)
	{
		usageMode = !usageMode;
	}
	else if (key == 'w')
	{
		if (debugMode) {
			saveCurrentState();
			if (debugOutput) {printf("saved current state!\n");}
			buttonPushed = true;
		}
	}
	else if (key == 'e')
	{
		if (debugMode)
		{
			readStates();
		}
	}
	else if (key >= 257 && key <= 266)
	{
		if (m_currentState == 0) {
			nPtsBackup = nPts;
			for (int i = 0; i < MAX_N_PTS; ++i) {
				ptsBackup[i] = 0;
			}
			
			for (int i = 0; i < nPts; ++i) {
				ptsBackup[i] = pts[i];
			}
			for (int i = 0; i < MAX_SAMPLES; ++i) {
				m_sampleVectorBackup[i] = m_sampleVector[i];
				m_numSamplesBackup[i] = m_numSamples[i];
				m_playStatusesBackup[i] = m_playStatuses[i];
			}
		}
		
		m_currentState = (key - 256) + stateTen;
		printf("current state %i\n", m_currentState);
		printf("lastTagNumber: %i\n", lastTagNumber);
		if (m_currentState > XMLstates.getNumTags("STATE")) 
		{
			m_currentState = lastTagNumber;
		}
		loadState(m_currentState);
		stateTenMsg = "";
		if (debugOutput) {printf("current state : %i\n", m_currentState);}
	}
	else if (key == OF_KEY_F11)
	{
		printf("bla %i",(XMLstates.getNumTags("STATE")));
		if ((XMLstates.getNumTags("STATE") - stateTen) > 10 )
		{
			stateTen += 10;
			std::stringstream str;
			str << ", +";
			str << stateTen;
			str << "...";
			stateTenMsg = str.str();
		}
//		if (stateTen% <= XMLstates.getNumTags("STATE")) {
//			m_currentState += stateTen
//		}
//		m_currentState 
	}
	else if (key == OF_KEY_F12) 
	{
		if (stateTen != 0){
			stateTen -= 10;
			std::stringstream str;
			str << ", -";
			str << stateTen;
			str << "...";			
			stateTenMsg = str.str();
		}
	}
}
Beispiel #3
0
void testApp::guiEvent(ofxUIEventArgs &e){
    
    if(e.widget->getName() == "FADE AMOUNT")
    {
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        fadeAmnt = (int)slider->getScaledValue();
        cout << "changing fade amount: " << fadeAmnt<< endl;
    }
    
    else if(e.widget->getName() == "FULLSCREEN")
    {
        ofxUIToggle *toggle = (ofxUIToggle *) e.widget;
        ofSetFullscreen(toggle->getValue());
    }
    
    else if(e.widget->getName() == "TOGGLE PLAYBACK")
    {
        ofxUIToggle *toggle = (ofxUIToggle *) e.widget;
        if (toggle->getValue() == true){
            mVideoPlayerController.playVideos();
        }
        if (toggle->getValue() == false){
            mVideoPlayerController.pauseVideos();
        }
    }
    else if(e.widget->getName() == "TOGGLE FLATTEN")
    {
        ofxUIToggle *toggle = (ofxUIToggle *) e.widget;
        mFlatten = toggle->getValue();
    }
    
    else if(e.widget->getName() == "HIGH THRESHOLD")
    {
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        mHighThresh = slider->getScaledValue();
    }
    
    else if(e.widget->getName() == "LOW THRESHOLD")
    {
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        mLowThresh = slider->getScaledValue();
    }
    
    else if(e.widget->getName() == "ATTRACT THRESHOLD")
    {
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        mAttractStrength = slider->getScaledValue();
    }
    
    else if(e.widget->getName() == "REPEL THRESHOLD")
    {
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        mRepelStrength = slider->getScaledValue();
    }
    
    else if(e.widget->getName() == "ORIENTATION THRESHOLD")
    {
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        mOrientStrength = slider->getScaledValue();
    }
    
    else if(e.widget->getName() == "VIDEOCUBE DECELERATION")
    {
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        mVideoCubeController.setSpeed(slider->getScaledValue());
    }
    
}
Beispiel #4
0
void DebugUI::update(){
    
    tfield.update("Magic Book \n" + book->getReport() + "\n" + book->whatSituation());
    
    
    if(loadCropBtn){
       cropper->loadFromFile();
        loadCropBtn = false;
    }
    if(saveCropBtn){
        cropper->saveToFile();
        saveCropBtn = false;
    }
    if(bQuadCropperEdit!=bQuadCropperEdit_prev){
        bQuadCropperEdit ? cropper->showDragUI() : cropper->hideDragUI();
        bQuadCropperEdit_prev = bQuadCropperEdit;
    }
    
    if(loadQuadImageBtn){
        quadImage->loadFromFile("settings/pages_mask.xml");
        loadQuadImageBtn = false;
    }
    if(saveQuadImageBtn){
        quadImage->saveToFile("settings/pages_mask.xml");
        saveQuadImageBtn = false;
    }
    if(bQuadImageEdit!=bQuadImageEdit_prev){
        bQuadImageEdit ? quadImage->showDragUI() : quadImage->hideDragUI();
        bQuadImageEdit_prev = bQuadImageEdit;
    }
    if(bLooseDrag != bLooseDrag_prev){
        quadImage->setLooseDrag(bLooseDrag);
        bLooseDrag_prev = bLooseDrag;
    }
    
    
    if(ofGetMousePressed()) pos_ui.update();
    
    if(bDragUIcheckbox!=bDragUIcheckbox_prev){
        bDragUIcheckbox ? bookView->showDragUI() : bookView->hideDragUI();
        bDragUIcheckbox_prev = bDragUIcheckbox;
    }
    
    if(bFullScreencheckbox!=bFullScreencheckbox_prev){
        ofSetFullscreen(bFullScreencheckbox);
        bFullScreencheckbox_prev = bFullScreencheckbox;
    }

    // Load in default XML file
    if(defaultXMLbtn){
        bookView->clearPages();
        vector< vector<MediaModel> > pages = loader->load("settings/book.default", *lang);
        for (int i = 0; i < pages.size(); i++) bookView->addPage(pages.at(i));
    }
    
    if(saveXMLbtn) bookView->savePageLayout();
    
    // Load in custom XML file
    if(loadXMLbtn){
        bookView->clearPages();
        vector< vector<MediaModel> > pages = loader->load("settings/book.xml", *lang);
        for (int i = 0; i < pages.size(); i++) bookView->addPage(pages.at(i));
    }
}
//--------------------------------------------------------------
void testApp::guiEvent(ofxUIEventArgs &e)
{	
	unsigned char Rev;
    float CurrentPosSliderVal;
	
	if(e.widget->getName() == "Carito Position")
    {
        ofxUISlider *slider = (ofxUISlider *) e.widget;    
        //ofBackground(slider->getScaledValue());
		CurrentPosSliderVal = slider->getScaledValue();
		
		if ((unsigned char)CurrentPosSliderVal != (unsigned char)PosPreviousPosSliderVal)
		{  
			if (PosPreviousPosSliderVal > CurrentPosSliderVal)
			{
				Rev = (unsigned char) (PosPreviousPosSliderVal-CurrentPosSliderVal);
				cout << Rev << '\n';
			    cout << (PosPreviousPosSliderVal-CurrentPosSliderVal); 
				//dolly.MoveDollyForward(Rev);
			}
			else if (PosPreviousPosSliderVal < CurrentPosSliderVal)
			{
				Rev = (unsigned char) (CurrentPosSliderVal-PosPreviousPosSliderVal);
				cout <<'-' <<Rev << '\n';			
				
				//dolly.MoveDollyBackward(Rev);

			}
		
			//save the current Slider Position
			PosPreviousPosSliderVal = CurrentPosSliderVal;
		}

    }
    else if(e.widget->getName() == "FULLSCREEN")
    {
        ofxUIToggle *toggle = (ofxUIToggle *) e.widget;
        ofSetFullscreen(toggle->getValue());   
    }
	else if(e.widget->getName() == "Backward")
    {
		dolly.MoveDollyBackward(1);
    }
	else if(e.widget->getName() == "Forward")
    {
		dolly.MoveDollyForward(1);
    }
	else if(e.widget->getName() == "ShiftLeft")
    {
		dolly.ShiftDollyLeft(1);
    }
	else if(e.widget->getName() == "ShiftRight")
    {
		dolly.ShiftDollyRight(1);
    }
	else if(e.widget->getName() == "TiltUp")
    {
		dolly.TiltDollyUp(1);
    }
	else if(e.widget->getName() == "TiltDown")
    {
		dolly.TiltDollyDown(1);
    }
	else if(e.widget->getName() == "Tilt")
    {
        ofxUISlider *slider = (ofxUISlider *) e.widget;    
        //ofBackground(slider->getScaledValue());
		CurrentPosSliderVal = slider->getScaledValue();
		
		if ((unsigned char)CurrentPosSliderVal != (unsigned char)TiltPreviousPosSliderVal)
		{  
			if (TiltPreviousPosSliderVal > CurrentPosSliderVal)
			{   
				Rev = (unsigned char) (TiltPreviousPosSliderVal-CurrentPosSliderVal);
				cout << Rev << '\n';
			    cout << (TiltPreviousPosSliderVal-CurrentPosSliderVal); 
				dolly.TiltDollyDown(Rev);
			}
			else
			{
				Rev = (unsigned char) (CurrentPosSliderVal-TiltPreviousPosSliderVal);
				cout <<'-' <<Rev << '\n';			
				
				dolly.TiltDollyUp(Rev);

			}
		
			//save the current Slider Position
			TiltPreviousPosSliderVal = CurrentPosSliderVal;
		}

    }
	else if(e.widget->getName() == "Shift")
    {
        ofxUISlider *slider = (ofxUISlider *) e.widget;    
        //ofBackground(slider->getScaledValue());
		CurrentPosSliderVal = slider->getScaledValue();
		
		if ((unsigned char)CurrentPosSliderVal != (unsigned char)ShiftPreviousPosSliderVal)
		{  
			if (ShiftPreviousPosSliderVal > CurrentPosSliderVal)
			{   
				Rev = (unsigned char) (ShiftPreviousPosSliderVal-CurrentPosSliderVal);
				cout << Rev << '\n';
			    cout << (ShiftPreviousPosSliderVal-CurrentPosSliderVal); 
				//dolly.ShiftDollyLeft(Rev);
			}
			else
			{
				Rev = (unsigned char) (CurrentPosSliderVal-ShiftPreviousPosSliderVal);
				cout <<'-' <<Rev << '\n';			
				
				//dolly.ShiftDollyRight(Rev);

			}
		
			//save the current Slider Position
			ShiftPreviousPosSliderVal = CurrentPosSliderVal;
		}

    }
	else if(e.widget->getName() == "Calibrate")
	{
		dolly.Calibrate();

	}
	else if(e.widget->getName() == "Speed")
	{
		ofxUINumberDialer *dialer = (ofxUINumberDialer *) e.widget;
		dolly.SetSpeed((unsigned char)dialer->getValue());
	}
}
Beispiel #6
0
void testApp::setFullscreen(bool b){
    ofSetFullscreen(b);
}
Beispiel #7
0
//--------------------------------------------------------------
void ofApp::setup(){
		//画面の基本設定
		ofSetFullscreen(true);
    ofBackground(0, 0, 0);
    ofSetFrameRate(60);
		ofSetCircleResolution(64);
		
		//カメラから映像を取り込んで表示
		useBlackMagic = false;
		ofVec2f imageSize;
		if (useBlackMagic) {
				imageSize.set(1920, 1080);
				blackMagic.setup(imageSize.x, imageSize.y, 59.94);
		}else{
				vidGrabber.setVerbose(true);
				imageSize.set(1920, 1080);
				ofSetLogLevel(OF_LOG_VERBOSE);
				vidGrabber.listDevices();
				// ADJUSTME: カメラを確認して、使いたいカメラのIDを入力すること
				vidGrabber.setDeviceID(0); // logicool 920を挿した時は、 0 - FaceTime HD Camera (Built-in) / 1 - HD Pro Webcam C920
				vidGrabber.initGrabber(imageSize.x,imageSize.y);
				
		}
		
		//使用する画像の領域を確保
		colorImg.allocate(imageSize.x, imageSize.y);
		grayImage.allocate(imageSize.x, imageSize.y);
		grayBg.allocate(imageSize.x, imageSize.y);
		grayDiff.allocate(imageSize.x, imageSize.y);
		grayDiffSmall.allocate(60, 40);
		
		//変数の初期化
    bLearnBakground = true;
    showCvAnalysis = false;
		
		//ベクトル場の初期化
    VF.setupField(60, 40, ofGetWidth(), ofGetHeight());
		
		//GUIの初期設定
    gui.setup();
    gui.config->gridSize.x = 250;
    gui.addContent("grayImage", grayImage);
    gui.addContent("grayDiff", grayDiff);
    gui.addContent("grayDiffSmall", grayDiffSmall);
    gui.addFPSCounter();
    gui.addSlider("threshold", threshold, 0, 400);
    gui.addSlider("gravity", gravity, 0.0, 10.0);
    gui.addSlider("force", force, 0.0, 20.0);
    gui.addSlider("vector threshold", vectorThreshold, 0.0, 2.0);
    gui.addToggle("use live video", liveVideo);
    gui.addToggle("draw video", drawColorImg);
    gui.addToggle("draw vector field", drawVectorFirld);
    gui.addToggle("force inward", bForceInward);
    gui.loadFromXML();
		
		// Box2D初期設定
    box2d.init();
    box2d.setGravity(0, gravity);
		// box2d.createBounds();
		// box2d.createGround();
		float edgeHeight = 0.2;
		ofPolyline polyLineEdge;
		polyLineEdge.addVertex(0, ofGetHeight()*edgeHeight);
		polyLineEdge.addVertex(0, ofGetHeight());
		polyLineEdge.addVertex(ofGetWidth(), ofGetHeight());
		polyLineEdge.addVertex(ofGetWidth(), ofGetHeight()*edgeHeight);
		box2dEdge.addVertexes(polyLineEdge);
		box2dEdge.setPhysics(0.0, 0.5, 0.5);
		box2dEdge.create(box2d.getWorld());
		box2d.setFPS(30);
		box2d.registerGrabbing();
		
		//パーティクル生成
		//    particleNum = 10;
		//    for (int i = 0; i < particleNum; i++) {
		//        CustomCircle* p = new CustomCircle();
		//        p->setPhysics(1.0, 0.0, 0.2);
		//				p->setup(box2d.getWorld(), ofRandom(0, ofGetWidth()), ofRandom(0, ofGetHeight()), ofRandom(7, 14));
		////        p->disableCollistion();
		//        particles.push_back(p);
		//    }
		
		//		ofURLFileLoader loader;
		//		loader.get("https://yt3.ggpht.com/-3js912icS0E/AAAAAAAAAAI/AAAAAAAAAAA/54i1xPNqEmM/s48-c-k-no/photo.jpg");
		//		loader.saveTo(<#string url#>, <#string path#>);
		//		imageTest.loadImage(loader);
		
		// custom rect
		//		photoNumberRect = 17;
		//		for (int i = 0; i<photoNumberRect; i++) {
		//				ofImage img;
		//				img.loadImage(ofToString(i)+".jpg");
		//				customRectImageVector.push_back(img);
		//		}
		
		// custom circle
		photoNumberCircleLogos = 36;
		for (int i = 0; i<photoNumberCircleLogos; i++) {
				ofImage img;
				img.loadImage("flat_icons/"+ofToString(i)+".png");
				customCircleImageVector.push_back(img);
		}
		
		//special circle
//		specialCircleImage.loadImage("special.png");
//		specialCircle = ofPtr<CustomCircle>(new CustomCircle);
//		specialCircle->setCircleMainColor(ofColor(ofRandom(0, 255), ofRandom(0, 255), ofRandom(0, 255), 127));
//		specialCircle->setBirthTime(ofGetElapsedTimef());
//		specialCircle->setPhysics(0.2, 0.0, 3.9);
//		specialCircle->setImage(specialCircleImage);
//		specialCircle->setup(box2d.getWorld(), ofRandom(0, ofGetWidth()), ofRandom(-ofGetHeight(), 0), ofRandom(30, 50));
		
		//初期追加
		//		for (int i=0; i<1000; i++) {
		//				circles.push_back(ofPtr<CustomCircle>(new CustomCircle));
		//				circles.back().get()->setCircleMainColor(ofColor(ofRandom(0, 255), ofRandom(0, 255), ofRandom(0, 255), 127));
		//				circles.back().get()->setBirthTime(ofGetElapsedTimef());
		//				circles.back().get()->setPhysics(1.0, 0.0, 3.9);
		//				circles.back().get()->setup(box2d.getWorld(), ofRandom(0, ofGetWidth()), ofRandom(-ofGetHeight(), 0), ofRandom(3, 20));
		//		}
		
		// 寿命
		circleLifeTime = 45;
		circleLogosLifeTime = 45;
		
		// 上限数
		circleNumberLimit = 0;
		circleLogoNumberLimit = 2000;
		
		// サイズの範囲設定
		circleSizeRangeMinimum = 3;
		circleSizeRangeMaximum = 30;
		circleLogoSizeRangeMinimum = 5;
		circleLogoSizeRangeMaximum = 41;
		
		// sound
		// register the listener so that we get the events
//		box2d.enableEvents();   // <-- turn on the event listener
//		ofAddListener(box2d.contactStartEvents, this, &ofApp::contactStart);
//		soundPlayer.loadSound("sound/4.mp3");
//		soundPlayer.setMultiPlay(true);
}
//--------------------------------------------------------------
void testApp::setup(){
    setupComplete = false;
    
    //graphics
    ofSetFrameRate(60);
    ofSetVerticalSync(true);
    ofEnableAlphaBlending();
    
    bUseFbo = false;
    bFlip = true;
    
    //leap setup
	leap.open();
    
    
	cam.setOrientation(ofPoint(-20, 0, 0));
	l1.setPosition(200, 300, 50);
	l2.setPosition(-200, -200, 50);
	glEnable(GL_DEPTH_TEST);
    glEnable(GL_NORMALIZE);
    
    ofSetFullscreen(true);
    fadesFbo.allocate(ofGetWidth(), ofGetHeight(), GL_RGBA32F_ARB);
    fadesFbo.begin();
	ofClear(255,255,255, 20);
    fadesFbo.end();
    
    //audio
    synth = ofxAudioUnitSampler('aumu', 'CaC2', 'CamA');
    synth.getParameters(false, false);
    synth.setBank(0, 0);
    prog = 0;
    synth.setProgram(prog);
    
    limiter = ofxAudioUnit('aufx', 'mcmp', 'appl');
    limiter.setParameter(kMultibandCompressorParam_Threshold1, kAudioUnitScope_Global, -10.0);
    limiter.setParameter(kMultibandCompressorParam_Headroom1, kAudioUnitScope_Global, 0.1);
    limiter.setParameter(kMultibandCompressorParam_Threshold2, kAudioUnitScope_Global, -10.0);
    limiter.setParameter(kMultibandCompressorParam_Headroom2, kAudioUnitScope_Global, 0.1);
    limiter.setParameter(kMultibandCompressorParam_Threshold3, kAudioUnitScope_Global, -10.0);
    limiter.setParameter(kMultibandCompressorParam_Headroom3, kAudioUnitScope_Global, 0.1);
    limiter.setParameter(kMultibandCompressorParam_Threshold4, kAudioUnitScope_Global, -10.0);
    limiter.setParameter(kMultibandCompressorParam_Headroom4, kAudioUnitScope_Global, 0.1);
    
    synth >> tap >> limiter >> output;
    output.start();
    
    tap.getSamples(samples);
    bufferSize = samples.size();
    buffer = new float[bufferSize];
    spectrum = new float[bufferSize/2];
    
    ofSoundStreamSetup(2, 0, 44100, bufferSize, 4);
    fftCalc.setup(bufferSize, bufferSize/8, 44100);
    
    int DorianScaleDegrees[] = {0, 2, 3, 5, 7, 9, 10};
    dorian.assign(DorianScaleDegrees, DorianScaleDegrees+7);
    
    
    //postproc
    post.init(1920, 1080);
    post.createPass<FxaaPass>()->setEnabled(true);
    post.createPass<BloomPass>()->setEnabled(true);
    post.createPass<KaleidoscopePass>()->setEnabled(true);
    
    //gui
    
    gui = new ofxUICanvas(0,0,320,640);
    gui->addWidgetDown(new ofxUILabel("LEAP HACK DAY", OFX_UI_FONT_LARGE));
    gui->addSpacer(304, 2);
    gui->addWidgetDown(new ofxUISlider(304,16,0.0,255.0,100.0,"BACKGROUND VALUE"));
    gui->addWidgetDown(new ofxUIToggle(32, 32, false, "FULLSCREEN"));
    gui->addSpacer(304, 2);
    gui->addWidgetDown(new ofxUIButton("LAST PATCH", false, 16, 16));
    gui->addWidgetDown(new ofxUIButton("NEXT PATCH", false, 16, 16));
    gui->addSlider("PROGRAM", 0, 127, &prog, 95, 16);
    gui->addSlider("XyPad1x", 0.0,1.0, &XyPad1x, 304, 16);
    gui->addSlider("XyPad1y", 0.0,1.0, &XyPad1y, 304, 16);
    gui->addSlider("XyPad2x", 0.0,1.0, &XyPad2x, 304, 16);
    gui->addSlider("XyPad2y", 0.0,1.0, &XyPad2y, 304, 16);
    gui->addSpacer(304, 2);
    gui->addWidgetDown(new ofxUILabel("WAVEFORM DISPLAY", OFX_UI_FONT_MEDIUM));
	gui->addWidgetDown(new ofxUIWaveform(304, 64, buffer, bufferSize, -1.0, 1.0, "WAVEFORM"));
    gui->addWidgetDown(new ofxUILabel("SPECTRUM DISPLAY", OFX_UI_FONT_MEDIUM));
    gui->addWidgetDown(new ofxUISpectrum(304, 64, spectrum, bufferSize/2, 0.0, 1.0, "SPECTRUM"));
    gui->addSpacer(304, 2);
    gui->addSlider("fade amnt", 1.0, 200.0, &fadeAmnt, 304, 16);
    gui->addToggle("kaleidascope", bKaleidoscope);
    
    ofAddListener(gui->newGUIEvent, this, &testApp::guiEvent);
    gui->loadSettings("GUI/guiSettings.xml");

    setupComplete = true;
}
//--------------------------------------------------------------
void testApp::guiEvent(ofxUIEventArgs &e)
{
    if(e.widget->getName() == "BACKGROUND VALUE")
    {
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        ofBackground(slider->getScaledValue());
    }
    else if(e.widget->getName() == "FULLSCREEN")
    {
        ofxUIToggle *toggle = (ofxUIToggle *) e.widget;
        ofSetFullscreen(toggle->getValue());
    }
    else if(e.widget->getName() == "XyPad1x")
    {
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        synth.setParameter(8, kAudioUnitScope_Global, slider->getScaledValue());
    }
    else if(e.widget->getName() == "XyPad1y")
    {
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        synth.setParameter(9, kAudioUnitScope_Global, slider->getScaledValue());
    }
    else if(e.widget->getName() == "XyPad2x")
    {
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        synth.setParameter(10, kAudioUnitScope_Global, slider->getScaledValue());
    }
    else if(e.widget->getName() == "XyPad2y")
    {
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        synth.setParameter(11, kAudioUnitScope_Global, slider->getScaledValue());
    }
    else if(e.widget->getName() == "LAST PATCH")
    {
        ofxUIButton *button = (ofxUIButton *) e.widget;
        if(button->getValue())
        {
            prog--;
            if (prog < 0) prog = 0;
            synth.setProgram(prog);
        }
    }
    else if(e.widget->getName() == "NEXT PATCH")
    {
        ofxUIButton *button = (ofxUIButton *) e.widget;
        if(button->getValue())
        {
            prog++;
            if (prog > 127) prog = 127;
            synth.setProgram(prog);
        }
    }
    else if(e.widget->getName() == "fade amnt")
    {
        ofxUISlider *slider = (ofxUISlider *) e.widget;
    }
    
    
    //params
    /*
     #8: _XyPad1x [0 ~ 1]
     #9: _XyPad1y [0 ~ 1]
     #10: _XyPad2x [0 ~ 1]
     #11: _XyPad2y [0 ~ 1]
     */
}
Beispiel #10
0
//--------------------------------------------------------------
void testApp::keyPressed(int key){
	ofSetFullscreen(true);
}
Beispiel #11
0
void testApp::guiEvent(ofxUIEventArgs &e)
{
    if(e.getName() == "FULLSCREEN")
    {
        ofxUIToggle *toggle = e.getToggle();
        ofSetFullscreen(toggle->getValue());
    }else if(e.getName() == "Meditation_Level")
    {
        ofxUISlider *slider = e.getSlider();
        meditationLevel = slider->getScaledValue();
    }else if(e.getName() == "camera_distance"){
        ofxUISlider *slider = e.getSlider();
        camDistance = slider->getScaledValue();
    }else if(e.getName() == "background_color"){
        ofxUISlider *slider = e.getSlider();
        ofBackground(slider->getScaledValue());
    }else if(e.getName() == "Whole_Scene_Position_x"){
        ofxUISlider *slider = e.getSlider();
        whole_scene_x = slider->getScaledValue();
    }else if(e.getName() == "Whole_Scene_Position_y"){
        ofxUISlider *slider = e.getSlider();
        whole_scene_y = slider->getScaledValue();
    }else if(e.getName() == "Whole_Scene_Position_z"){
        ofxUISlider *slider = e.getSlider();
        whole_scene_z = slider->getScaledValue();
    }else if(e.getName() == "Whole_Scene_Rotate_x"){
        ofxUISlider *slider = e.getSlider();
        scene_rx = slider->getScaledValue();
    }else if(e.getName() == "Whole_Scene_Rotate_y"){
        ofxUISlider *slider = e.getSlider();
        scene_ry = slider->getScaledValue();
    }else if(e.getName() == "Whole_Scene_Rotate_z"){
        ofxUISlider *slider = e.getSlider();
        scene_rz = slider->getScaledValue();
    }else if(e.getName() == "particle_Size"){
        ofxUISlider *slider = e.getSlider();
        particleSize = slider->getScaledValue();
    }else if(e.getName() == "PlaneX"){
        ofxUISlider *slider = e.getSlider();
        planeX = slider->getScaledValue();
    }else if(e.getName() == "PlaneY"){
        ofxUISlider *slider = e.getSlider();
        planeY = slider->getScaledValue();
    }else if(e.getName() == "PlaneZ"){
        ofxUISlider *slider = e.getSlider();
        planeZ = slider->getScaledValue();
    }else if(e.getName() == "whole_scene_scale"){
        ofxUISlider *slider = e.getSlider();
        whole_scene_scale = slider->getScaledValue();
    }else if(e.getName() == "tv_x"){
        ofxUISlider *slider = e.getSlider();
        tv_x = slider->getScaledValue();
    }else if(e.getName() == "tv_y"){
        ofxUISlider *slider = e.getSlider();
        tv_y = slider->getScaledValue();
    }else if(e.getName() == "tv_z"){
        ofxUISlider *slider = e.getSlider();
        tv_z = slider->getScaledValue();
    }else if(e.getName() == "gif_x"){
        ofxUISlider *slider = e.getSlider();
        image_x = slider->getScaledValue();
    }else if(e.getName() == "gif_y"){
        ofxUISlider *slider = e.getSlider();
        image_y = slider->getScaledValue();
    }else if(e.getName() == "gif_z"){
        ofxUISlider *slider = e.getSlider();
        image_z = slider->getScaledValue();
    }else if(e.getName() == "gif_scale"){
        ofxUISlider *slider = e.getSlider();
        image_scale = slider->getScaledValue();
    }
}
Beispiel #12
0
//--------------------------------------------------------------
void ofApp::keyPressed(int key)
{
    //キー入力でモード切り替え
    switch (key)
    {
        case '0':
            //カラー映像表示
            videoMode = 0;
            break;
            
        case '1':
            //グレースケール映像表示
            videoMode = 1;
            break;
            
        case '2':
            //背景画像表示
            videoMode = 2;
            break;
            
        case '3':
            //2値化した差分映像
            videoMode = 3;
            break;
            
        case 'a':
            //解析結果の表示の on / off
            showCvAnalysis ? showCvAnalysis=false : showCvAnalysis=true;
            break;
            
        case 'f':
            //フルスクリーンに
            ofSetFullscreen(true);
            break;
            
        case ' ':
            //背景画像を新規に取り込む
            bLearnBakground = true;
            break;
            
        case '+':
            //2値化の閾値を増加
            threshold ++;
            if (threshold > 255) threshold = 255;
                break;
            
        case '-':
            //2値化の閾値を減少
            threshold --;
            if (threshold < 0) threshold = 0;
                break;
            
        case 'd':
            //カメラ切替
            devID ? devID = 0 : devID = 1;
            
            vidGrabber.close();
            vidGrabber.setDeviceID(devID);
            vidGrabber.initGrabber(320,240);
            vidGrabber.bind();
            break;

    }
}
//--------------------------------------------------------------------------
void testApp::setup() {	
	doScreenshots = false;
	screenshotCount = 0;
	
	ofxDaito::setup("oscSettings.xml");
	ofxConnexion::start();
	ofAddListener(ofxConnexion::connexionEvent, this, &testApp::connexionEvent);
	ofxConnexion::setLed(false);
	
	frameScaleFactor = .6;
	frameW = 320 * frameScaleFactor;
	frameH = 240 * frameScaleFactor;
	int numParticles = frameW * frameH;
	
	SP.setup(frameW, frameH);
	SP.loadDirectory("input/otherTest/");
	
	notifier.setup("network.xml");
	notifier.enable();
	ofAddListener(notifier.theEvent,this,&testApp::eventsIn);		
	
	state = VIZAPP_PARTICLES_FREE;
	
	setupControlPanel();
	if( bDebugMode == false ){
		ofSetFullscreen(true);
		panel.hide();
	}
		
	bJustLoadedUser = false;	
	pointBrightness = .5;
	aberration		= .02;
	aperture		= .01;
	
	dofShader.load("shaders/DOFCloud");
	sphereShader.load("shaders/SphereShader");
	
	timeLastLoaded = ofGetElapsedTimef();

	bDoUnload = false;

	PS.setup(numParticles);
	
	isMousePressed = false;
	
	chroma.allocate(targetWidth, targetHeight);
	chroma.begin();
	ofClear(0, 0, 0, 255);
	chroma.end();
	
	bTogglePlayer = panel.getValueB("toggle_mode");
	
	for(int k = 0; k < PS.particles.size(); k++){	
		PS.particles[k].queueState(PARTICLE_FLOCKING,  0.0);
	}
	
	connexionCamera.setup(PS);
	currentMsg = "app started";
	
	isSlow = false;
	slowState = 0;
	
	ofEnableAlphaBlending();
	
	keyPressed('f');
	keyPressed('h');
	
	ofSetSphereResolution(16);
}
Beispiel #14
0
//--------------------------------------------------------------
void testApp::setup(){

	std::stringstream versionStr;
	versionStr << APP_VERSION_MAJOR << "." << APP_VERSION_MINOR;
	m_versionString = versionStr.str();
    //-----------
	//the string is printed at the top of the app
	//to give the user some feedback
	message = "loading AppSettings.xml";
    std::cout << message << std::endl;
	//we load our settings file
	//if it doesn't exist we can still make one
	//by hitting the 's' key
	if( XML.loadFile("AppSettings.xml") ){
		message = "AppSettings.xml loaded!";
	}else{
		message = "unable to load AppSettings.xml check data/ folder";
	}
	std::cout << message << std::endl;

    oschost = XML.getValue("settings:osc:host", "localhost");
    oscport = XML.getValue("settings:osc:port", 57120);

	nPts = 0;
	nPtsBackup = 0;
	m_runInterval = 0;
	m_prevTime = 0;
	ofBackground(255, 255, 255);
	sender.setup(oschost,oscport);
//	sender.setup(HOST, PORT);
	m_run = false;
	m_BallPos = 0;
	m_numSampls = 0;
	isPlaying = true;

	if (XML.getValue("settings:startup:fullscreen", 0))
		isFullScreen = true;
	else
		isFullScreen = false;
	ofSetFullscreen(isFullScreen);
	
	if (XML.getValue("settings:startup:debugmode", 0))
		debugMode = true;
	else
		debugMode = false;

	if (XML.getValue("settings:startup:colormode", 0))
		showColors = true;
	else
		showColors = false;

	if (XML.getValue("settings:startup:helpmode", 0))
		helpMode = true;
	else
		helpMode = false;

	if(XML.getValue("settings:startup:aboutscreen", 0))
		usageMode = true;
	else
		usageMode = false;

	if (XML.getValue("settings:debug:position", 1))
		showOscDebugPosition = true;
	else
		showOscDebugPosition = false;

	if (XML.getValue("settings:debug:sysout", 1))
		debugOutput = true;
	else
		debugOutput = false;

	m_savedStatesFileName = XML.getValue("settings:states:file", "savedStatesDefault.xml");

	m_currentSample = 0;

	for (int i = 0; i < MAX_SAMPLES; ++i) {
		m_sampleColors[i].r = ofRandom(0, 255);
		m_sampleColors[i].g = ofRandom(0, 255);
		m_sampleColors[i].b = ofRandom(0, 255);
		m_sampleColors[i].a = 127;
		m_numSamples[i] = 0;
	}

	message = "loading "+m_savedStatesFileName;
    std::cout << message << std::endl;
	//we load our settings file
	//if it doesn't exist we can still make one
	//by hitting the 's' key
	if( XMLstates.loadFile(m_savedStatesFileName) ){
		message = m_savedStatesFileName+" loaded!";
	}else{
		message = "unable to load "+m_savedStatesFileName+" check data/ folder";
	}
	std::cout << message << std::endl;

	lastTagNumber = 0;

	int tags = XMLstates.getNumTags("STATE");
	lastTagNumber = tags;
	if (debugOutput) {printf("states : %i\n", tags);}
	std::stringstream numstates;
	numstates << tags;
	m_stateLoadMessage = numstates.str();

	m_currentState = 0;

	m_fontTitle.loadFont("Sudbury_Basin_3D.ttf", 50);
	m_fontOfVersion.loadFont("mono.ttf", 7);
	m_fontText.loadFont("mono.ttf", 10);
	
	buttonPushed = false;
	stateTen = 0;
}
//#define TEST_COUNTER
//--------------------------------------------------------------
void testApp::setup(){
#ifdef TEST_COUNTER
    ofSetLogLevel(OF_LOG_SILENT);
    cout << "Start test Count 10000" << endl;
    cout << "--------------------------------------------------------------" << endl;

    for(int i = 0 ; i < 10000 ; i++)
    {
        stateMachine.getSharedData().load();
        cout << "Count = "<< stateMachine.getSharedData().counter <<endl;
        stateMachine.getSharedData().counter+=1;
        stateMachine.getSharedData().save();
	}
    cout << "End test Count 10000" << endl;
    cout << "--------------------------------------------------------------" << endl;

    std::exit(0);
#endif
    ofEnableSmoothing();
	ofEnableAlphaBlending();
    ofSetVerticalSync(true);
    glDisable(GL_DEPTH_TEST);
    ofxXmlSettings xml  = stateMachine.getSharedData().xml;
    if(xml.loadFile(settingFileName))
	{
		if(xml.pushTag("DATA"))
		{
            stateMachine.getSharedData().bDebug = xml.getValue("DEBUG", true);   
            float width = xml.getValue("WIDTH", 1280);    
            float height = xml.getValue("HEIGHT", 720);
            sndPlayer.loadSound(xml.getValue("SOUND_PATH", "sounds/Zone 5 - Door Creak, scream and witchly laugh.wav"));
            sndPlayer.setLoop(true);
            sndPlayer.play();
            stateMachine.getSharedData(). wRatio = width/1920;
            stateMachine.getSharedData(). hRatio = height/1080;
            ofSetFullscreen(xml.getValue("FULLSCREEN", 0));
            ofSetWindowShape(width, height);
			stateMachine.getSharedData().path_to_save = xml.getValue("CAPTURE_PATH", "./captures");
            stateMachine.getSharedData().filesXml.loadFile(stateMachine.getSharedData().path_to_save+"/files.xml");
            if(!stateMachine.getSharedData().filesXml.pushTag("XML"))
            {
                stateMachine.getSharedData().filesXml.addTag("XML");
                stateMachine.getSharedData().filesXml.pushTag("XML");
            }
			stateMachine.getSharedData().numDigi = xml.getValue("DIGI", 5);
            stateMachine.getSharedData().font.loadFont(xml.getValue("FONT_PATH", "fonts/LunacyMore.ttf"),xml.getValue("FONT_SIZE", 128));
			ofDirectory dir;
			if(dir.listDir(stateMachine.getSharedData().path_to_save)<1)
			{
				dir.createDirectory(stateMachine.getSharedData().path_to_save);
			}
			
			xml.popTag();
		}
	}
	else
	{
		ofLog(OF_LOG_ERROR,"Faile to load "+ settingFileName);
	}
    
	//    // setup shared data
    ofxControlPanel::setBackgroundColor(simpleColor(30, 30, 60, 100));
	ofxControlPanel::setTextColor(simpleColor(240, 50, 50, 255));
    stateMachine.getSharedData().panel.setup(ofGetWidth(),ofGetHeight());
	stateMachine.getSharedData().panel.loadFont("MONACO.TTF", 8);		
	stateMachine.getSharedData().panel.addPanel("General", 4,false);
    
	ofxControlPanel::setBackgroundColor(simpleColor(60, 30, 30, 100));	
	stateMachine.getSharedData().panel.addPanel("FaceTracking", 5, false);
    ofxControlPanel::setBackgroundColor(simpleColor(60, 30, 30, 100));	
	stateMachine.getSharedData().panel.addPanel("FaceTracking0", 4, false);
    ofxControlPanel::setBackgroundColor(simpleColor(60, 30, 30, 100));	
	stateMachine.getSharedData().panel.addPanel("FaceTracking1", 4, false);
    
	ofxControlPanel::setBackgroundColor(simpleColor(70, 70, 30, 100));	
	stateMachine.getSharedData().panel.addPanel("FaceMapEdit", 4, false);
    
	ofxControlPanel::setBackgroundColor(simpleColor(30, 30, 30, 100));	
    //some dummy vars we will update to show the variable lister object
	appFrameRate	= ofGetFrameRate();
    stateMachine.getSharedData().panel.setWhichPanel("General");
    stateMachine.getSharedData().panel.setWhichColumn(0);
	stateMachine.getSharedData().panel.addChartPlotter("some chart", guiStatVarPointer("app fps", &appFrameRate, GUI_VAR_FLOAT, true, 2), 200, 50, 200, 5, 80);
    vector<string> loglevel;
    loglevel.push_back("OF_LOG_VERBOSE");
    loglevel.push_back("OF_LOG_NOTICE");
    loglevel.push_back("OF_LOG_WARNING");
    loglevel.push_back("OF_LOG_ERROR");
    loglevel.push_back("OF_LOG_FATAL_ERROR");
    loglevel.push_back("OF_LOG_SILENT");
    stateMachine.getSharedData().panel.addTextDropDown("LogLevel","LogLevel", 0, loglevel);
	
	// initialise state machine
	stateMachine.addState(new IndexState());
	stateMachine.addState(new SelectPlayerState());
	stateMachine.addState(new CaptureState());
	stateMachine.addState(new EditState());
	stateMachine.addState(new EndState());
	stateMachine.addState(new LicenseState());
	stateMachine.changeState(xml.getValue("DATA:INIT_STATE", "IndexState"));
    stateMachine.getSharedData().panel.loadSettings("settings.xml");
    stateMachine.getSharedData().panel.hide();
//    if(!stateMachine.getSharedData().bDebug)
//    {
////        stateMachine.getSharedData().panel.unregisterKeyboardEvent();
//    }
    stateMachine.getSharedData().numPlayer = 1;
    for(int i = 0 ; i < NUM_SEQ ;i++)
    {
        image[i].loadSequence("images/bat/bat_", "png", 0, 154, 5);
        image[i].setFrameRate(60);
    }
    
    int num = 3000;
    
	stateMachine.getSharedData().p.assign(num, Particle());
    resetParticles();
    
    
}
Beispiel #16
0
//--------------------------------------------------------------
void ofRender::update(){
    
    string WindowTitle = "";
    WindowTitle = "Spreads_Display";
    WindowTitle += " - ";
    WindowTitle += ofToString(ofGetFrameRate());
    
    ofSetWindowTitle(WindowTitle);
    
    // 1ere Affect des tailles de fenetre
    // CALCUL DE LA TAILLE DE FENETRE ET EVENEMENT -----------------------------------
    /*
    if(m_slWidthDisplay!=getWidth() || m_slHeightDisplay!=getHeight()){
      windowResized(m_slWidthDisplay, m_slHeightDisplay);
    }
     */
    // Fullscreen ? --
    ofSetFullscreen(m_btFullScreen);
    
    // RECUPERATION DEPUIS La GUI ET INJECTION DANS LE SYSTEME
    ofLogVerbose() << ("Trace Error : __GUI__");
    updateGUI();
    
    // MSA Modes
    // Changement de page MSA
    /*
    switch (m_slDrawMode){
        case MSAmode_Vectors:
            m_MSA.fluidDrawer.setDrawMode(msa::fluid::kDrawVectors);
            break;
        case MSAmode_Speed:
            m_MSA.fluidDrawer.setDrawMode(msa::fluid::kDrawSpeed);
            break;
        case MSAmode_Motion:
            m_MSA.fluidDrawer.setDrawMode(msa::fluid::kDrawMotion);
            break;
        case MSAmode_Colors:
            m_MSA.fluidDrawer.setDrawMode(msa::fluid::kDrawColor);
            break;
        case MSAmode_DrawCount:
            m_MSA.fluidDrawer.setDrawMode(msa::fluid::kDrawCount);
            break;
        default:
            break;
    }
    */
    // PAD -------------------------------------------------------------------------
    ofLogVerbose() << ("Trace Error : __ PADS __");
    
    // Events Particules -----------------------------------------
    // TODO : with new ofxAttractors
    /*
    if (m_oOscEvents.getConstValue("/Events/Parts/Center") > 0.5) {
        m_oPartWorld.set_partsAtPosition(POSPARTS_CENTER, m_oOscEvents.getConstValue("/Events/Parts/Center"));
    }
    if (m_oOscEvents.getConstValue("/Events/Parts/Circle") > 0.5) {
        m_oPartWorld.set_partsAtPosition(POSPARTS_CIRCLE, m_oOscEvents.getConstValue("/Events/Parts/Circle"));
    }
    if (m_oOscEvents.getConstValue("/Events/Parts/Hori") > 0.5) {
        m_oPartWorld.set_partsAtPosition(POSPARTS_HORI, m_oOscEvents.getConstValue("/Events/Parts/Hori"));
    }
    if (m_oOscEvents.getConstValue("/Events/Parts/Vert") > 0.5) {
        m_oPartWorld.set_partsAtPosition(POSPARTS_VERT, m_oOscEvents.getConstValue("/Events/Parts/Vert"));
    }
    */
    
    // --------------------------------------------------------------
    // ALL PATTERNS EVENTS -------------------------------------------
    // ON / OFF
    while (!m_oOscEventsOnOff.isEventsEmpty()){
        ofxEasyOscEventMessage eventToGo = m_oOscEventsOnOff.getFirstEvent();
        
        string  family = eventToGo.getFamily();
        string  name = eventToGo.getName();
        float   value = eventToGo.getValue();
        
        // On envoie le pattern si c'est du note off (c'est ˆ dire value = 0)
        if(value!=0){
            //m_oSpreads.eventSequence(_family, _name, m_oSpreads.m_slModeTypo2, m_oPartWorld.m_btPartsOn, false);
            //m_oSpreads.eventAll(_family, _name, m_oPartWorld.m_btPartsOn, false);
            m_oSpreads.eventOn(family, name, 255*value, m_oPartWorld.m_btPartsOn, true);
            //m_oSpreads.eventOn(family, name, 255*value, false, true);
        }else{
            m_oSpreads.eventOff(family, name);
        }
        
        if(family=="arduino"){
            m_oArduinoClient.addPwmSignal(ofToInt(name), 255*value);
        }

    };
    
    while (!m_oOscEventsFades.isEventsEmpty()){
        ofxEasyOscEventMessage eventToGo = m_oOscEventsFades.getFirstEvent();
        
        string  family = eventToGo.getFamily();
        string  name = eventToGo.getName();
        float   value = eventToGo.getValue();
        
        if(value!=0){
            // On envoie le pattern si c'est du note off (c'est ˆ dire value = 0)
            // m_oSpreads.eventAll(family, name, 255*value, m_oPartWorld.m_btPartsOn, true);
            m_oSpreads.eventSequence(family, name, 255*value, m_oPartWorld.m_btPartsOn, m_oSpreads.m_slSeqMode, true);
        }
        
        if(family=="arduino"){
            m_oArduinoClient.addPwmSignal(ofToInt(name), 255*value);
        }
        
    };
    
    // --------------------------------------------------------------
    // AUDIO REACTION ------------------------------------------------------------
    ofLogVerbose() << ("Trace Error : __ AUDIO __");
    
    /*
    if (m_oOscEvents.getConstValue("/Audio/Trigger/Bass")>0.5){
        m_oSpreads.eventSequence(ofToString(0), m_oSpreads.m_slModeTypo2, m_oPartWorld.m_btPartsOn, false);
    }
    if (m_oOscEvents.getConstValue("/Audio/Trigger/Mid")>0.5){
        m_oSpreads.eventSequence(ofToString(1), m_oSpreads.m_slModeTypo2, m_oPartWorld.m_btPartsOn, false);
    }
    if (m_oOscEvents.getConstValue("/Audio/Trigger/High")>0.5){
        m_oSpreads.eventSequence(ofToString(2), m_oSpreads.m_slModeTypo2, m_oPartWorld.m_btPartsOn, false);
    }
    */
    
    // UPDATES ----------------------------------------------------------------------
    ofLogVerbose() << ("Trace Error : __ UPDATES __");

    // COLOR SET ---------------------------------------------------------------------
    m_oColorSet.update();
    
    // PARTICULES -------------------
    m_aAttractors["top"].setActive(m_btTop);
    m_aAttractors["bottom"].setActive(m_btBottom);
    m_aAttractors["left"].setActive(m_btLeft);
    m_aAttractors["right"].setActive(m_btRight);
    
    m_oPartWorld.setAttractors(&m_aAttractors);
    m_oPartWorld.update();
    
    // SPREADS ----------------------
    m_oSpreads.update();
    
    // MSA no more compatible ----
    /*
    updateMSA();                    // Update des paramètres MSA
    m_MSA.update();                 // MSA Particules
    
    // RECALCULS DES TRACKERS ----------------------------------------------------------------------
    ofLogVerbose() << ("Trace Error : __ TrackersMSA __");
    // ici on gére les rendus des particules qui ne sont pas gérés dans les particules en elles-mêmes
    if(m_slDrawMode != MSAmode_None){
        
        vector<ofxParticle*>::iterator itParts;
        vector<ofxParticle*>          trackers = m_oPartWorld.m_aPartTrackers;
        
        Vec2f pos;
        Vec2f vel;
        
        for(itParts = trackers.begin(); itParts!= trackers.end(); itParts++){
            
            vel.x = (*itParts)->getVel().x / getWidth();
            vel.y = (*itParts)->getVel().y / getHeight();
            
            pos.x = (*itParts)->getPos().x / getWidth();
            pos.y = (*itParts)->getPos().y / getHeight();
            
            switch(m_slDrawMode){
                case MSAmode_Motion:
                case MSAmode_Speed:
                case MSAmode_Vectors:
                    m_MSA.addToFluid(pos,vel,true,true);
                    break;
                    
                case MSAmode_Colors:
                case MSAmode_DrawCount:
                    m_MSA.addToFluid(pos,vel,true,false);
                    break;
                    
                case MSAmode_None:
                default:
                    break;
                    
            }
        }
    }
    */
    
    // ARDUINO --------------------------------------------------------------------------
    m_oArduinoServer.update();
    // ----------------------------------------------------------------------------------
    
    //  INFOS
    m_strTrace = ofToString(ofGetElapsedTimeMillis()) + " |\t" ;
    m_strTrace += ofToString(ofGetFrameRate()) + " |\t" ;
    m_strTrace += ofToString("Parts: " + ofToString(m_oPartWorld.m_aParts.size())) + " |\t";
    m_strTrace += ofToString("Trackers: " + ofToString(m_oPartWorld.m_aPartTrackers.size())) + " |\t";
    m_strTrace += "Background : " + ofToString(m_oSpreads.m_spreadsDrawings.size()) + " x " + m_oSpreads.lastSpreadFamily() + " : " + ofToString(m_numPattern)+ " |";
    
    ofLogVerbose() << m_strTrace;
    
}
Beispiel #17
0
//--------------------------------------------------------------
void shaderApp::setup()
{
    ofSetLogLevel(OF_LOG_NOTICE);
	//ofSetLogLevel(OF_LOG_VERBOSE);
	ofSetLogLevel("ofThread", OF_LOG_SILENT);
	ofSetVerticalSync(false);
	ofEnableAlphaBlending();
	ofSetFullscreen(true);
	
	doDrawInfo = false;
	
	OMXCameraSettings omxCameraSettings;
	omxCameraSettings.width = 640;
	omxCameraSettings.height = 480;
	omxCameraSettings.framerate = 30;
	omxCameraSettings.isUsingTexture = true;
	
	videoGrabber.setup(omxCameraSettings);

    
    
	shader.load("shaderExample");
	

	ofLogNotice() << "Allocating FBOs";
	camFbo.allocate(omxCameraSettings.width, omxCameraSettings.height);
	camFbo.begin();
		ofClear(0, 0, 0, 0);
	camFbo.end();
	
	overlayFbo.allocate(omxCameraSettings.width, omxCameraSettings.height);
	overlayFbo.begin();
		ofClear(0, 0, 0, 0);
	overlayFbo.end();


	ofLogNotice() << "listening for osc messages on port " << PORT << "\n";
	receiver.setup(PORT);


	ofLogNotice() << "Loading fonts";
	font[0].loadFont("fonts/Neue Helvetica/HelveticaNeueLTCom-Bd.ttf", 120);
	font[1].loadFont("fonts/Neue Helvetica/HelveticaNeueLTCom-Md.ttf", 48);

    
	ofLogNotice() << "Listing filters";
	map<string, OMX_IMAGEFILTERTYPE>::iterator it;
	for(it = OMX_Maps::getInstance().imageFilters.begin();
			it!=OMX_Maps::getInstance().imageFilters.end(); ++it) {
        	ofLogNotice() << (*it).first;
   	}

	ofLogNotice() << "Listing videos";
	ofDirectory dir;
	dir.listDir(VIDEO_DIRECTORY);
	for(int i = 0; i < (int)dir.size(); i++){
		string path = dir.getName(i);
		ofLogNotice() << path;
	}

    ofxOMXPlayerSettings settings;
    settings.videoPath = dir.getPath(0);
    settings.useHDMIForAudio = false;	//default true
    settings.enableTexture = true;		//default true
    settings.enableLooping = false;		//default true
    settings.enableAudio = true;		//default true, save resources by disabling
    settings.listener = this;
    omxPlayer.setup(settings);
    omxPlayer.setVolume(1);
    
    displayMode = MODE_VIDEO;
    float duration = omxPlayer.getDuration();
    videoEndTime = ofGetElapsedTimef() + omxPlayer.getDuration();
    
    timeMarkerTime = ofGetElapsedTimef() + 10;
}	
Beispiel #18
0
//--------------------------------------------------------------
void myAmeManager::keyPressed(int key ){
    switch(key)
    {
	case 'h':
		gui1->toggleVisible(); 
		gui2->toggleVisible(); 
		gui3->toggleVisible(); 
		bStadisticsVisible = !bStadisticsVisible;
        break;
	case 's':
		gui1->saveSettings("GUI/guiSettings1.xml"); 
		gui2->saveSettings("GUI/guiSettings2.xml"); 
		gui3->saveSettings("GUI/guiSettings3.xml"); 

		saveCameraPosition();
		printf("camera matrix saved\n");
		break;
	case 'l':
		loadCameraPosition();
		gui1->loadSettings("GUI/guiSettings1.xml");
		gui2->loadSettings("GUI/guiSettings2.xml");
		gui3->loadSettings("GUI/guiSettings3.xml");
		break;
	case 'f':
		ofSetWindowPosition(0, 0);
		ofSetVerticalSync(false);
		//ofSetFullscreen(false);
		break;
	case 'F':
		ofSetWindowPosition(windowXpos, 0);
		ofSetVerticalSync(true);
		ofSetFullscreen(true);
		break;
    case OF_KEY_UP:
        if(bcameraMode)cam.getTarget().boom(-5);
		else {
			cam.tilt(1);
		}
        break;
    case OF_KEY_DOWN:
        if(bcameraMode)cam.getTarget().boom(5);
		else {
			cam.tilt(-1);
		}
        break;
    case OF_KEY_LEFT:
        if(bcameraMode)cam.getTarget().truck(-5);
		else {
			cam.pan(1);
		}
        break;
    case OF_KEY_RIGHT:
        if(bcameraMode)cam.getTarget().truck(5);
		else {
			cam.pan(-1);
		}
        break;
	case 'M':
		bcameraMode = !bcameraMode;
		break;
	case OF_KEY_RETURN:
		//sequence of movements animated with timer
		animationTimer.reset();
		//animationTimer.setup(1000, false);
		animationTimer.startTimer();
		bactionTimer = true;
		//animationTimer.resumeTimer();
		//Save clip position
		last_clipPlaneDepth = clipPlaneDepth;
		break;
	}
		
}
Beispiel #19
0
void configuration::readGeneralConfig(string cfgFile){
    cout << ofToDataPath(cfgFile) << endl;
	ifstream config(ofToDataPath(cfgFile).c_str());
	while (config.peek()!=EOF) {
		string nextLine;
		getline(config, nextLine);
		vector<string> token=ofSplitString(nextLine, "=");
		if(token.size()){
            cout << token[0] << endl;
			if(token[0]=="MCU") mcu=token[1];
			else if(token[0]=="TRANSFER_RATE") baud=token[1];
			else if(token[0]=="PROGRAMMER") programmer=token[1];
			else if(token[0]=="F_CPU"){
				if(token[1]=="16M") freq="16000000L";
				else if(token[1]=="8M") freq="8000000L";
				else if(token[1]=="20M") freq="20000000L";
				else freq=token[1];
			}
			else if(token[0]=="BOARD"){
				if(token[1]=="UNO") mcu="atmega328p", programmer="arduino", freq="16000000L",baud="115200";
				else if(token[1]=="DUEM") mcu="atmega328p", programmer="arduino", freq="16000000L",baud="57600";
                else if(token[1]=="PEAPOD") mcu="attiny85", programmer="usbtiny", freq="8000000L",baud="";
			}
			else if(token[0]=="EXCLUDE_PORT"){
				excludedPort.push_back(token[1]);
				if(verbose) cout << "Port " << token[1] << " will not be used to program."<<endl;
			}
			else if(token[0]=="INSTALL_DIR"){
				rootDir=ofToDataPath(token[1]);
				toolDir=rootDir+"hardware/tools/avr/bin/";
			}
			else if(token[0]=="PERIPHERAL"){
				addonLib=ofToDataPath(token[1]);
			}
			else if(token[0]=="VERBOSE"){
				verbose=ofToInt(token[1]);
			}
			else if(token[0]=="TIMEOUT"){
				timeout=ofToInt(token[1]);
                cout << "timeout is " << timeout/1000 << "seconds" << endl;
			}
			else if(token[0]=="ROBOT"){
				if(verbose) cout << token[1] << " is the current robot configuration." << endl;
				robotRoot=ofToDataPath("robots/"+token[1]);
			}
			else if(token[0]=="TEST_AVAILABLE"){
				test=ofToInt(token[1]);
			}
			else if(token[0]=="SCROLL_SCREEN"){
				scroll=ofToInt(token[1]);
			}
			else if(token[0]=="PORTRAIT_MODE"){
				portraitMode=ofToInt(token[1]);
				//ofSetWindowShape(ofGetScreenWidth(),ofGetScreenHeight());
			}
			else if(token[0]=="NEW_USER_BUTTON"){
				if(token[1].length()>1){
					drawNewUser=true;
					//newUser.setTextSize(ofToInt(token[1]));
					newUser.setup(token[1],buttonFontSize);
				}
				else drawNewUser=false;
			}
			else if(token[0]=="WRAPPER"){
				wrapperFile=token[1];
			}
			else if(token[0]=="BLOCK_FONT_SIZE"){
				blockFontSize=ofToInt(token[1]);
			}
			else if(token[0]=="BUTTON_FONT_SIZE"){
				buttonFontSize=ofToInt(token[1]);
			}
			else if(token[0]=="UPLOADED_MESSAGE"){
				uploadedMessage=token[1];
			}
			else if(token[0]=="CONNECT_MESSAGE"){
				connectMessage=token[1];
			}
			else if(token[0]=="DISCONNECT_MESSAGE"){
				disconnectMsg=token[1];
			}
			else if(token[0]=="DEMO_MESSAGE"){
				demoMsg=token[1];
			}
			else if(token[0]=="CREATE_MESSAGE"){
				createMsg=token[1];
			}
			else if(token[0]=="EDIT_MESSAGE"){
				editMsg=token[1];
			}
			else if(token[0]=="CLEAR_MESSAGE"){
				clearMsg=token[1];
			}
			else if(token[0]=="BOARD_DETECT"){
			    boardDetect=ofToInt(token[1]);
			}
			else if(token[0]=="LEVEL_FOLDER"){
		      levelFolders.push_back(token[1]);
			}
			else if(token[0]=="ABS_SAVE_DIR"){
				programDir=token[1];
				if(verbose) cout << "The directory to which programs are saved is " << programDir <<endl;
			}
			else if(token[0]=="SAVED_PROGRAM_DIR"){
				programDir=ofToDataPath(token[1]);
			}
			else if(token[0]=="SAVE_PROGRAMS"){
				savePrograms=ofToInt(token[1]);
			}
			else if(token[0]=="FULLSCREEN"){
				ofSetFullscreen(ofToInt(token[1]));
			}
			else if(token[0]=="TITLE_BAR_SIZE"){
				titleBarSize=ofToInt(token[1]);
                if(titleBarSize) showTitle=true;
			}
			else if(token[0]=="DEMO_AVAILABLE"){
				demoAvailable=ofToInt(token[1]);
			}
			else if(token[0]=="CONTROL_BAR_COLOR"){
				controlBarColor=ofColor(strtol(token[1].c_str(),NULL,0));
				controlBarColor.a=255;
			}
			else if(token[0]=="BG_COLOR"){
				backgroundColor=ofColor(strtol(token[1].c_str(),NULL,0));
				backgroundColor.a=255;
			}
			else if(token[0]=="SIDE_BAR_COLOR"){
				sideBarColor=ofColor(strtol(token[1].c_str(),NULL,0));
				sideBarColor.a=255;
			}
			else if(token[0]=="LINE_COLOR"){
				lineColor=ofColor(strtol(token[1].c_str(),NULL,0));
				lineColor.a=255;
			}
			else if(token[0]=="TEXT_COLOR"){
				textColor=ofColor(strtol(token[1].c_str(),NULL,0));
				textColor.a=255;
			}
			else if(token[0]=="SUBTITLE_COLOR"){
				subtitleColor=ofColor::fromHex(strtol(token[1].c_str(),NULL,0));
                cout << subtitleColor << endl;
				subtitleColor.a=255;
			}
			else if(token[0]=="DEFAULT_COLORS"){
				defaultColor=ofToInt(token[1]);
			}
			else if(token[0]=="BUTTONS_ON_SIDEBAR"){
				buttonsOnSidebar=ofToInt(token[1]);
			}
			else if(token[0]=="SAVE_NOT_UNDO"){
				saveNotUndo=ofToInt(token[1]);
			}
		}
	}
	config.close();
    if(!wrapperFile.length()) wrapperFile = robotRoot+"/wrapper.wrp";
}
Beispiel #20
0
//--------------------------------------------------------------
void ofApp::setup(){
    
    sender.setup(HOST, PORT);
    stage.set(0, 0, ofGetWidth(), ofGetHeight());

    
    ofSetFullscreen(true);  // set fullscreen
    
    open=true;              // set the polygon true at the beginning
    running=true;
    ableClick=true;
//    ofSetBackgroundAuto(false);
    ofBackground(15);      //background white
    handlerRadius = 5;     // radius of the handler of the polygon
    
    
    ///////////COLOR PICKER////////
    //setting up the color picker
    
    float w = ofGetWidth()/6;
    float h = ofGetHeight()/6;
    float cx = w/2;
    float cy = h/2;
    
  
    img.allocate(w,h,OF_IMAGE_COLOR);
    
    for (float y=0; y<h; y++) {
        for (float x=0; x<w; x++) {
            
            float angle = atan2(y-cy,x-cy)+PI;
            float dist = ofDist(x,y,cx,cy);
            float hue = angle/TWO_PI*255;
            float sat = ofMap(dist,0,w/4,0,255,true);
            float bri = ofMap(dist,w/4,w/2,255,0,true);
            
            img.setColor(x,y,ofColor::fromHsb(hue,sat,bri));
            
        }
    }
    
    img.reloadTexture();
    
    ofPoint mousePos(mouseX,mouseY);
    
    
    colorPickerRect.set((ofGetWidth()-ofGetWidth()/6),(ofGetHeight()-ofGetHeight()/6), ofGetWidth(), ofGetHeight());
    


    
//////////////////////////////
    
    curvedVal= "Curved";
    
    
    ////////////////// fbo color picker /////////////////
    
//        pickerFbo.allocate(w, h,GL_RGB);
//    
//        pickerFbo.begin();
//        ofClear(255,255,255);
//        pickerFbo.end();
    
    
    ofSetRectMode(OF_RECTMODE_CORNER);
//    img.draw(ofGetWidth()-ofGetWidth()/6,ofGetHeight()-ofGetHeight()/6);
    
    if (colorPickerRect.inside(mouseX, mouseY)) {
        
        ofPopMatrix();
        ofSetRectMode(OF_RECTMODE_CENTER);
        ofSetColor(255,255,255,200);
        ofRect(mouseX+10, mouseY, 30, 30);
        
        
        colorPicked.set(img.getColor(mouseX-(ofGetWidth()-ofGetWidth()/6), mouseY-(ofGetHeight()-ofGetHeight()/6)));
//        colorPicked.set(colorPicked.r,colorPicked.g,colorPicked.b,curveVertices.size()*10);
        ofSetColor(colorPicked);
        
        ofRect(mouseX+10, mouseY, 20, 20);
        ofFill();
        ofSetColor(255);
        ofPushMatrix();
        
        ofDrawBitmapString(ofToString( colorPicked), 50,500);
    }

    ////////////////// end fbo color picker /////////////////

    
    //temp coordinates
    for (int i = 0; i < curveVertices.size(); i++){
        
        xt = curveVertices[i].x;
        yt = curveVertices[i].y;
        
        
    }
    
    
    ///////////////// maximilian//////////////
    
    /* some standard setup stuff*/
    
    ofEnableAlphaBlending();
    ofSetupScreen();
    ofBackground(0, 0, 0);
    ofSetVerticalSync(true);
    
    /* This is stuff you always need.*/
    
    sampleRate 			= 44100; /* Sampling Rate */
    initialBufferSize	= 512;	/* Buffer Size. you have to fill this buffer with sound*/
    
    
    /* Now you can put anything you would normally put in maximilian's 'setup' method in here. */
    
    
    beat.load(ofToDataPath("beat2.wav"));
    beat.getLength();
    
    
    ofSoundStreamSetup(2,0,this, sampleRate, initialBufferSize, 4);/* Call this last ! */
 

    randomZ=0;

}
Beispiel #21
0
void ofApp::videoSyncUpdate(){
    videoPlayer.update();
    
    
    if  (!videoPlayer.isPlaying() && bPLAY) videoPlayer.play();
    if(bPLAY == 0) videoPlayer.stop();
    
    
    
    
    // check for waiting messages
	while(client.hasWaitingMessages()){
        
		ofxOscMessage m;
		client.getNextMessage(&m);
        
		if(m.getAddress() == "/movie/frame"){
            
            syncPOSITION = m.getArgAsInt32(0);
            
        } else if (m.getAddress() == "/movie/state"){
            
			bPLAY = m.getArgAsInt32(0);
            
        } else if (m.getAddress() == "/ctrl/fs"){
            
            ofSetFullscreen(m.getArgAsInt32(0));
            
        } else if (m.getAddress() == "/ctrl/info"){
            
            bINFO = m.getArgAsInt32(0);
            
        } else if (m.getAddress() == "/movie/testConsumerPlay"){
            
            bTestPlay = m.getArgAsInt32(0);
            
        } else {
			// unrecognized message: display on the bottom of the screen
			string msg_string;
			msg_string = m.getAddress();
			msg_string += ": ";
			for(int i = 0; i < m.getNumArgs(); i++){
				// get the argument type
				msg_string += m.getArgTypeName(i);
				msg_string += ":";
				// display the argument - make sure we get the right type
				if(m.getArgType(i) == OFXOSC_TYPE_INT32){
					msg_string += ofToString(m.getArgAsInt32(i));
				}
				else if(m.getArgType(i) == OFXOSC_TYPE_FLOAT){
					msg_string += ofToString(m.getArgAsFloat(i));
				}
				else if(m.getArgType(i) == OFXOSC_TYPE_STRING){
					msg_string += m.getArgAsString(i);
				}
				else{
					msg_string += "unknown";
				}
			}
            
		}
        
	}
    
    
    int diff = abs(videoPlayer.getCurrentFrame() - syncPOSITION);
    if (diff > 10) {
        videoPlayer.setFrame(syncPOSITION);
    }
    
}
Beispiel #22
0
 void updateWindowShape() {
     ofSetWindowShape(config["screen"]["width"], config["screen"]["height"]);
     ofSetWindowPosition(config["screen"]["x"], config["screen"]["y"]);
     ofSetFullscreen(config["screen"]["fullscreen"]);
 }
Beispiel #23
0
void testApp::guiEvent(ofxUIEventArgs &e) {
    
    string name = e.widget->getName();
    int kind = e.widget->getKind();
    
    if(kind == OFX_UI_WIDGET_LABELBUTTON)
    {
        ofxUILabelButton *button = (ofxUILabelButton *) e.widget;

    }
    
    if (e.widget->getName() == "PAUSE") {
        ofxUIToggle *toggle = (ofxUIToggle *) e.widget;
        bPaused = toggle->getValue();
    }

    if (e.widget->getName() == "CLEAR REGIONS") {
        ofxUILabelButton *button = (ofxUILabelButton *) e.widget;
        
        if (button->getValue()) {
            featureFinder.clearRegions();
        }
    }
    else if(e.widget->getName() == "BLUR")
    {
        ofxUIToggle *toggle = (ofxUIToggle *) e.widget;
        featureFinder.bBlur = toggle->getValue();
    }
    else if(e.widget->getName() == "STRETCH CONTRAST")
    {
        ofxUIToggle *toggle = (ofxUIToggle *) e.widget;
        featureFinder.bStretchContrast = toggle->getValue();
    }
    else if(e.widget->getName() == "EQUALIZE HISTOGRAM")
    {
        ofxUIToggle *toggle = (ofxUIToggle *) e.widget;
        featureFinder.bEqualizeHistogram = toggle->getValue();
    }
    
    else if(e.widget->getName() == "BLUR LEVEL")
    {
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        
        featureFinder.setBlurLevel( slider->getScaledValue() );
        
    }
    else if(e.widget->getName() == "OCTAVES")
    {
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        
        featureFinder.octaves = slider->getScaledValue();
        
    }
    else if(e.widget->getName() == "MIN HESSIAN")
    {
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        
        featureFinder.hessianThreshold = slider->getScaledValue();
        
    }
    else if(e.widget->getName() == "MIN MATCHES")
    {
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        
        featureFinder.minMatchCount = slider->getScaledValue();
        
    }
    
    
    else if(e.widget->getName() == "FULLSCREEN")
    {
        ofxUIToggle *toggle = (ofxUIToggle *) e.widget;
        ofSetFullscreen(toggle->getValue());
    }
    else if (e.widget->getName() == "LOAD IMAGE") {
        
        ofxUILabelButton *button = (ofxUILabelButton *) e.widget;
        
        if (button->getValue()) {
            bPaused = true;
            
            this->openSampleImage();
        }
        
    }
    else if (e.widget->getName() == "SAVE DESCRIPTORS") {
        ofxUILabelButton *button = (ofxUILabelButton *) e.widget;
        
        if (button->getValue()) {

            ofFileDialogResult res = ofSystemSaveDialog("object.yml", "Save Object Description");
            
            if (res.bSuccess) {
                featureFinder.createAndSaveObject(res.getPath());
            }
        }
    }
    else if (e.widget->getName() == "LOAD DESCRIPTORS") {
        ofxUILabelButton *button = (ofxUILabelButton *) e.widget;
        
        if (button->getValue()) {

            ofFileDialogResult res = ofSystemLoadDialog("Load Object Description");
            
            if (res.bSuccess) {
                featureFinder.loadObject(res.getPath());
            }
            
        }
    }
    else if (e.widget->getName() == "DRAW CIRCLES") {
        ofxUIToggle *toggle = (ofxUIToggle *) e.widget;
        featureFinder.bDrawCircles = toggle->getValue();
    }
    else if (e.widget->getName() == "DETECT OBJECTS") {
        ofxUIToggle *toggle = (ofxUIToggle *) e.widget;
        bDetectObjects = toggle->getValue();
    }
    
    processRawImage();
}
Beispiel #24
0
//--------------------------------------------------------------
void ofApp::setup(){
    ofSetFullscreen(true);
    ofHideCursor();
    ofBackground(50, 50, 50);
    string line;
    fstream myFile;
    ifstream info("wordsEN.txt");
    if(!info) {
        cout << "That file doesn't exist. Try again." << endl;
    } else {
        myFile.open("wordsEN.txt");
        if (myFile.bad()) {
            cout << "Your file is empty or the wrong format." << endl;
        } else {
            while(getline(myFile, line)) {
                wordsEN.push_back(line);
            }
        }
    }
    //Closes the file
    myFile.close();
    eyex.init(); // ***COMMENT OUT ON MAC***
    cursor = EyeCursor(0,0);
    screenWidth = ofGetScreenWidth();
    screenHeight = ofGetScreenHeight();
    //Menu 0 Labels
    menu0ButtonLabels.push_back("A B C D E F G");
    menu0ButtonLabels.push_back("Suggestions");
    menu0ButtonLabels.push_back("H I J K L M N");
    menu0ButtonLabels.push_back("Delete");
    menu0ButtonLabels.push_back("Hello easyKeyboard");
    menu0ButtonLabels.push_back("Other Characters");
    menu0ButtonLabels.push_back("O P Q R S T");
    menu0ButtonLabels.push_back("Typed so far...");
    menu0ButtonLabels.push_back("U V W X Y Z");
    vectorOfLabelArrays.push_back(menu0ButtonLabels);
    //Menu 1 Labels
    menu1ButtonLabels.push_back("A");
    menu1ButtonLabels.push_back("B");
    menu1ButtonLabels.push_back("C");
    menu1ButtonLabels.push_back("D");
    menu1ButtonLabels.push_back("E");
    menu1ButtonLabels.push_back("F");
    menu1ButtonLabels.push_back("Back");
    menu1ButtonLabels.push_back("G");
    menu1ButtonLabels.push_back("Back");
    vectorOfLabelArrays.push_back(menu1ButtonLabels);
    //Menu 2 Labels
    menu2ButtonLabels.push_back("");
    menu2ButtonLabels.push_back("");
    menu2ButtonLabels.push_back("");
    menu2ButtonLabels.push_back("");
    menu2ButtonLabels.push_back("");
    menu2ButtonLabels.push_back("");
    menu2ButtonLabels.push_back("");
    menu2ButtonLabels.push_back("");
    menu2ButtonLabels.push_back("");
    vectorOfLabelArrays.push_back(menu2ButtonLabels);
    //Menu 3 Labels
    menu3ButtonLabels.push_back("H");
    menu3ButtonLabels.push_back("I");
    menu3ButtonLabels.push_back("J");
    menu3ButtonLabels.push_back("K");
    menu3ButtonLabels.push_back("L");
    menu3ButtonLabels.push_back("M");
    menu3ButtonLabels.push_back("Back");
    menu3ButtonLabels.push_back("N");
    menu3ButtonLabels.push_back("Back");
    vectorOfLabelArrays.push_back(menu3ButtonLabels);
    //Menu 4 Labels
    menu4ButtonLabels.push_back("");
    menu4ButtonLabels.push_back("");
    menu4ButtonLabels.push_back("");
    menu4ButtonLabels.push_back("");
    menu4ButtonLabels.push_back("");
    menu4ButtonLabels.push_back("");
    menu4ButtonLabels.push_back("");
    menu4ButtonLabels.push_back("");
    menu4ButtonLabels.push_back("");
    vectorOfLabelArrays.push_back(menu4ButtonLabels);
    //Menu 5 Labels - Contains Nothing
    vectorOfLabelArrays.push_back(menu5ButtonLabels);
    //Menu 6 Labels
    menu6ButtonLabels.push_back("");
    menu6ButtonLabels.push_back("");
    menu6ButtonLabels.push_back("");
    menu6ButtonLabels.push_back("");
    menu6ButtonLabels.push_back("");
    menu6ButtonLabels.push_back("");
    menu6ButtonLabels.push_back("");
    menu6ButtonLabels.push_back("");
    menu6ButtonLabels.push_back("");
    vectorOfLabelArrays.push_back(menu6ButtonLabels);
    //Menu 7 Labels
    menu7ButtonLabels.push_back("O");
    menu7ButtonLabels.push_back("P");
    menu7ButtonLabels.push_back("Q");
    menu7ButtonLabels.push_back("R");
    menu7ButtonLabels.push_back("S");
    menu7ButtonLabels.push_back("T");
    menu7ButtonLabels.push_back("Back");
    menu7ButtonLabels.push_back("Back");
    menu7ButtonLabels.push_back("Back");
    vectorOfLabelArrays.push_back(menu7ButtonLabels);
    //Menu 8 Labels
    menu8ButtonLabels.push_back("");
    menu8ButtonLabels.push_back("");
    menu8ButtonLabels.push_back("");
    menu8ButtonLabels.push_back("");
    menu8ButtonLabels.push_back("");
    menu8ButtonLabels.push_back("");
    menu8ButtonLabels.push_back("");
    menu8ButtonLabels.push_back("");
    menu8ButtonLabels.push_back("");
    vectorOfLabelArrays.push_back(menu8ButtonLabels);
    //Menu 9 Labels
    menu9ButtonLabels.push_back("U");
    menu9ButtonLabels.push_back("V");
    menu9ButtonLabels.push_back("W");
    menu9ButtonLabels.push_back("X");
    menu9ButtonLabels.push_back("Y");
    menu9ButtonLabels.push_back("Z");
    menu9ButtonLabels.push_back("Back");
    menu9ButtonLabels.push_back("Back");
    menu9ButtonLabels.push_back("Back");
    vectorOfLabelArrays.push_back(menu9ButtonLabels);
    wordToType = "";
    //Row 1
    button = EyeButton(10, 10, (screenWidth-60)/3, (screenHeight-60)/3, "A B C D E F G", false);
    vectorOfButtons.push_back(button);
    button = EyeButton(10+(screenWidth/3), 10, (screenWidth-60)/3, (screenHeight-60)/3, "Suggestions", false);
    vectorOfButtons.push_back(button);
    button = EyeButton(10+((screenWidth/3)*2), 10, (screenWidth-60)/3, (screenHeight-60)/3, "H I J K L M N", false);
    vectorOfButtons.push_back(button);
    //Row 2
    button = EyeButton(10, 10+(screenHeight/3), (screenWidth-60)/3, (screenHeight-60)/3, "Delete", false);
    vectorOfButtons.push_back(button);
    button = EyeButton(10+(screenWidth/3), 10+(screenHeight/3), (screenWidth-60)/3, (screenHeight-60)/3, "Hello easyKeyboard", false);
    vectorOfButtons.push_back(button);
    button = EyeButton(10+((screenWidth/3)*2), 10+(screenHeight/3), (screenWidth-60)/3, (screenHeight-60)/3, "Other Characters", false);
    vectorOfButtons.push_back(button);
    //Row 3
    button = EyeButton(10, 10+((screenHeight/3)*2), (screenWidth-60)/3, (screenHeight-60)/3, "O P Q R S T", false);
    vectorOfButtons.push_back(button);
    button = EyeButton(10+(screenWidth/3), 10+((screenHeight/3)*2), (screenWidth-60)/3, (screenHeight-60)/3, "Typed so far...", false);
    vectorOfButtons.push_back(button);
    button = EyeButton(10+((screenWidth/3)*2), 10+((screenHeight/3)*2), (screenWidth-60)/3, (screenHeight-60)/3, "U V W X Y Z", false);
    vectorOfButtons.push_back(button);
}
Beispiel #25
0
void testApp::guiEvent(ofxUIEventArgs &e){
	string name = e.widget->getName();
	int kind = e.widget->getKind();
    
    if(e.getName() == "FULLSCREEN"){
        ofxUIToggle *toggle = (ofxUIToggle *) e.widget;
        ofSetFullscreen(toggle->getValue());
        
        
        /*----------------- PARTICLES -----------------*/
	}else if(name == "PARTICLE GUI MODE"){
        ofxUIToggle *toggle = (ofxUIToggle *) e.widget;
        particleGUImode = toggle->getValue();
        
	}else if(name == "EXPANSION"){
		ofxUISlider *slider = (ofxUISlider *) e.widget;
		expansion = slider->getScaledValue();
        
    }else if(name == "ROTATION"){
		ofxUISlider *slider = (ofxUISlider *) e.widget;
		rotation = slider->getScaledValue();
        
    }else if(name == "SHAPE SIZE"){
		ofxUISlider *slider = (ofxUISlider *) e.widget;
		shapeSize = slider->getScaledValue();
        
    }else if(name == "VERTICES"){
		ofxUISlider *slider = (ofxUISlider *) e.widget;
		nVertices = slider->getScaledValue();
        
    }else if(name == "PARTICLE SIZE"){
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        particleSize = slider->getScaledValue();
        
    }else if(name == "SHAPES"){
        ofxUIRadio *radio = (ofxUIRadio *) e.widget;
        cout << radio->getName() << " value: " << radio->getValue() << " active name: " << radio->getActiveName() << endl;
        selectedShape = radio->getActiveName();
        
    }else if(name == "MODES"){
        ofxUIRadio *radio = (ofxUIRadio *) e.widget;
        cout << radio->getName() << " value: " << radio->getValue() << " active name: " << radio->getActiveName() << endl;
        selectedMode = radio->getActiveName();
        
        
        /*---------------- BACKGROUND -----------------*/

	}else if(name == "TILE GUI MODE"){
        ofxUIToggle *toggle = (ofxUIToggle *) e.widget;
        tileGUImode = toggle->getValue();
        
    }else if(name == "TILE MODES"){
        ofxUIRadio *radio = (ofxUIRadio *) e.widget;
        cout << radio->getName() << " value: " << radio->getValue() << " active name: " << radio->getActiveName() << endl;
        selectedTileMode = radio->getActiveName();
        
    }else if(name == "HUE"){
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        hue = slider->getScaledValue();

    }else if(name == "VIDEO"){
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        videoAlpha = slider->getScaledValue();
        
    }else if(name == "THRESHOLD"){
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        threshold = slider->getScaledValue();
    }
}
void testApp::setup()
{
    ofHideCursor();
    ofBackground(0, 0, 0);
    
    generateCircularSpiral();
    loadImagesandXMLData();
    
    ofSetLogLevel(OF_LOG_VERBOSE);
    ofSetFrameRate(200);
    
#ifdef DEBUGMODE
    camera.setDistance(200);
    camera.setFarClip(1000000);
#else
    
    camera.setFov(40);
    
    /// Setting a very large far clip
    camera.setFarClip(10000000);
    cameraindex=combinedImageObjects.size()-1;
    
    camera.setPosition(cameraStartPosition);
    animationMode=false;
    isstartingAnimationActive=true;
    
    startoverShotCameraAnimation=false;
    
    overshotCameraStartingPosition=ofVec3f(0,0,0);
    startAnimationCounter=0;
    pushWigglePositions();
    currentwiggleindex=0;
    wiggleAnimationCounter=0;
    startInstallation=false;
    
#endif
    
    ofEnableAlphaBlending();    
    ofSetBackgroundAuto(true);    
    numberofImages=combinedImageObjects.size()-1;
    
#ifdef USEWII
    
    // For debug purposes
    //cout << "listening for osc messages on port " << PORT << "\n";
    receiver.setup( PORT );
    
    accel_x=accel_y=accel_z;
    
    Message="";
     accel=0;
    
#ifdef ADJUSTTIMEGAP
    minAngularVelocity=10000;
    maxAngularVelocity=(-1000);
    minAccel=1000;maxAccel=-1000;
#endif
    
    State="";
    fonttodisplayWiimoteValues.loadFont("Inconsolata.otf", 20);
    
#endif
    
    BluementhalMp3.loadSound("Blumenthal.mp3");
    BluementhalMp3.setVolume(1.0f);
    
    timeGap=6000; // This is the default timeGap .Can be easily changed.
    
    ofSetFullscreen(true);
    currentVolume=1;
    fadeAudio=false;
    
    startingMovieFinished=false;
    startingMovie.loadMovie("Intro_new.mov", OF_QTKIT_DECODE_TEXTURE_ONLY);
    startingMovie.setLoopState(OF_LOOP_NONE);
    
    cout<<startingMovie.getDuration()<<endl;
    cout<<startingMovie.getWidth()<<"    "<<startingMovie.getHeight();
    
    previewText.loadFont("asyouwish.ttf",42);
    ending=false;
    
}
Beispiel #27
0
//--------------------------------------------------------------
void testApp::keyPressed (int key) {
	switch (key) {
		case ' ':
			bThreshWithOpenCV = !bThreshWithOpenCV;
		break;
		
		case'p':
			bDrawPointCloud = !bDrawPointCloud;
			break;
	
		case '>':
		case '.':
			farThreshold ++;
			if (farThreshold > 255) farThreshold = 255;
			break;
			
		case '<':		
		case ',':		
			farThreshold --;
			if (farThreshold < 0) farThreshold = 0;
			break;
			
		case '+':
		case '=':
			nearThreshold ++;
			if (nearThreshold > 255) nearThreshold = 255;
			break;
			
		case '-':		
			nearThreshold --;
			if (nearThreshold < 0) nearThreshold = 0;
			break;
			
		case 'w':
			kinect.enableDepthNearValueWhite(!kinect.isDepthNearValueWhite());
			break;
			
		case 'o':
			kinect.setCameraTiltAngle(camAngle);	// go back to prev tilt
			kinect.open();
			break;
			
		case OF_KEY_UP:
			camAngle++;
			if(camAngle>30) camAngle=30;
			kinect.setCameraTiltAngle(camAngle);
			break;

		case OF_KEY_DOWN:
			camAngle--;
			if(camAngle<-30) camAngle=-30;
			kinect.setCameraTiltAngle(camAngle);
			break;
		case 'f':			
			ofSetFullscreen(true);
		break;
		case 'F':			
			ofSetFullscreen(false);
		break;
		case 'c':			
			ofHideCursor();
		break;
		case 'C':			
			ofShowCursor();
		break;
		
		
		

	}			
}
//--------------------------------------------------------------
void testApp::keyReleased  (int key) {
    int idxSndStop, idxVidStop;

    idxSndStop = -1;
    idxVidStop = -1;

    fprintf(stdout, "keyReleased %c, code %d\n", key, (int) key);
    switch (key) {
    case 113:
        printf("Obj 1\n");
        idxSndStop = 0;
        idxVidStop = 0;
        break;
    case 32:
        printf("Obj 2\n");
        idxSndStop = 1;
        idxVidStop = 1;
        break;
    case 359:
        printf("Obj 3\n");
        idxSndStop = 2;
        break;
    case 122:
        printf("Obj 4\n");
        idxSndStop = 3;
        //idxVidStop = 3;
        break;
    //case 102:
    //printf("Obj 5\n");
    //idxSndStop = 4;
    //break;
    case 103:
        printf("Obj 6\n");
        idxSndStop = 5;
        idxVidStop = 2;
        break;
    case 357:
        printf("Obj 7\n");
        idxSndStop = 6;
        idxVidStop = 3;
        break;
    case 102:
        printf("Obj 8\n");
        idxSndStop = 7;
        break;
    case 356:
        printf("Obj 9\n");
        idxSndStop = 8;
        break;
    }

    // Arrêt Sons ?
    printf("Arret sons\n");
    if (idxSndStop>=0) {
        if (sounds[idxSndStop].getIsPlaying()) {
            sounds[idxSndStop].stop();
        }
    }

    // Lecture Vidéo ?
    printf("Arret video\n");
    if (idxVidStop>=0) {
        // Arrêt vidéo en cours
        if (idxVidPlaying==idxVidStop) {
            vids[idxVidStop].stop();
            vids[idxVidStop].setPosition(0.0);
            idxVidPlaying = -1; // Reset le statut des vidéos
            fadeLevel = 0;
        }
    }

    // M pour fullscreen
    if (key=='m') {
        bFullScreen = !bFullScreen;
        ofSetFullscreen(bFullScreen);
    }
}
void captureApp::update(){
	panel.update();
		
	// this is where an event/callback-based
	// control panel would be really helpful!
	int curWavelength = panel.getValueI("wavelength");
	if(curWavelength != lastWavelength) {
		threePhase.setWavelength(curWavelength);
		threePhase.generate();
		twoPlusOne.setWavelength(curWavelength);
		twoPlusOne.generate();
	}
	lastWavelength = curWavelength;

	int minBrightness = panel.getValueI("minBrightness");
	if (minBrightness != lastMinBrightness) {
		threePhase.setMinBrightness(minBrightness);
		threePhase.generate();
		twoPlusOne.setMinBrightness(minBrightness);
		twoPlusOne.generate();
	}
	lastMinBrightness = minBrightness;

	int curOrientation = panel.getValueI("orientation");
	if(curOrientation != lastOrientation) {
		phaseOrientation orientation = curOrientation == 0 ? PHASE_VERTICAL : PHASE_HORIZONTAL;
		threePhase.setOrientation(orientation);
		threePhase.generate();
		grayCode.setOrientation(orientation);
		grayCode.generate();
		gradient.setOrientation(orientation);
		gradient.generate();
		twoPlusOne.setOrientation(orientation);
		twoPlusOne.generate();
	}
	lastOrientation = curOrientation;

	int curSubdivisions = panel.getValueI("subdivisions");
	if(curSubdivisions != lastSubdivisions) {
		grayCode.setSubdivisions(curSubdivisions);
		grayCode.generate();
	}
	lastSubdivisions = curSubdivisions;

	threePhase.setReverse(panel.getValueB("reverse"));
	twoPlusOne.setReverse(panel.getValueB("reverse"));
	grayCode.setReverse(panel.getValueB("reverse"));

	int curFullscreen = panel.getValueB("fullscreen");
	if(curFullscreen !=	lastFullscreen)
		ofSetFullscreen(curFullscreen);
	lastFullscreen = curFullscreen;

	int curPatternType = panel.getValueI("patternType");
	if(curPatternType != lastPatternType) {
		switch(curPatternType) {
			case 0: curGenerator = &threePhase; break;
			case 1: curGenerator = &grayCode; break;
			case 2: curGenerator = &gradient; break;
			case 3: curGenerator = &twoPlusOne; break;
		}
	}
	lastPatternType = curPatternType;

	handleCamera();

	if(panel.getValueB("projectorLut")) {
		curGenerator->applyLut(ofToDataPath("projector-lut.csv"));
		panel.setValueB("projectorLut", false);
	}
}
Beispiel #30
0
void ofApp::fullscreenToggle(bool &control){
    ofSetFullscreen(control);
}