Beispiel #1
0
void MindPaint::setup(){
    smallFont.loadFont("Arial.ttf", 10);
    // ofSetBackgroundAuto(false); // disable auto clear, there's a bug there
    ofBackground(230, 220, 220, 255);
    ofEnableAlphaBlending();
    ofEnableSmoothing();
    ofSetFrameRate(FPS);
    //useMouse = false;
    tgState = NONE;
    appState = SELECT_BG;
    tg.addEventListener(this);
    brush = new EllipseBrush();
    screenshotCount = 0;
    back = RYBWheel::pick(backRybAngle);
    back = ofFloatColor(250, 250, 230);
    mood = RYBWheel::pick(backRybAngle - 0.5);
    mood.a = 0.4;
    attBonus = 0;
    attScore = 0;
    medBonus = 0;
    medScore = 0;
    score = 0;
    //setMoverController(new EvadeController());
    setMoverController(new SpiralController());
    tgEmu.setup();
    Buffer::init(buffer, ofColor(220,220,220,255));
}
//--------------------------------------------------------------
void ofApp::setup()
{
    for (int i = 0; i < ArrayCount(population); i++)
    {
        population[i] = DNA();
    }
	myFont.loadFont("LiberationMono-Regular.ttf", 12);
}
Beispiel #3
0
	// ---------------------------------------------------------------------------------------
	//
	void setup()
	{
		ofSetFrameRate(60);
		ofSetVerticalSync(true);
		ofBackground(0);
		
		ofxCL::Context::listDevices();
		
		ocl.setup( 0, true );
				
		noiseProgram.load("NoiseKernel.cl");
		
		methodNames.push_back( "GradientNoiseImage2d" );
		methodNames.push_back( "RidgedMultiFractalImage2d" );
		methodNames.push_back( "MonoFractalImage2d" );
		methodNames.push_back( "TurbulenceImage2d" );
		
		Resolution.addListener(this, &ofApp::resolutionChanged);
		
		gui.setup("Settings", "Settings.xml");

		gui.add( methodIndex.set( "methodIndex", 3, 0, methodNames.size()-1 ) );
		
		gui.add( Resolution.set( "Resolution", 1024, 2, 4096 ) );
		
		gui.add( Scale.set( "Scale", 1.0, 0.0, 1.0 ) );
		gui.add( ScaleMultiplier.set( "Scale Multiplier", 3.0, 0.001, 100.0f ) );
	
		gui.add( Lacunarity.set( "Lacunarity", 2.02f, 0.001f, 10.0f ) );
		gui.add( Increment.set( "Increment", 1.0f, -1.0, 1.0f ) );
		gui.add( Octaves.set( "Octaves", 3.3f, 0.001, 20.0f ) );
		gui.add( Amplitude.set( "Amplitude", 1.0f, 0.001, 10.0f ) );

		gui.add( AutoMove.set( "AutoMove", true ) );
		gui.add( AutoMoveMagnitude.set( "AutoMoveMagnitude", 0.5f, 0.001, 10.0f ) );
		
		drawGui = true;
				
		fontSmall.loadFont("DIN.otf", 8 );
	}
Beispiel #4
0
	LogOverlay()
	:maxSize(10) {
		font.loadFont(OF_TTF_MONO, 8, false);
	}
Beispiel #5
0
void setupResources() {
	if(!ready) {
		font.loadFont("uni05_53.ttf", 6, false);
		ready = true;
	}
}
Beispiel #6
0
void runExperiment(void) {

	//When checking the timing of things, make sure to try it in full screen mode as well, because
	//timing errors happen a lot more when experiments is windowed rather than full screen.
	Disp.setFullscreen(false);

	if (Disp.isFullscreen()) {
		//If going to full screen, sometimes its good to wait a little while for things to settle before drawing stuff.
		Clock.sleep(CX_Seconds(1));
	}

	Log.levelForFile(CX_Logger::Level::LOG_ALL, "Last run.txt");
	Log.level(CX_Logger::Level::LOG_ALL, "CX_SlidePresenter");

	Log.notice() << "Frame period: " << Disp.getFramePeriod() << " (" << Disp.getFramePeriodStandardDeviation() << ")";
	
	Input.setup(true, false); //Use keyboard, not mouse.

	bigFont.loadFont(OF_TTF_SANS, 26);
	smallFont.loadFont(OF_TTF_SANS, 12);

	stringstream s;
	s << "Press '" << targetKey << "' for targets and '" << nonTargetKey << "' for non-targets";
	keyReminderInstructions = s.str();

	generateTrials();

	//In this example, more of the configuration settings for the slide presenter are used.
	//See the documentation for CX_SlidePresenter::Configuration for more information.
	CX_SlidePresenter::Configuration config;
	config.display = &Disp;
	config.swappingMode = CX_SlidePresenter::SwappingMode::SINGLE_CORE_BLOCKING_SWAPS;
	config.finalSlideCallback = &finalSlideFunction;
	config.deallocateCompletedSlides = useFramebuffersForStimuli; //Only deallocate if using framebuffers

	config.preSwapCPUHoggingDuration = CX_Millis(3);
	config.useFenceSync = true;
	config.waitUntilFenceSyncComplete = false;

	SlidePresenter.setup(config);

	for (int i = 3; i > 0; i--) {
		if (useFramebuffersForStimuli) {
			//Note that regardless of whether drawing functions are used later, you can use the standard framebuffer approach as well.
			//To be clear: You can mix and match framebuffers with drawing functions in a single presentation of slides.
			SlidePresenter.beginDrawingNextSlide(1000, "fixation");
			drawFixationSlide(i);
		} else {
			//std::bind sort of "bakes in" the value of i to drawFixationSlide, and the resulting function
			//takes no arguments, so it can be given to the slide presenter as a drawing function.
			SlidePresenter.appendSlideFunction( std::bind(drawFixationSlide, i), 1000, "fixation" );
		}
	}

	for (unsigned int i = 0; i <= nBack; i++) {
		//Depending on whether using the framebuffer approach or the drawing function approach, call a different setup function.
		if (useFramebuffersForStimuli) {
			drawStimuliToFramebuffers(SlidePresenter, i);
		} else {
			appendDrawingFunctions(SlidePresenter, i);
		}
	}
	trialNumber = nBack;

	Log.flush();

	SlidePresenter.startSlidePresentation();

	while (SlidePresenter.isPresentingSlides()) {
		SlidePresenter.update();
		Input.pollEvents();
	}

	df.printToFile("N-Back output.txt");

	Log.notice() << "Slide presentation information: " << endl << SlidePresenter.printLastPresentationInformation();


	vector<CX_SlidePresenter::Slide>& slides = SlidePresenter.getSlides();
	CX_Millis startMinusCopySum = 0;
	for (int i = 0; i < slides.size(); i++) {
		startMinusCopySum += slides[i].actual.startTime - slides[i].copyToBackBufferCompleteTime;
	}
	Log.notice() << "Average difference between back buffer copy completion and slide start: " << startMinusCopySum / slides.size();
	
	if (Disp.isFullscreen()) {
		Disp.setFullscreen(false);
	}

	if (Disp.isAutomaticallySwapping()) {
		Disp.setAutomaticSwapping(false);
	}

	Disp.beginDrawingToBackBuffer();
	ofBackground(backgroundColor);
	Draw::centeredString(Disp.getCenter(), "Experiment complete!\nPress any key to exit.", bigFont);
	Disp.endDrawingToBackBuffer();
	Disp.swapBuffers();

	Log.flush();

	Input.Keyboard.waitForKeypress(-1);
}
void kinectCapture::setup(bool _bTwoKinects) {
    
    bTwoKinects = _bTwoKinects;
    
    bMovementDetection = true;
    
    // SETUP KINECT ONE
    
    fKin1Angle = 0;
    
    bool success = false;
    int counter = 0;
    
    kinect1.init(false, false);
    kinect1.open(0);
    
    if(bTwoKinects) {
        fKin2Angle = 0;
        
        kinect2.init(false, false);
        kinect2.open(1);
    
    }
    
    kinect1.update();
    kinect1.setCameraTiltAngle(0);
    kinect1.close();
    
    if(bTwoKinects) {
        kinect2.update();
        kinect2.setCameraTiltAngle(0);
        kinect2.close();
    }
    
    kinect1.init(false, false);
    success = kinect1.open(0);
    
    while (!success && counter < 10) {
        cout << "Problems found in connecting with Kinect 1. Trying again!" << endl;
        kinect1.close();
        kinect1.init(false, false);
        success = kinect1.open(0);
        counter++;
    }
    
    kinect1.setCameraTiltAngle(fKin1Angle);
    cvGrayKin1.allocate(640, 480);
    cvGrayKin1Prev.allocate(640,480);
    
    bKin1Refreshed = false;
    
    //IF USING TWO KINECTS, SETUP KINECT TWO
	
    if(bTwoKinects) {
    
        fKin2Angle = 0;
        
        success = false;
        counter = 0;
        
        kinect2.init(false, false);
        success = kinect2.open(1);
        
        kinect2.update();
        kinect2.close();
        
        kinect2.init(false, false);
        
        success = kinect2.open(1);
        
        while (!success && counter < 10) {
            cout << "Problems found in connecting with Kinect 2. Trying again!" << endl;
            kinect2.close();
            kinect2.init(false, false);
            success = kinect2.open(1);
            counter++;
        }
        
        kinect2.setCameraTiltAngle(fKin2Angle);
        cvGrayKin2.allocate(640, 480);
        cvGrayKin2Prev.allocate(640, 480);
        
        bKinectsStarted = false;
        bKin2Refreshed = false;
        
        vector<ofPoint> allocator(KIN_H * KIN_OUTPUT_W, ofPoint(0,0,0));
        
        for (int i = 0; i < iBufferSize; i++) {
            pointCloudBuffer.push_back(allocator);
        }
        
        allocator.clear();
        
    }
    
    else {
        
        vector<ofPoint> allocator(KIN_H * KIN_W, ofPoint(0,0,0));
        
        for (int i = 0; i < iBufferSize; i++) {
            pointCloudBuffer.push_back(allocator);
        }
        
        allocator.clear();
        
    }
    
    iNearThreshold  = 0;
    iFarThreshold   = 255;
    iMinBlobSize    = 20;
    iMaxBlobSize    = 20000;
    iMaxNumBlobs    = 10;
        
    font.loadFont("Ruda-Regular.ttf", 32); 
}