//--------------------------------------------------------------
void GrafPlayerApp::setupControlPanel()
{
	
	panel.setup("GA 3.0", ofGetWidth()-320, 20, 300, 650);
	panel.addPanel("App Settings", 1, false);
	panel.addPanel("Draw Settings", 1, false);
	panel.addPanel("FBO Warper", 1, false);
	panel.addPanel("Audio Settings", 1, false);
	panel.addPanel("Architecture Settings", 1, false);
	panel.addPanel("Red / Blue Settings", 1, false);
	
	//---- application sttings
	panel.setWhichPanel("App Settings");
	
	
	panel.addToggle("Load tags", "LOAD_TAGS", false);
	panel.addToggle("Auto load on start", "AUTO_LOAD", true);
	panel.addSpace();
	
	panel.addToggle("Use Audio", "use_audio",true);
	panel.addToggle("Use Architecture", "use_arch",true);
	panel.addToggle("Use Red / Blue", "use_rb",true);
	panel.addSpace();
	
	panel.addToggle("Play / Pause", "PLAY", true);
	panel.addToggle("FullScreen", "FULL_SCREEN", false);
	panel.addToggle("Rotate", "ROTATE", true);
	panel.addSlider("Rotation Speed","ROT_SPEED",.65,0,4,false);
	panel.addSlider("Change wait time","wait_time",30,0,120,true);
	panel.addToggle("Display filename", "SHOW_NAME", true);
	panel.addToggle("Display time", "SHOW_TIME", true);
	panel.addToggle("Save Tag Position/Rotation", "save_Tag_pos", false);
	panel.addSpace();
	
	rssTextBox = panel.addTextInput("Rss Keyword", "RSS_KEYWORD", "", 200, 18 );
	panel.addToggle("Load from rss", "LOAD_RSS", false);
		
	//--- rb
	panel.setWhichPanel("Red / Blue Settings");
	panel.addSlider("Eye Distance","eye_dist",5,0,20,false);
	panel.addToggle("Red Channel on Right","red_on_right",true);
	
	//--- draw settings
	panel.setWhichPanel("Draw Settings");
	panel.addSlider("Line Alpha","LINE_ALPHA",.92,0,1,false);
	panel.addSlider("Outline Width","LINE_WIDTH",2,1,10,false);
	panel.addSlider("Line Scale","LINE_SCALE",.05,0,.1,false);
	panel.addSlider("Particle Size","P_SIZE",2,0,10,false);
	panel.addSlider("Particle Alpha","P_ALPHA",.75,0,1,false);
	panel.addSlider("Particle Damping","P_DAMP",.15,0,.25,false);
	panel.addSlider("Number Particles","P_NUM",1,0,4,true);
	panel.addToggle("Use gravity", "USE_GRAVITY", true);
	panel.addToggle("Use edge mask", "USE_MASK", false);
	panel.addSlider("Z Depth","Z_DEPTH",16,0,50,false);
	panel.addToggle("Apply to Z to all","Z_ALL",false);
	
	
	
	//--- audio settings
	panel.setWhichPanel("Audio Settings");
	panel.addSlider("Outward amp force","outward_amp_force",8,0,200,false);
	panel.addSlider("Particle size force","particle_size_force",22,0,200,false);
	panel.addSlider("Wave deform force","wave_deform_force",1,0,10,false);
	panel.addSlider("Bounce force","bounce_force",.25,0,2,false);
	panel.addSlider("Drop p threshold","drop_p_thresh",.1,0,2,false);
	// toggles to apply what to what...
	panel.addToggle("Use particle amp", "use_p_amp", true);
	panel.addToggle("Use particle size", "use_p_size", true);
	panel.addToggle("Use wave deform", "use_wave_deform", true);
	panel.addToggle("Use bounce", "use_bounce", true);
	panel.addToggle("Use drop particel", "use_drop", true);

	//--- arch settings
	panel.setWhichPanel("Architecture Settings");
	panel.addToggle("new structure", "new_structure",false);
	panel.addToggle("done","arch_done",false);
	panel.addToggle("save xml", "arch_save", false);
	panel.addToggle("load xml", "arch_load", false);
	panel.addToggle("clear", "arch_clear", false);
	panel.addSpace();
	
	panel.addToggle("show drawing tool", "show_drawing_tool",false);
	panel.addToggle("show image", "show_image",true);
	panel.addSlider("mass","box_mass",1,0,20,false);
	panel.addSlider("bounce","box_bounce",.53,0,2,false);
	panel.addSlider("friction","box_friction",.41,0,2,false);
	panel.addSlider("gravity","gravity",6,0,20,false);
	panel.addSlider("max time to fall","max_arch_time",5,-1,10,false);
	
	//--- fbo settings	
	panel.setWhichPanel("FBO Warper");
	panel.addToggle("Load Warping", "load_warping", true);
	panel.addToggle("Save Warping", "save_warping", false);
	panel.addToggle("Reset Warping", "reset_warping", false);
	panel.addToggle("Toggle Preview","toggle_fbo_preview",false);
	
	//--- load saved
	panel.loadSettings(pathToSettings+"appSettings.xml");
	
	updateControlPanel(true);
	
	keypanel.setup("GA 3.0",  panel.boundingBox.x-260, 20, 230, 650);
	keypanel.setBackgroundColor(0, 0, 0, 100);
	keypanel.setForegroundColor(0, 0, 0, 200);
	keypanel.setTextColor(220, 220, 220, 220);
	keypanel.setOutlineColor(220, 220, 220, 220);
	keypanel.borderWidth	= 3;
	keypanel.bDrawOutline	= false;
	keypanel.bShowTabs		= false;
	keypanel.bDrawHeader	= false;
	keypanel.topSpacing		= 1;
	guiTypePanel * myPanel	= keypanel.addPanel(" ", 1, false);
	myPanel->setElementSpacing(0, 5);
	
	keypanel.setWhichPanel(" ");
	keypanel.addText("Key Commands:","K");
	keypanel.addText("x: toggle control panel","x");
	keypanel.addText("p: pause/play","p");
	//keypanel.addText("s: screen capture","s");
	keypanel.addText("m: toggle mouse","m");
	keypanel.addText("f: toggle fullscreen","f");
	keypanel.addText("R: reset pos/rot","R");
	keypanel.addText("s: save ALL tags","s");
	keypanel.addText("S: save current tag","s");
	keypanel.addText("arrows: next/prev","arrows");
	keypanel.addText("esc: quit","esc");
	keypanel.addText("L mouse: alter position","lm");
	keypanel.addText("L+shift mouse: zoom","lsm");
	keypanel.addText("R mouse: rotate y","rm");
	keypanel.addText("R+shift mouse: rotate x","rsm");
	//keypanel.addText("left-mouse: add point","lm");
	//keypanel.addText("right-mouse: move / select all","rmm");
	//keypanel.addText("left+shift mouse: move single point","lsmm");
	//keypanel.addText("Return: new shape","Ret");
	//keypanel.addText("Delete: remove last point","Del");
	
	keypanel.update();
	
	
}
//--------------------------------------------------------------
void GrafPlayerApp::setup(){

	
	ofxXmlSettings xmlUser;
	xmlUser.loadFile("appSettings.xml");
	string username = xmlUser.getValue("project_folder","default");
	
	pathToSettings = "projects/"+username+"/settings/";//"settings/default/";
	myTagDirectory = "projects/"+username+"/tags/";
	
	ofAddListener(ofEvents.mouseMoved, this, &GrafPlayerApp::mouseMoved);
	ofAddListener(ofEvents.mousePressed, this, &GrafPlayerApp::mousePressed);
	ofAddListener(ofEvents.mouseReleased, this, &GrafPlayerApp::mouseReleased);
	ofAddListener(ofEvents.mouseDragged, this, &GrafPlayerApp::mouseDragged);
	ofAddListener(ofEvents.keyPressed, this, &GrafPlayerApp::keyPressed);
	ofAddListener(ofEvents.keyReleased, this, &GrafPlayerApp::keyReleased);

	screenW			= ofGetWidth();
	screenH			= ofGetHeight();
	
	mode			= PLAY_MODE_LOAD;
	lastX			= 0;
	lastY			= 0;
	bShowPanel		= true;
	bRotating		= false;
	bShowName		= false;
	bShowTime		= false;
	bUseFog			= true;
	bUseMask		= true;
	bTakeScreenShot = false;
	bUseGravity		= true;
	bUseAudio		= true;
	bUseArchitecture= true;
	modeRender		= GA_RMODE_NORMAL;
	modeDualScreen	= GA_SCREENS_NORMAL;
	
	
	prevStroke		= 0;
	currentTagID	= 0;
	waitTime		= 2.f;
	waitTimer		= waitTime;
	rotationY		= -45;
	tagMoveForce	= .1;
	tagPosVel.set(0,0,0);
	z_const			= 16;
	bUseGlobalZ		= false;
	lastUpdatedZ	= -1;
	
	fontSS.loadFont("fonts/frabk.ttf",9);
	fontS.loadFont("fonts/frabk.ttf",14);
	fontL.loadFont("fonts/frabk.ttf",22);
	imageMask.loadImage("images/mask.jpg");
	
	float FogCol[3]={0,0,0};
    glFogfv(GL_FOG_COLOR,FogCol);
    glFogi(GL_FOG_MODE, GL_LINEAR);
    glFogf(GL_FOG_DENSITY, 0.05f);
	fogStart = 370;
    fogEnd   = 970;
	
	// controls
	setupControlPanel();
	updateControlPanel();
	
	if(panel.getValueB("use_rb") ) modeRender = GA_RMODE_RB;

	particleDrawer.setup(screenW,screenH);
	
	// fbo
	#ifdef GA_STACK_SCREENS
		fbo.allocate(screenW*2,screenH*2 );
	#else
		fbo.allocate(screenW,screenH );
	#endif
	
	pWarper.initWarp( screenW,screenH,screenW*WARP_DIV,screenH*WARP_DIV );
	pWarper.recalculateWarp();
	pWarper.loadFromXml(pathToSettings+"warper.xml");
	
	// audio
	audio.setup();
	
	#ifdef GA_STACK_SCREENS
		archPhysics.setup(screenW,screenH);
		archPhysics.floorH = screenH*2;
	#else
		archPhysics.setup(screenW,screenH);
	#endif
	
	archPDropTime = 0;
	
	if(bUseArchitecture)
	{
		archPhysics.archImage.loadImage(pathToSettings+"arch.jpg");
		archPhysics.loadFromXML(pathToSettings+"architecture.xml");
		createWarpedArchitecture();
	}
	
	// red blue stuff
	fboLeft.allocate(screenW,screenH );
	fboRight.allocate(screenW,screenH );
	
	loadStatus = "No tags loaded.";
	if(panel.getValueB("AUTO_LOAD") )
	{
		preLoadTags(0);
	}
	
	bSetup = true;
	
	
	gIO.setup("0","Graffiti Analysis","3.0");
	
}
Beispiel #3
0
void userComboScene::update()
{
	if(bPanelOn) updateControlPanel();
}
//--------------------------------------------------------------
void GrafPlayerApp::update(){

	dt  = ofGetElapsedTimef()-lastTime;
	lastTime  = ofGetElapsedTimef();
	
	
	bool bTrans = false;
	
	if( mode == PLAY_MODE_LOAD )
	{
		loadTags();
		if(bUseAudio)audio.update();
	}
	else if( mode == PLAY_MODE_PLAY && tags.size() > 0 )
	{
		
		//---- set drawing data for render
		if( drawer.bSetupDrawer )
			drawer.setup( &tags[currentTagID], tags[currentTagID].distMax );

		//---- update tag playing state
		if( !myTagPlayer.bDonePlaying )					
		{
			myTagPlayer.update(&tags[currentTagID]);	// normal play, update tag
		
		}else if( !myTagPlayer.bPaused && myTagPlayer.bDonePlaying && waitTimer > 0)			   
		{
			waitTimer -= dt;	// pause time after drawn, before fades out
		}
		else if ( !myTagPlayer.bPaused && myTagPlayer.bDonePlaying && (drawer.alpha > 0 || particleDrawer.alpha > 0))			  		
		{
			updateTransition(0);
			bTrans = true;
		}
		else if (  !myTagPlayer.bPaused && myTagPlayer.bDonePlaying )							
		{
			resetPlayer(1);	// setup for next tag
		}
	
		
		//---------- AUDIO applied
		if( bUseAudio) updateAudio();
		
		
		//--------- ARCHITECTURE
		if( bUseArchitecture ) updateArchitecture();
		
		
		//--------- PARTICLES
		updateParticles();
			
		
		//--------- TAG ROTATION + POSITION
		if(bRotating && !myTagPlayer.bPaused ) rotationY += panel.getValueF("ROT_SPEED")*dt;
		
		// update pos / vel
		tags[currentTagID].position.x += tagPosVel.x;
		tags[currentTagID].position.y += tagPosVel.y;
		
		tagPosVel.x -= .1*tagPosVel.x;
		tagPosVel.y -= .1*tagPosVel.y;
		
		if(!bTrans)
		{
		tags[currentTagID].rotation_o = tags[currentTagID].rotation;
		tags[currentTagID].position_o = tags[currentTagID].position;
		}

	}
	
	
	
	// controls
	if( bShowPanel ) updateControlPanel();
	
	
}
//--------------------------------------------------------------
void calibrationManager::update(){
	
	// TODO: rewrite the code to control calibration mode.
	// bAuto--, bPre--- are not friendly to understand how it works.

	calibrationRectangle.x = 0;
	calibrationRectangle.y = 0;
	calibrationRectangle.width = ofGetWidth();
	calibrationRectangle.height = ofGetHeight();

	float widthPad = ofGetWidth() * 0.025f;
	float heightPad = ofGetHeight() * 0.025f;

	calibrationRectangle.x += widthPad;
	calibrationRectangle.y += heightPad;
	calibrationRectangle.width -= widthPad*2;
	calibrationRectangle.height -= heightPad*2;
	
	updateControlPanel();

	// TODO:make it possible to change nDivisions?
//	nDivisionsWidth = panel.getValueI("N_DIV_W");
//	nDivisionsHeight = panel.getValueI("N_DIV_H");;

	fitter.removeOutliers();
	
	totalTimePerDot = preTimePerDot + recordTimePerDot;

	if ((bAutomatic == true && bAmInAutodrive == true) || bPreAutomatic){
		menuEnergy = 0.94f * menuEnergy + 0.06f * 0.0f;
	} else {
		menuEnergy = 0.94f * menuEnergy + 0.06f * 1.0f;
	}
	
	// do the auto:
	if (bAutomatic == true && bAmInAutodrive == true){
		int nPts = nDivisionsWidth * nDivisionsHeight;
		float totalTime = totalTimePerDot * nPts;
		
		if (ofGetElapsedTimef() - startTime > totalTime){		// calibration finish.
			bAmInAutodrive = false;
			bInAutoRecording = false;
			bPreAutomatic = false;
			fitter.calculate(calibrationRectangle);
			
		} else {

			float diffTime = ofGetElapsedTimef() - startTime ;
			pt = (int)(diffTime / totalTimePerDot);
			float diffDotTime = diffTime - pt * totalTimePerDot;
			// cout << diffTime << " " << pt <<  " " << diffDotTime << endl;
			if (diffDotTime < preTimePerDot){

				autoPct = (diffDotTime / preTimePerDot);
				bInAutoRecording = false;

			} else {
				autoPct = (diffDotTime - preTimePerDot) / recordTimePerDot;
				bInAutoRecording = true;
			}
			pos = pt;
		}
	}

	inputEnergy *= 0.98f;

	int xx = (pos % nDivisionsWidth);
	int yy = (pos / nDivisionsWidth);

	bool bEven = false;
	if (yy % 2 == 0)  bEven = true;

	xp = bEven ? calibrationRectangle.x + ((float)calibrationRectangle.width / (float)(nDivisionsWidth-1)) * xx :
				 calibrationRectangle.x + (calibrationRectangle.width - ((float)calibrationRectangle.width / (float)(nDivisionsWidth-1)) * xx);

	yp = calibrationRectangle.y + calibrationRectangle.height - ((float)calibrationRectangle.height / (float)(nDivisionsHeight-1)) * yy;
	
	fitter.update(pt, xp, yp);		// raw data is comming from testApp directly to fitter.
}