void ofInit(){
	if(initialized()) return;
	initialized() = true;

#if defined(TARGET_ANDROID) || defined(TARGET_OF_IOS)
    // manage own exit
#else
	atexit(ofExitCallback);
#endif

#if defined(TARGET_LINUX) || defined(TARGET_OSX)
	// see http://www.gnu.org/software/libc/manual/html_node/Termination-Signals.html#Termination-Signals
	signal(SIGTERM, &ofSignalHandler);
	signal(SIGQUIT, &ofSignalHandler);
	signal(SIGINT,  &ofSignalHandler);

	signal(SIGHUP,  &ofSignalHandler); // not much to be done here

	// http://www.gnu.org/software/libc/manual/html_node/Program-Error-Signals.html#Program-Error-Signals
	signal(SIGABRT, &ofSignalHandler);  // abort signal
#endif

	#ifdef WIN32_HIGH_RES_TIMING
		timeBeginPeriod(1);		// ! experimental, sets high res time
								// you need to call timeEndPeriod.
								// if you quit the app other than "esc"
								// (ie, close the console, kill the process, etc)
								// at exit wont get called, and the time will
								// remain high res, that could mess things
								// up on your system.
								// info here:http://www.geisswerks.com/ryan/FAQS/timing.html
	#endif

#ifdef TARGET_LINUX
	if(std::locale().name() == "C"){
		try{
			std::locale::global(std::locale("C.UTF-8"));
		}catch(...){
			if(ofToLower(std::locale("").name()).find("utf-8")==std::string::npos){
				ofLogWarning("ofInit") << "Couldn't set UTF-8 locale, string manipulation functions\n"
						"won't work correctly for non ansi characters unless you specify a UTF-8 locale\n"
						"manually using std::locale::global(std::locale(\"locale\"))\n"
						"available locales can be queried with 'locale -a' in a terminal.";
			}
		}
	}
#endif

	
	ofSeedRandom();
	ofResetElapsedTimeCounter();
	of::priv::setWorkingDirectoryToDefault();
}
Beispiel #2
0
Ball::Ball(){
    ofSeedRandom();
    
    position.x = ofGetWindowWidth()/4;
    position.y = ofGetWindowHeight()/2;
    
    velocity.x = ofRandom(0.0,4.0);
    velocity.y = ofRandom(-5.0,-20.0);
    
    ofSetRectMode( OF_RECTMODE_CENTER );
    
    gravity = 0.8;
}
Beispiel #3
0
//--------------------------------------------------------------
void testApp::keyPressed  (int key){ 
	
	switch( key )
	{
		// panic button
		case '!':
			lights.clear( true );
			break;
		case 'p':
			lights.pulseAll( 1 );
			break;
		case 'W':
		{
			ofxXmlSettings data;
			lights.save( data );
			data.saveFile( "settings.xml" );
			data.addValue("ontime_ms", ontime_ms);
			break;
		}
		case OF_KEY_LEFT:
		case '[':
			current_anim = anim_switcher.prevAnim();
			lights.clear();
			break;
		case OF_KEY_RIGHT:
		case ']':
			current_anim = anim_switcher.nextAnim();
			lights.clear();
			break;
		
		case 'b':
			lights.increaseSmallLightBrightnessFactor();
			break;
		case 'B':
			lights.decreaseSmallLightBrightnessFactor();
			break;
		
		case 'R':
			ofSeedRandom( 12345 );
			break;
		case 'r':
			StateAnimIdle::should_reset_random = true;
			
			break;
			
		default:
			break;
			
	}
	current_anim->keyPressed( key );
}
void testApp::setup() {
	ofSetWindowTitle(appName);
	ofSetVerticalSync(true);
	ofSetLogLevel(OF_LOG_VERBOSE);

	ofSeedRandom(0);
	PhotoManager::setup("~/Desktop/3rdiStream/resized/");
	
	setupOsc();

	ofxVec2f size = getMaxSize();
	surface.setup(size, ofxVec2f(60, 100));
	wall.setup(surface);
}
Beispiel #5
0
//--------------------------------------------------------------
void ofApp::setup(){
    
    ofSetFrameRate(60);
    ofSetCircleResolution(100);
    ofEnableSmoothing();
    ofEnableAlphaBlending();
    ofBackground(255);
    
    ofSeedRandom(9);
    
    for (int i = 0; i<NUM_MOVER; i++) {
        movers[i].setup(ofRandom(1,4), ofRandom(ofGetWidth()), 0);
    }
}
EmergenceLog::EmergenceLog(string logDir)
{
    
    _baseDir = "";
    //_baseDir = "./logs/";
    _logDir = logDir;
    _fileName = "EmergenceLog.txt";
    _imagesDir = "images/";

    mkdir( ofToDataPath(_baseDir).c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
    mkdir( ofToDataPath(getLogDirPath()).c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
    mkdir( ofToDataPath(getImagesDirPath()).c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
    ofSeedRandom();
    
}
void PushDown::reconstruct(){
    
    ofVec3f _s = globalParams->getVec3f("stage_size_cm").get();
    
    box.setParent(world->origin);
    box.set(_s.x, _s.x*0.5, _s.z, 4,2,4);
    box.setScale(1,1,1);
    box.setGlobalPosition( ofVec3f(0, -box.getHeight()/2, box.getDepth()/2) );
    
    origin.set(box.getGlobalPosition());
    
    ofSeedRandom(seed.get());
    mainNode.setupFromBoundingBox(box.getWidth(), box.getHeight(), box.getDepth(), numCells, true,false,true);
    mainNode.setParent(box);
}
Beispiel #8
0
//--------------------------------------------------------------
vector <ofPoint> ofApp::generateRandomPoints(int count, int seed, ofRectangle bounds) {
    vector <ofPoint> points;
    ofSeedRandom(seed);
    
    for(int i=0; i<count; i++) {
        ofPoint newPoint = ofPoint(
            ofRandom(bounds.x, bounds.width),
            ofRandom(bounds.y, bounds.height)
        );
        
        points.push_back(newPoint);
    }
    
    return points;
}
Beispiel #9
0
//--------------------------------------------------------------
void testApp::draw(){
	ofEnableAlphaBlending();
	ofSetColor(255,255,255, 100);
	ofSeedRandom(0); // always pick the same random numbers.

	for (int i = 0; i < mouseX*3; i++){
		float x = ofNoise(ofGetElapsedTimef()*0.2, i*0.3)*ofGetWidth();
		float y = ofNoise(-ofGetElapsedTimef()*0.2, i*0.3)*ofGetHeight();
		ofColor col = getColorForPixel( ofMap(x,0,ofGetWidth(), 0, colorScheme.width),
						ofMap(y,0,ofGetHeight(), 0, colorScheme.height));
		col.a = 85;	// set some alpha. 
		ofSetColor(col);
		ofCircle(x,y,ofRandom(4,40));
	}
}
//--------------------------------------
void ofRunApp(ofPtr<ofBaseApp> OFSA){

	OFSAptr = OFSA;
	if(OFSAptr){
		OFSAptr->mouseX = 0;
		OFSAptr->mouseY = 0;
	}
    
#ifndef TARGET_ANDROID
//    #ifndef OF_SCREEN_SAVER
        atexit(ofExitCallback);
//    #endif
#endif

	#ifdef WIN32_HIGH_RES_TIMING
		timeBeginPeriod(1);		// ! experimental, sets high res time
								// you need to call timeEndPeriod.
								// if you quit the app other than "esc"
								// (ie, close the console, kill the process, etc)
								// at exit wont get called, and the time will
								// remain high res, that could mess things
								// up on your system.
								// info here:http://www.geisswerks.com/ryan/FAQS/timing.html
	#endif

	window->initializeWindow();

	ofSeedRandom();
	ofResetElapsedTimeCounter();

    ofAddListener(ofEvents().setup,OFSA.get(),&ofBaseApp::setup,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().update,OFSA.get(),&ofBaseApp::update,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().draw,OFSA.get(),&ofBaseApp::draw,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().exit,OFSA.get(),&ofBaseApp::exit,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().keyPressed,OFSA.get(),&ofBaseApp::keyPressed,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().keyReleased,OFSA.get(),&ofBaseApp::keyReleased,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().mouseMoved,OFSA.get(),&ofBaseApp::mouseMoved,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().mouseDragged,OFSA.get(),&ofBaseApp::mouseDragged,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().mousePressed,OFSA.get(),&ofBaseApp::mousePressed,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().mouseReleased,OFSA.get(),&ofBaseApp::mouseReleased,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().windowEntered,OFSA.get(),&ofBaseApp::windowEntry,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().windowResized,OFSA.get(),&ofBaseApp::windowResized,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().messageEvent,OFSA.get(),&ofBaseApp::messageReceived,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().fileDragEvent,OFSA.get(),&ofBaseApp::dragged,OF_EVENT_ORDER_APP);
    
	window->runAppViaInfiniteLoop(OFSAptr.get());

}
void ofxRemoteUIServer::setup(int port_, float updateInterval_){

	if(port_ == -1){ //if no port specified, pick a random one, but only the very first time we get launched!
		portIsSet = false;
		ofxXmlSettings s;
		bool exists = s.loadFile(OFXREMOTEUI_SETTINGS_FILENAME);
		bool portNeedsToBePicked = false;
		if (exists){
			if( s.getNumTags(OFXREMOTEUI_XML_PORT) > 0 ){
				port_ = s.getValue(OFXREMOTEUI_XML_PORT, 10000);
			}else{
				portNeedsToBePicked = true;
			}
		}else{
			portNeedsToBePicked = true;
		}
		if(portNeedsToBePicked){
#ifdef OF_AVAILABLE
			ofSeedRandom();
			port_ = ofRandom(5000, 60000);
#else
			srand (time(NULL));
			port_ = 5000 + rand()%55000;
#endif
			ofxXmlSettings s2;
			s2.loadFile(OFXREMOTEUI_SETTINGS_FILENAME);
			s2.setValue(OFXREMOTEUI_XML_PORT, port_, 0);
			s2.saveFile();
		}
	}else{
		portIsSet = true;
	}
	params.clear();
	updateInterval = updateInterval_;
	waitingForReply = false;
	avgTimeSinceLastReply = timeSinceLastReply = timeCounter = 0.0f;
	port = port_;
	cout << "ofxRemoteUIServer listening at port " << port << " ... " << endl;
	oscReceiver.setup(port);
#ifdef OF_AVAILABLE
	ofAddListener(ofEvents().exit, this, &ofxRemoteUIServer::_appExited);
	ofAddListener(ofEvents().keyPressed, this, &ofxRemoteUIServer::_keyPressed);
	ofAddListener(ofEvents().update, this, &ofxRemoteUIServer::_update);
	if(drawNotifications){
		ofAddListener(ofEvents().draw, this, &ofxRemoteUIServer::_draw);
	}
#endif
}
Beispiel #12
0
//--------------------------------------------------------------
void testApp::setup(){
	// init logs
	ofSetLogLevel(OF_LOG_VERBOSE);
	ofLogVerbose() << "setup started";
	
	tripno.mass = 1.0;
	tripno.velocity = 0;
	tripno.position = ofPoint(0, 0);

	// init scene objects
	timeElapsed = 0;
	currentIndex = 1;

	minFreqLog = 100;
	maxFreqLog = 0;
	maxSignal = 0;

    for (int i = 0; i < SEGMENTS_STORED; ++i) {
        ceilHeights[i] = floorHeights[i] = 0;
		earthline[i] = skyline[i] = ofRectangle(0,0,0,0);
    }

	gameField = paddingTop = paddingBottom = 
		ofRectangle(0,0,0,0);

	viewPort = ofGetCurrentViewport();

	// init vertical sync and some graphics
	ofSetVerticalSync(true);
	ofSetCircleResolution(6);
	ofBackground(47, 52, 64);

	// init audio
	soundStream.listDevices();

	fft = ofxFft::create(AUDIO_BUFFER_SIZE, OF_FFT_WINDOW_RECTANGULAR);

	soundStream.setup(this, 0, 2, SAMPLE_RATE, AUDIO_BUFFER_SIZE, 4);
	fftOutput = new float[fft->getBinSize()];

	// seed random
	ofSeedRandom();

	//update config
	readConfig();

	ofLogVerbose() << "setup finished";
}
Beispiel #13
0
void ofxRunTouchApp(ofxTouchApp * OFSA){

	OFSAptr = OFSA;  //as ofSimpleApp
	OFXTAptr = OFSA; //as ofxTouchApp (inherits from ofSimpleApp )
	OFSAptr->mouseX = 0;
	OFSAptr->mouseY = 0;
	
	atexit(ofExitCallback);

	#ifdef WIN32_HIGH_RES_TIMING
		timeBeginPeriod(1);		// ! experimental, sets high res time
								// you need to call timeEndPeriod.
								// if you quit the app other than "esc"
								// (ie, close the console, kill the process, etc)
								// at exit wont get called, and the time will
								// remain high res, that could mess things
								// up on your system.
								// info here:http://www.geisswerks.com/ryan/FAQS/timing.html

	#endif


	bFrameRateSet = false;

	//----------------------
	// setup the callbacks
	glutMouseFunc(mouse_touchCb);
	glutMotionFunc(motion_touchCb);
	glutPassiveMotionFunc(passive_motion_touchCb);
	glutIdleFunc(idle_touchCb);
	glutDisplayFunc(display_touchCb);

	glutKeyboardFunc(keyboard_touchCb);
	glutKeyboardUpFunc(keyboard_up_touchCb);
	glutSpecialFunc(special_key_touchCb);
	glutSpecialUpFunc(special_key_up_touchCb);

	//----------------------

	ofSeedRandom();

	// 		seed the random generator
	// 		(users can seed it to a value in setup
	// 		if they want it fixed);

	OFXTAptr->_setup();
	glutMainLoop();
}
Beispiel #14
0
void testApp::update() {
	vector<ofVec2f> touches;
	ofSeedRandom(0);
	for(int i = 0; i < 1; i++) {
		float f = .1;
		touches.push_back(
			ofVec2f(
				ofGetWidth() * ofNoise(ofGetElapsedTimef() * f + ofRandom(1024)),
				ofGetHeight() * ofNoise(ofGetElapsedTimef() * f + ofRandom(1024))));
	}
	if(ofGetMousePressed()) {
		touches.push_back(ofVec2f(mouseX, mouseY));
	}
	scenes[curScene]->setTouches(touches);
	scenes[curScene]->update();
}
Beispiel #15
0
Ball::Ball() {
    
    ofSeedRandom();
    
    xVelocity = ofRandom(0.0, 1.0);
    yVelocity = ofRandom(0.0, 1.0);
    zVelocity = ofRandom(0.0, 1.0);
    
    pos.x = ofGetWindowWidth() * 0.5;
    pos.y = ofGetWindowHeight() * 0.5;
    pos.z = ofGetWindowHeight() * 0.5;
    
    ofSetRectMode( OF_RECTMODE_CENTER );
    
    
}
Beispiel #16
0
void ofApp::draw() {
	ofBackground(0);
	ofTranslate(16, 16);
	ofSetColor(255);
	splineTool.draw();
	ofNoFill();
	ofSetColor(ofColor::red);
	float spacing = ofMap(mouseX, 0, ofGetWidth(), .1, .01, true);
	ofSeedRandom(0);
	int i = 0;
	for(float t = 0; t <= 1; t += spacing) {
		ofVec2f cur = splineTool.getSnapped(t, 50);
		ofCircle(cur, 3);
	}
	ofCircle(splineTool.getSnapped(fmodf(ofGetElapsedTimef() / 10., 1.), 50), 6);
}
Beispiel #17
0
void MissingControl::buildSpeakers() {
	ofxXmlSettings calibration;
	calibration.loadFile("calibration.xml");
	ofSeedRandom(0);
	for(int i = 0; i < centersCloud.getNumVertices(); i++) {
		Speaker speaker;
		ofVec3f position = centersCloud.getVertex(i);
		position.z = feetToMillimeters(ofRandom(2, 6));
		calibration.pushTag("speaker", i);
		int posMin = calibration.getValue("posMin", 0);
		int posCenter = calibration.getValue("posCenter", 64);
		int posMax = calibration.getValue("posMax", 127);
		calibration.popTag();
		speaker.setup(position, wiresCloud, posMin, posCenter, posMax);
		speakers.push_back(speaker);
	}
}
Beispiel #18
0
// ---------------------------------------------------------------------------------------------------------------------------------------------------
//
void ofApp::setup()
{
	isServer = false;
	
	fontSmall.loadFont("Fonts/DIN.otf", 8 );
    
	ofSeedRandom();
	int uniqueID = ofRandom( 999999999 ); // Yeah this is bogus I know. Good enough for our purposes.
    server = NULL;
	client = NULL;
	
    if( ofFile( ofToDataPath("Settings/IsServer.txt")).exists() )
	{
		server = new ofxServerOscManager();
		server->init( "Settings/ServerSettings.xml" );
        
		isServer = server->isInitialised();
        ofAddListener( server->newDataEvent, this, &ofApp::newData );
        cout<<"Starting Server"<<endl;
	}
	else
	{
        ofxXmlSettings XML;
        bool loadedFile = XML.loadFile( "Settings/ClientSettings.xml" );
        if( loadedFile )
        {
            screenIndex = XML.getValue("Settings:ScreenIndex", 0);
            displayWidth = XML.getValue("Settings:DisplayWidth", 5120);
            displayHeight = XML.getValue("Settings:DisplayHeight", 2880);
            viewWidth = XML.getValue("Settings:ViewWidth", ofGetWidth());
            viewHeight = XML.getValue("Settings:ViewHeight", ofGetHeight());
            screenOffsetX = viewWidth*screenIndex;
        }
        
		client = new ofxClientOSCManager();
		client->init( screenIndex );
		
		commonTimeOsc = client->getCommonTimeOscObj();
		commonTimeOsc->setEaseOffset( true );
		
		ofAddListener( client->newDataEvent, this, &ofApp::newData );
	}
    
    // Read the screen index from a file
    
}
//--------------------------------------------------------------
void testApp::setup(){
    ofSeedRandom();
    
    
    dest1 = ofVec2f( ofRandomWidth(), ofRandomHeight() );
    dest2 = ofVec2f( ofRandomWidth(), ofRandomHeight() );
    
    car1.setParams( ofGetWindowSize() / 2, ofVec2f(10, -5) );
    car2.setParams( ofGetWindowSize() / 2, ofVec2f(10, 5) );
    
    car1.color = ofColor(0,255,0);
    car2.color = ofColor(0,0,255);
    
    ofBackground(255);
    
    ofEnableAlphaBlending();
}
Beispiel #20
0
 void draw() {
     ofMesh mesh;
     mesh.setMode(OF_PRIMITIVE_POINTS);
     int n = initial.size();
     float t = ofMap(cos(ofGetElapsedTimef()), -1, 1, 0, 1);
     ofSeedRandom(0);
     for(int i = 0; i < n; i++) {
         mesh.addVertex(grid[i] * t + initial[i] * (1 - t));
         mesh.addColor(ofFloatColor(1, initial[i].x, initial[i].y));
     }
     float padding = 128;
     float scale = ofGetWidth() - 2 * padding;
     ofTranslate(padding, padding);
     ofScale(scale, scale);
     ofSetColor(255);
     mesh.draw();
 }
//--------------------------------------------------------------
void testApp::draw(){

    ofEnableAlphaBlending();    
    ofEnableSmoothing();      
    ofSetLineWidth(1);
    
    
    
    //draw two dimensional array
    
    ofSeedRandom(0);
    
    ofSetColor(24, ofRandom(255), 117,70);
    ofNoFill();
  
    for(int i=0; i<NUM; i++){
        mouse.x=mouseX;
        mouse.y=mouseY;
        int distance= (pos[i] - mouse).length()/6;
        distance=ofClamp(distance, 7, ofRandom(5,100));
        difference = pos[i]-mouse;
        
        float angle = atan2(difference.y, difference.x);
        
//        polygon = ofRandom(3,8);
     
//        for (int j = 0; j < polygon; j++) {
//            j = j+1;
//            ofPushMatrix();
//            ofTranslate(pos[i].x,pos[i].y);
//            ofRotate(360/polygon*j);
//            ofTriangle(0,0,distance,0,distance*cos(360/polygon*j),sin(360/polygon*j));
//            ofPopMatrix(); 
//        }
        
        ofPushMatrix();
        ofTranslate(pos[i].x,pos[i].y);
        ofRotate(angle * RAD_TO_DEG);
        ofTriangle(0,0,distance,0,distance*0.5,distance*0.866);
        ofPopMatrix();
                 
           }
    

}
Beispiel #22
0
//--------------------------------------------------------------
void ofApp::setup()
{
    k = 0;
    j = 0;
    
    fw = ofGetWidth();
    fh = ofGetHeight();
    
    ofSeedRandom();
    
    lineColor.set(0, 0, 255, 255);
    lineSpeed.set(0, 0);
    lineFriction = 0;
    
    alr1.setup();
    
    stat1 = " ";
}
Beispiel #23
0
void ofApp::setup() {
	ofSeedRandom(0);
	ofSetVerticalSync(true);

	iso.setup(64);
	
	vector<ofVec3f> centers;
	for(int i = 0; i < 12; i++) {
		centers.push_back(ofVec3f(ofRandomuf(), ofRandomuf(), ofRandomuf()));
	}
	iso.setCenters(centers);
	iso.setRadius(8/32., 16./32.);
	iso.update();
	
	ofMesh mesh = iso.getMesh();
	mesh.save("out-ascii.ply", false);
	mesh.save("out-binary.ply", true);
}  
void PMBrushContainer2::setOrigin(PMBrushContainerOrigin origin)
{
    ofSeedRandom(rand());
    float randomNormalizedPos = ofRandom(MIN_ORIGIN, MAX_ORIGIN);
    randomNormalizedPos = 0.5f;

    switch (origin)
    {
        case LEFT:
        default: // TODO: Check why sometimes origin is a weird number (it's not initialized)
        {
            setPositionX(0);
            setPositionY(randomNormalizedPos);
            direction = RIGHT;
            break;
        }
        case RIGHT:
        {
            setPositionX(1);
            setPositionY(randomNormalizedPos);
            direction = LEFT;
            break;
        }
        case UP:
        {
            setPositionY(0);
            setPositionX(randomNormalizedPos);
            direction = DOWN;
            break;
        }
        case DOWN:
        {
            setPositionY(1);
            setPositionX(randomNormalizedPos);
            direction = UP;
            break;
        }
    }

//    cout << "--------------------------------" << endl;
//    cout << "setOrigin " << origin << endl;
//    cout << "Pos: " << x << ", " << y << endl;
//    cout << "--------------------------------" << endl;
}
void ofApp::initRandom(ofFbo &target, int seed){
    printf("init random %d\n", seed);
    ofSeedRandom(seed);
    ofFloatPixels newState;
    int w = target.getWidth();
    int h = target.getHeight();
    newState.allocate(w, h, OF_PIXELS_RGB);
    for(int x=0; x<w; x++){
        for(int y=0; y<h; y++){
            float r = ofSignedNoise(x,y,frame);
            float g = ofSignedNoise(x+11111,y+11111,frame);
            float b = ofSignedNoise(x+37283,y+37283,frame);
            newState.setColor(x,y,ofFloatColor(r,g,b));
        }
    }
    target.begin();
    ofImage(newState).draw(0,0,w,h);
    target.end();
}
Beispiel #26
0
//------------------------------------------------------------------------------
void ofApp::setup()
{
	//ofToggleFullscreen();
	
	ofBackground(0,0,0);	
    ofSeedRandom(ofGetSystemTimeMicros());
    ofSetLogLevel(OF_LOG_VERBOSE);
	ofLogToFile("Log.txt",false);
	font.loadFont("frabk.ttf", 26, false);

	settings.useHDMIForAudio = false;	//default true
	settings.enableLooping = false;		//default true
	settings.enableTexture = true;		//default true
	settings.listener = this;			//this app extends ofxOMXPlayerListener so it will receive events ;
	
	if(!settings.enableTexture) {
		settings.displayRect.width=320;
		settings.displayRect.height=240;
		settings.displayRect.x =0;
		settings.displayRect.y =0;
	}		  
    
    string path = "videos";
    int maxvids = 100;
	vidreader.setup(maxvids,path);
	bLoading = true;
	bInitVids = false;
    bShowInfo = true;
    bTriggerNextMovie = false;
    bReceivedEvent = false;

    bExiting = false;	
	bEndMovie = false;
	ratio = 0.0f;
	currentVideo = "";
	curTime = ofGetElapsedTimeMillis();
	prevTime = curTime;
	
    ofAddListener(loader.youTubeURLEvent, this, &ofApp::receivedYouTubeURLEvent);
    
    getNewVideo();

}
Beispiel #27
0
//--------------------------------------------------------------
void testApp::setup(){
	// initialize app
	ofSetFrameRate(30);
    ofEnableSmoothing();
    ofEnableAlphaBlending();
	ofSetBackgroundAuto(false);
    
	client.setup("settings.xml", this);
	
    // set the random seed
	ofSeedRandom(1);
    
    // add a "randomly" placed ball
    Ball* ball = new Ball(ofRandom(0, client.getMWidth()), ofRandom(0, client.getMHeight()), client.getMWidth(), client.getMHeight());
    balls.push_back(ball);
    
	// start client
    client.start();
}
Beispiel #28
0
//--------------------------------------------------------------
void ofApp::setup(){
    ofEnableAlphaBlending();
    ofSoundSetVolume(1);
    viewPos = ofVec2f(0, 0);
    first = true;
    currentState = MAINMENU;
    ofSetFrameRate(60); //set framerate
    ofSeedRandom();
    mapDim = ofVec2f(60, 60);
    tileDim = ofVec2f(32, 32);
    mainSound.loadSound("Music1.mp3");
    secondSound.loadSound("Music2.mp3");
    menuSound.loadSound("Music3.mp3");
    mainSound.setLoop(false);
    menuSound.setLoop(true);
    secondSound.setLoop(false);
    soundIsPlaying == false;

}
void SimpleThresholdTrigger::draw()
{
	ofVec2f center = ofVec2f(mLocation.x + mLocation.width / 2.,
							 mLocation.y + mLocation.height / 2.);
	// Draw the threshold as a light grey cricle
	ofSetColor(180, 180, 180, 64);
	float locationRadius = min(mLocation.width, mLocation.height) / 2.;
	ofCircle(center, mThreshold * locationRadius);
	// Then draw the movement amount as a colour circle growing out of it
	int red = (int)(mPreviousMovement * 244.);
	int green = (int)(mPreviousMovement * 10. + 30);
	int blue = max(0,(int)((.4 - .1*mPreviousMovement) * 43.)+130);
	ofColor circleColor = ofColor(red, green, blue, 255);
	ofSetColor(circleColor);
	ofCircle(center, mPreviousMovement * locationRadius);
	
	// Some small visual effect of a ring moving outwards
//	if (mNoteIsPlaying)
	{
		float t = ofGetElapsedTimef() - mTimeNoteStarted;
		float circleLifetime = 5.f;
		// to prevent artefacts, we add a little bit onto the lifetime
		// based on which circle we're in.
		// Seed the random number generator so that each trigger always gets the same number each frame
		ofSeedRandom(int(1000. * mLocation.x) + int(1000000. * mLocation.y) + 2367);
		circleLifetime = circleLifetime + ofRandom(0.f, 3.f);
		if (t<circleLifetime)
		{
			t = t/circleLifetime; // scale t to between 0 and 1
			t = ofClamp(t, 0., 1.);
			// Fade to white over 5 seconds
			circleColor.lerp(ofColor::white, pow(t*.7f+.3f, .6f));
			// draw the circle the at threshold size when the note is first plaing
			// and a larger size when it stops playing, fading out
			float radius = mThreshold * locationRadius * (pow(t, .25f) * 20. + 1.);
			float opacity = pow(1.f - t, 3.f) * .4;
			circleColor.a = opacity * 255;
			ofSetColor(circleColor);
//			glColor4f(circleColor.r/255., circleColor.g/255., circleColor.b/255., opacity);
			ofCircle(center, radius);
		}
	}
}
Beispiel #30
0
void KoreaFlock::setRandomEating()
{
	ofSeedRandom();
	
	// pick a random particle
	int i = ofRandom(0,particles.size()-1);
	
	// set its state
	particles[i].setState(KPARTICLE_EATING);
	
	// set its targetForce
	particles[i].targetForce = .1;
	
	// pick target in range
	float radius = ofRandom(30,50);
	float angle = ofRandom(0,TWO_PI);
	particles[i].target.set( particles[i].pos.x+radius * cos(angle), particles[i].pos.y+radius * sin(angle), particles[i].pos.z+ ofRandom(-5,5) );
	
	
}