Exemplo n.º 1
0
void ofApp::setup(){

	ofSetFrameRate(60);
	ofSetVerticalSync(true);
	ofEnableAlphaBlending();
	ofBackground(22);

	TIME_SAMPLE_ENABLE();
	scale = scaleTarget = 1.0;

	// LOAD ATLAS /////////////////////////////////////////////////

	altasLoaded = false;
	ofAddListener(atlasCreator.eventAllAtlasesLoaded, this, &ofApp::onAtlasesLoaded);
	atlasCreator.loadAtlasesFromDisk(GL_RGBA, //internal format
									 "textureCache", //dir
									 "png", //image format
									 true, //gen mipmaps
									 -0.9 //mipmap bias
									 );

	////////////////////////////////////////////////////////

	RUI_SETUP();
	RUI_SHARE_PARAM(p, -100, 100);
	RUI_LOAD_FROM_XML();
}
Exemplo n.º 2
0
//--------------------------------------------------------------
void ofApp::setup(){

	fonts.setup(512);
	fonts.addFont("veraMono", "fonts/VeraMono.ttf");
	fonts.addFont("veraMonoBold", "fonts/VeraMono-Bold.ttf");
	fonts.addFont("Helvetica", "fonts/HelveticaNeue.ttf");

	ofxFontStashStyle style;
	style.fontID = "veraMono";
	style.fontSize = 14;
	style.color = ofColor::yellow;
	fonts.addStyle("banana", style);

	style.color = ofColor::brown;
	fonts.addStyle("monkey", style);

	fonts.setLineHeightMult(0.9);
	ofBackground(22);
	TIME_SAMPLE_ENABLE();
	TIME_SAMPLE_SET_AVERAGE_RATE(0.01);
	TIME_SAMPLE_SET_DRAW_LOCATION(TIME_SAMPLE_DRAW_LOC_TOP_RIGHT);

	RUI_SETUP();
	RUI_SHARE_PARAM(debug);
	RUI_LOAD_FROM_XML();

}
Exemplo n.º 3
0
void ofApp::setup(){

	ofBackground(22);

	RUI_SETUP();

	// PARAMS
	RUI_NEW_GROUP("PARAMS");

	RUI_NEW_GROUP("OBJ DROP");
	dropBounceHeight = 0.21;
	RUI_SHARE_PARAM(dropBounceHeight, 0, 1);

	RUI_NEW_GROUP("QUADRATIC BEZIER");
	quadBezierA = 0.87; quadBezierB = 0.18;
	RUI_SHARE_PARAM(quadBezierA, 0, 1);
	RUI_SHARE_PARAM(quadBezierB, 0, 1);

	RUI_NEW_GROUP("EXP SIGMOID");
	expSigmoidSteep = 0.65;
	RUI_SHARE_PARAM(expSigmoidSteep, 0, 1);

	RUI_NEW_GROUP("CUBIC BEZIER");
	cubicBezAx = 0.19; cubicBezAy = 0.91;
	cubicBezBx = 0.97; cubicBezBy = 0.2;
	RUI_SHARE_PARAM(cubicBezAx, -0.5, 2);
	RUI_SHARE_PARAM(cubicBezAy, -0.5, 2);
	RUI_NEW_COLOR();
	RUI_SHARE_PARAM(cubicBezBx, -0.5, 2);
	RUI_SHARE_PARAM(cubicBezBy, -0.5, 2);

	RUI_NEW_GROUP("CUBIC BEZIER 2");
	cubicBez2Ax = 0.36; cubicBez2Ay = 0.22;
	cubicBez2Bx = 0.55; cubicBez2By = 0.81;
	RUI_SHARE_PARAM(cubicBez2Ax, -0.5, 2);
	RUI_SHARE_PARAM(cubicBez2Ay, -0.5, 2);
	RUI_NEW_COLOR();
	RUI_SHARE_PARAM(cubicBez2Bx, -0.5, 2);
	RUI_SHARE_PARAM(cubicBez2By, -0.5, 2);

	RUI_NEW_GROUP("ELASTIC");
	elasticG = 0.26; elasticFreq = 0.52; elasticDecay = 0.08;
	RUI_SHARE_PARAM(elasticG, 0, 1);
	RUI_SHARE_PARAM(elasticFreq, 0, 1);
	RUI_SHARE_PARAM(elasticDecay, 0, 1);

	RUI_NEW_GROUP("EASE_OUT");
	easeOutOffset = -0.78;
	RUI_SHARE_PARAM(easeOutOffset, -4, 4);

	RUI_NEW_GROUP("BOUNCE");
	bounceNum = 4; bounceElast = 0.38;
	RUI_SHARE_PARAM(bounceNum, 0, 10);
	RUI_SHARE_PARAM(bounceElast, 0, 1);

	for ( int i = 0; i < NUM_ANIM_CURVES; i++ ){
		pos[i].animateFromTo( xMargin, xMargin + widthCol );
		pos[i].setDuration(2);
		pos[i].setRepeatType( LOOP_BACK_AND_FORTH );
		AnimCurve curve = (AnimCurve) (EASE_IN_EASE_OUT + i );
		pos[i].setCurve( curve );
		curveNames[i] = ofxAnimatable::getCurveName( curve );
	}
}
Exemplo n.º 4
0
//--------------------------------------------------------------
void ofApp::setup(){
    
    
    ofSetVerticalSync(true);
    ofSetFrameRate(60);
    
    // for single delivery package
    //ofSetDataPathRoot("./");
    
    
    ofDirectory dir;
    dir.open(ASSEST_VIDOE_FOLDER);
    int numFiles = dir.listDir();
    
    for (int i = 0; i < numFiles; ++i)
    {
        cout << "Path at index [" << i << "] = " << dir.getPath(i) << endl;
        videoPlayers.push_back(new ofxAVFVideoPlayer());
        videoPlayers[i]->loadMovie(dir.getPath(i));
        videoPlayers[i]->setLoopState(OF_LOOP_NORMAL);
        videoPlayers[i]->play();
    }
    
    
    // load video
//    for(int i=0; i<N_VIDEO_PLAYERS; i++) {
//        videoPlayers.push_back(new ofxAVFVideoPlayer());
//        videoPlayers[i]->loadMovie("movies/farm_window.mov");
//        videoPlayers[i]->setLoopState(OF_LOOP_NORMAL);
//    }
    
//    // load images
//    imgBottom = new ofImage();
//    imgTop = new ofImage();
//    
//    imgBottom->loadImage("images/L2.jpg");
//    imgTop->loadImage("images/L1.jpg");
    
    
    // load image using ofxGiantImage
    //imgTopx = new ofxGiantImage();
    //imgTopx->loadImage("images/L1.jpg");
    imgTop = new ofxGiantImage();
    imgBottom = new ofxGiantImage();
    imgBottom->loadImage("images/L2.jpg"); //papaya
    imgTop->loadImage("images/L1.jpg");
    
    imgTopPosters.push_back(imgTop);
    
    // enable trace to file
    //ofLogToFile("myLogFile.txt", true);
    
    // initilization
    videoPause = false;
    imageDisplay = false;
    dbgImg = false;
    isDemoMode = false;
    isUpdateImg = false;
    isDownloadImg = false;
    imgRotateIndex = 0;


#ifdef REMOTE_CONTROL
    ////////////////////////////////////////////////////////
    // Remote UI
    
    RUI_SETUP(); //start server
    RUI_SHARE_PARAM(isDemoMode, ofColor(255,0,0,64));
    
    // SET PARAM GROUPS / COLORS //////////////////////////////////
    RUI_NEW_GROUP("Poster");	//make a new group (optional)
    
    // SHARE A STRING PARAM ////////////////////////////////
    strPoster = " ";
    RUI_SHARE_PARAM(strPoster, ofColor(255,0,0,64));	// you can also set a color on a per-param basis
    //Expose x and y vars to the server, providing a valid slider range
    RUI_SHARE_PARAM(x, 0, ofGetWidth());
    RUI_SHARE_PARAM(y, 0, ofGetHeight());
    
    strUpdateFileDate = "";
    RUI_SHARE_PARAM(strUpdateFileDate);
    
    //share the color param
    //RUI_SHARE_COLOR_PARAM(color);
    
    
    // SET PARAM GROUPS / COLORS //////////////////////////////////
    RUI_NEW_GROUP("Video");	//make a new group (optional)
    
    strFruitPrefix = "今天的苹果好好吃,总共有 ";
    strUnit = " 颗";
    currentAppleAmount = "0";
    RUI_SHARE_PARAM(currentAppleAmount, ofColor(255,0,0,64));	// you can also set a color on a per-param basis
    
    
    // SHARE AN ENUM PARAM ////////////////////////////////
    //build a string list for the UI to show
//    menu = MENU_OPTION_1;
//    string menuItems[] = {"MENU_OPTION_0", "MENU_OPTION_1", "MENU_OPTION_2", "MENU_OPTION_3"};
//    //privide the enum param, loweset enum, highest enum, and the Enum string list
//    RUI_SHARE_ENUM_PARAM(menu, MENU_OPTION_0, MENU_OPTION_3, menuItems);
    
    
    // SHARE A string PARAM to unload it later;
    //this is useful in cases where a variable used to be shared,
    //but its value is now on the xml and you still want it loaded
    //but you dont want it to show on the client interface
    //to do so, you first share the param, then load from XML, then remove the param
    unloadTest = "inited from source";
    RUI_SHARE_PARAM(unloadTest);
    
    //load values from XML, as they were last saved (if they were)
    RUI_LOAD_FROM_XML();
    
    //this efectively removes all remoteUI references to this param
    //but bc it's been loaded from xml in the previous step before,
    //the end result is that you get to load its value from XML
    //but it doesnt show in the client.
    //This is meant to be a way to reduce clutter in the client,
    //allowing you to phase out params that have settled down and dont
    //need further editing, but still allowing you to load its value from the xml.
    RUI_REMOVE_PARAM(unloadTest);
    cout << "unloadTest: '" << unloadTest << "'" << endl;
    
    RUI_WATCH_PARAM(currentMouseX); //this will print the supplied param all the time on screen,
    //useful for debugging
    RUI_GET_INSTANCE()->setBuiltInUiScale(3);
    RUI_GET_INSTANCE()->drawUiWithFontStash("SourceHanSansSC-Light.ttf");

#endif
    
    // load font
    unicodeFont.setup("SourceHanSansSC-Light.ttf", //font file, ttf only
                      1.0,					//lineheight percent
                      1024,					//texture atlas dimension
                      true,					//create mipmaps of the font, useful to scale down the font at smaller sizes
                      8,					//texture atlas element padding, shouldbe >0 if using mipmaps otherwise
                      2.0f					//dpi scaleup, render textures @2x the reso
                      );					//lower res mipmaps wil bleed into each other
    
    
    FZLfont.setup("FZLTZCHJW.ttf", //font file, ttf only
                      1.0,					//lineheight percent
                      1024,					//texture atlas dimension
                      true,					//create mipmaps of the font, useful to scale down the font at smaller sizes
                      8,					//texture atlas element padding, shouldbe >0 if using mipmaps otherwise
                      2.0f					//dpi scaleup, render textures @2x the reso
                      );					//lower res mipmaps wil bleed into each other
    
//    char serverPath[512] = "http://www.vim.org/scripts/download_script.php?src_id=7701"; //TODO: move to url list
//    char filePath[256] = "poster_01.zip";
//    
//    char cmd[1024];
//    sprintf(cmd, "curl -o %s %s", filePath, serverPath);
//    cout << "c md:" << cmd << "\n";
//    
//    //char command[] = "curl -o est.zip http://www.vim.org/scripts/download_script.php?src_id=7701";
//    //char command[] = "wget http://www.openss7.org/repos/tarballs/strx25-0.9.2.1.tar.bz2";
//    int status = system(cmd);
    
    
    initTime = ofGetElapsedTimef();
    initTimeDbg = ofGetElapsedTimef();
    ofRegisterURLNotification(this);
    
    // osc
    oscSender.setup(HOST, SENDPORT);
    oscReceiver.setup(RECVPORT);
    
    // send ready
    msgSend.setAddress("/sync/start/FW_SH_02_HBD_A");
    msgSend.addStringArg("ready");
    oscSender.sendMessage(msgSend);

}