Ejemplo n.º 1
0
//--------------------------------------------------------------
void testApp::setup() {
	ofSetLogLevel(OF_LOG_VERBOSE);

	kinect.setRegistration(true);
	//kinect.init();
	//kinect.init(true); // shows infrared instead of RGB video image
	kinect.init(false, false); // disable video image (faster fps)
	
	kinect.open();		// opens first available kinect
	// print the intrinsic IR sensor values
	if(kinect.isConnected()) {
		ofLogNotice() << "sensor-emitter dist: " << kinect.getSensorEmitterDistance() << "cm";
		ofLogNotice() << "sensor-camera dist:  " << kinect.getSensorCameraDistance() << "cm";
		ofLogNotice() << "zero plane pixel size: " << kinect.getZeroPlanePixelSize() << "mm";
		ofLogNotice() << "zero plane dist: " << kinect.getZeroPlaneDistance() << "mm";
	}
	
	colorImg.allocate(kinect.width, kinect.height);
	grayImage.allocate(kinect.width, kinect.height);
	grayThreshNear.allocate(kinect.width, kinect.height);
	grayThreshFar.allocate(kinect.width, kinect.height);
	
	nearThreshold = 255;
	farThreshold = 150;
	triggerThreshold = 150;
	step = 50;
	drawEllipses = false;
	maxY = kinect.height;
	minFreq = 50;
	maxFreq = 2000;
	offY = 0; 
	
	ofSetFrameRate(60);
	
	// zero the tilt on startup
	angle = 0;
	kinect.setCameraTiltAngle(angle);
	
	// start from the front
	bDrawPointCloud = false;
	
	
	OFX_REMOTEUI_SERVER_SETUP(10000); 	//start server
	OFX_REMOTEUI_SERVER_SET_UPCOMING_PARAM_COLOR(ofColor(0,255,0,100));
	OFX_REMOTEUI_SERVER_SET_NEW_COLOR(); // set a bg color for the upcoming params
	OFX_REMOTEUI_SERVER_SET_UPCOMING_PARAM_GROUP("preprocess"); //make a new group
	OFX_REMOTEUI_SERVER_SHARE_PARAM(nearThreshold, 0, 255 ); //add an "x" float param to this group.
	OFX_REMOTEUI_SERVER_SHARE_PARAM(farThreshold, 0, 255);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(triggerThreshold, 0, 255);
	
	OFX_REMOTEUI_SERVER_SET_UPCOMING_PARAM_COLOR(ofColor(255,0,0,100));
	OFX_REMOTEUI_SERVER_SET_UPCOMING_PARAM_GROUP("analyze");
	OFX_REMOTEUI_SERVER_SHARE_PARAM(step, 1, 100);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(maxY, 1, kinect.height );
	
	OFX_REMOTEUI_SERVER_SET_UPCOMING_PARAM_COLOR(ofColor(0,150,255,100));
	OFX_REMOTEUI_SERVER_SET_UPCOMING_PARAM_GROUP("display"); //make a new group
	OFX_REMOTEUI_SERVER_SHARE_PARAM(drawEllipses);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(offY, 0, ofGetWidth()/2 );
	OFX_REMOTEUI_SERVER_LOAD_FROM_XML();	//load values from XML, if you want to do so

	OFX_REMOTEUI_SERVER_SET_UPCOMING_PARAM_COLOR(ofColor(255,255,0,100));
	OFX_REMOTEUI_SERVER_SET_UPCOMING_PARAM_GROUP("synthesis"); //make a new group
	OFX_REMOTEUI_SERVER_SHARE_PARAM(minFreq, 20, 500);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(maxFreq, 500, 5000);
	
	

	ofSoundStreamSetup( 2, 0, SAMPLE_RATE, BUFFER_SIZE, NUM_BUFFERS ); 
}
Ejemplo n.º 2
0
//--------------------------------------------------------------
void testApp::setup(){

	run = true;
	ofSetVerticalSync(true);
	ofEnableAlphaBlending();
	//ofEnableBlendMode(OF_BLENDMODE_ADD);
	ofBackground(00);

	flock = new Flock(&fp);

	//inital Trail settings
	tp.radius = 22;
	tp.circleRes = 8;
	tp.skipStep = 5;
	tp.headTailcurve = QUADRATIC_EASE_OUT;
	tp.maxLength = 400;

	int lineA = 255;
	for(int i = 0; i < NUM_FISH_PER_FLOCK; i++){
		ofxColorGradient g;
//		for(int j = 0; j < 3; j++){
//			g.addColor( ofColor(	ofRandom(255),
//									ofRandom(255),
//									ofRandom(255),
//									lineA)
//					   );
//		}
		ofColor c = flock->getMember(i)->c;
		float s = 0.5;
		c.r = c.r * s;
		c.g = c.g * s;
		c.b = c.b * s;
		g.addColor(c);
		g.addColor(flock->getMember(i)->c);
		t[i].setup(g, &tp);
	}
	glEnable(GL_LINE_SMOOTH);


	ofFbo::Settings s;
	s.width = ofGetWidth();
	s.height = ofGetHeight();
	s.internalformat = GL_RGBA;
	//	s.textureTarget = GL_TEXTURE_RECTANGLE_ARB;
	s.maxFilter = GL_LINEAR; GL_NEAREST;
	s.numSamples = 8;
	s.numColorbuffers = 3;
	s.useDepth = true;
	s.useStencil = false;

	gpuBlur.setup(s, true);

	//initial params
	fp.rethinkTime = 0.03f;

	//distances
	fp.schoolFriendsDist = 5.8;
	fp.schoolOthersDist = 2.9f;
	fp.collisionDist = 0.93f;
	fp.cohesionDist = 4.04f;

	//Forces
	fp.schoolFriends = 0.44f;
	fp.schoolOthersF = 0.14f;
	fp.collisionAvoidF = 0.35f;
	fp.cohesionF = 0.35f;
	fp.centerismF = 0.001f;

	fp.maxSpeedMagnitude = 2.1;
	fp.accelerationF = 0.15f;

	fp.debugShowCollisions = false;
	fp.debugShowCohesion = false;
	fp.debugShowSchooling = false;
	fp.debugShowDirection = false;

	float distRange = 200;

	shader = new ofxAutoReloadedShader();
	shader->setMillisBetweenFileCheck(500);
	shader->load("shaders/phong");


	OFX_REMOTEUI_SERVER_SETUP(10000); 	//start server

	OFX_REMOTEUI_SERVER_SET_UPCOMING_PARAM_GROUP("SHADER");
	OFX_REMOTEUI_SERVER_SHARE_PARAM(doShader);

	vector<string> showL; showL.push_back("SHOW_ALL"); showL.push_back("SHOW_N");
	showL.push_back("SHOW_L"); showL.push_back("SHOW_E"); showL.push_back("SHOW_R");
	showL.push_back("SHOW_SPECULAR");showL.push_back("SHOW_EYE_SPECULAR");
	OFX_REMOTEUI_SERVER_SHARE_ENUM_PARAM(showInShader, SHOW_ALL, NUM_SHOWS-1, showL);

	OFX_REMOTEUI_SERVER_SET_NEW_COLOR();
	OFX_REMOTEUI_SERVER_SHARE_COLOR_PARAM(matAmbient);
	OFX_REMOTEUI_SERVER_SHARE_COLOR_PARAM(matDiffuse);
	OFX_REMOTEUI_SERVER_SHARE_COLOR_PARAM(matSpecular);

	OFX_REMOTEUI_SERVER_SET_NEW_COLOR();
	OFX_REMOTEUI_SERVER_SHARE_PARAM(specularGain,0,2);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(specularClamp,0,1);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(specularPow,0,1);

	OFX_REMOTEUI_SERVER_SET_NEW_COLOR();
	OFX_REMOTEUI_SERVER_SHARE_PARAM(eyeSpecularGain,0,2);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(eyeSpecularClamp,0,1);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(eyeSpecularPow,0,1);

	OFX_REMOTEUI_SERVER_SET_UPCOMING_PARAM_GROUP("LIGHTS");
	OFX_REMOTEUI_SERVER_SET_NEW_COLOR();
	OFX_REMOTEUI_SERVER_SHARE_COLOR_PARAM(lightAmbient);
	OFX_REMOTEUI_SERVER_SHARE_COLOR_PARAM(lightDiffuse);
	OFX_REMOTEUI_SERVER_SHARE_COLOR_PARAM(lightSpecular);
	OFX_REMOTEUI_SERVER_SET_NEW_COLOR();
	OFX_REMOTEUI_SERVER_SHARE_PARAM(animateLight);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(lightSpeed,0,10);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(lightDist,1,600);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(drawTeapot);



	OFX_REMOTEUI_SERVER_SET_UPCOMING_PARAM_GROUP("BLUR");
	OFX_REMOTEUI_SERVER_SET_NEW_COLOR();
	OFX_REMOTEUI_SERVER_SHARE_PARAM(gpuBlur.blurPasses, 0, 4);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(gpuBlur.blurOffset, 0.0, 10);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(gpuBlur.blurOverlayGain, 0, 255);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(gpuBlur.numBlurOverlays, 0, 7);

	OFX_REMOTEUI_SERVER_SET_UPCOMING_PARAM_GROUP("TRAILS");
	OFX_REMOTEUI_SERVER_SET_NEW_COLOR();
	OFX_REMOTEUI_SERVER_SHARE_PARAM(lineW, 0.1, 10);

	OFX_REMOTEUI_SERVER_SET_NEW_COLOR();
	OFX_REMOTEUI_SERVER_SHARE_PARAM(drawTrails);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(tp.radius, 0.01, 50);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(tp.flatness, 0, 1.0);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(tp.maxLength, 0, 250);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(tp.skipStep, 1, 20);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(tp.circleRes, 4, 20);
	OFX_REMOTEUI_SERVER_SET_NEW_COLOR();
	OFX_REMOTEUI_SERVER_SHARE_PARAM(tp.ondulationAmp, 0, 90);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(tp.ondulationFreq, 0, 40);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(tp.ondulationPeriod, 3, 20);
	OFX_REMOTEUI_SERVER_SET_NEW_COLOR();
	OFX_REMOTEUI_SERVER_SHARE_PARAM(tp.headLen, 0, .9);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(tp.tailLen, 0, .9);
	//MACRO acces wont work for enum types, we need to cast, so we do it manually
	vector<string> curveNames;
	for(int i = 0; i<NUM_ANIM_CURVES; i++){
		curveNames.push_back(ofxAnimatable::getCurveName((AnimCurve)i));
	}
	OFX_REMOTEUI_SERVER_SHARE_ENUM_PARAM(tp.headTailcurve, 0, NUM_ANIM_CURVES-1, curveNames);

	OFX_REMOTEUI_SERVER_SET_NEW_COLOR();
	vector<string> modesNames;
	modesNames.push_back("OF_PRIMITIVE_TRIANGLES"); modesNames.push_back("OF_PRIMITIVE_TRIANGLE_STRIP");
	modesNames.push_back("OF_PRIMITIVE_TRIANGLE_FAN"); modesNames.push_back("OF_PRIMITIVE_LINES");
	modesNames.push_back("OF_PRIMITIVE_LINE_STRIP"); modesNames.push_back("OF_PRIMITIVE_LINE_LOOP");
	modesNames.push_back("OF_PRIMITIVE_LINE_POINTS");
	OFX_REMOTEUI_SERVER_SHARE_ENUM_PARAM(tp.primitiveMode, OF_PRIMITIVE_TRIANGLES, OF_PRIMITIVE_POINTS, modesNames);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(tp.drawNormals);

	OFX_REMOTEUI_SERVER_SET_UPCOMING_PARAM_GROUP("FLOCK");
	OFX_REMOTEUI_SERVER_SET_NEW_COLOR();
	OFX_REMOTEUI_SERVER_SHARE_PARAM(fp.ignoreClans);
	OFX_REMOTEUI_SERVER_SET_NEW_COLOR();
	OFX_REMOTEUI_SERVER_SHARE_PARAM(fp.schoolFriends, 0, 1);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(fp.schoolFriendsDist, 0, distRange);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(fp.debugShowSchooling);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(fp.debugSchoolingFriendsDist);

	OFX_REMOTEUI_SERVER_SET_NEW_COLOR();
	OFX_REMOTEUI_SERVER_SHARE_PARAM(fp.schoolOthersF, 0, 1);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(fp.schoolOthersDist, 0, distRange);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(fp.debugSchoolingOthersDist);

	OFX_REMOTEUI_SERVER_SET_NEW_COLOR();
	OFX_REMOTEUI_SERVER_SHARE_PARAM(fp.collisionAvoidF, 0, 1);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(fp.collisionDist, 0, distRange);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(fp.debugShowCollisions);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(fp.debugCollisionDist);

	OFX_REMOTEUI_SERVER_SET_NEW_COLOR();
	OFX_REMOTEUI_SERVER_SHARE_PARAM(fp.cohesionF, 0, 1);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(fp.cohesionDist, 0, distRange);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(fp.debugShowCohesion);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(fp.debugCohesionDist);

	OFX_REMOTEUI_SERVER_SET_NEW_COLOR();
	OFX_REMOTEUI_SERVER_SHARE_PARAM(fp.centerismF, 0, 1);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(fp.centerRadius, 50, 300);

	OFX_REMOTEUI_SERVER_SET_NEW_COLOR();
	OFX_REMOTEUI_SERVER_SHARE_PARAM(fp.maxSpeedMagnitude, 0, 300);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(fp.accelerationF, 0, 150);
	OFX_REMOTEUI_SERVER_SHARE_PARAM(fp.mediumFriction, 0.5, 1);
	OFX_REMOTEUI_SERVER_SET_NEW_COLOR();
	OFX_REMOTEUI_SERVER_SHARE_PARAM(fp.rethinkTime, 0, 0.4);

	OFX_REMOTEUI_SERVER_SET_NEW_COLOR();
	OFX_REMOTEUI_SERVER_SHARE_PARAM(fp.debugShowDirection);

	flock->setup();

	OFX_REMOTEUI_SERVER_LOAD_FROM_XML();


	light.enable();
	light.setPointLight();
	TIME_SAMPLE_SET_FRAMERATE(60);
	//ofEnableSmoothing();
	//cam.setDrag(0.98);

}
Ejemplo n.º 3
0
//--------------------------------------------------------------
void testApp::setup(){

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

	//set some default values for your params (optional)
	drawOutlines = false;
	currentSentence = "unInited";
	x = y = 66;
	numCircles = 30;
	menu = MENU_OPTION_1;

	// START THE SERVER ///////////////////////////////////////////
	OFX_REMOTEUI_SERVER_SETUP(10000); 	//specify a port if you want a specific one
										//if you dont specify, the server will choose a random one
										//the first time you launch it, and will use it forever

	// SETUP A CALLBACK ///////////////////////////////////////////
	OFX_REMOTEUI_SERVER_GET_INSTANCE()->setCallback(testApp::serverCallback); // (optional!)

	// SET PARAM GROUPS / COLORS //////////////////////////////////
	OFX_REMOTEUI_SERVER_SET_NEW_COLOR(); // set a bg color for all the upcoming params (optional)
	OFX_REMOTEUI_SERVER_SET_UPCOMING_PARAM_GROUP("position"); //make a new group (optional)

	// SHARE A FLOAT PARAM ////////////////////////////////////////
	OFX_REMOTEUI_SERVER_SHARE_PARAM(x, 0, ofGetWidth() ); //add an "x" float param to the current group ("position")
	OFX_REMOTEUI_SERVER_SHARE_PARAM(y, 0, ofGetHeight()); //provide a variable, a rangeMin and a rangeMax

	OFX_REMOTEUI_SERVER_SET_UPCOMING_PARAM_GROUP("style"); //make a new group (optional)
	OFX_REMOTEUI_SERVER_SET_NEW_COLOR(); // set a bg color for the upcoming params (optional)

	// SHARE A BOOL PARAM ////////////////////////////////////////
	OFX_REMOTEUI_SERVER_SHARE_PARAM(drawOutlines);

	// SHARE A FLOAT PARAM ////////////////////////////////////////
	OFX_REMOTEUI_SERVER_SHARE_PARAM(numCircles, 0, 30);	//variable, rangeMin, rangeMax

	OFX_REMOTEUI_SERVER_SET_UPCOMING_PARAM_GROUP("whatever"); //make a new group
	OFX_REMOTEUI_SERVER_SET_UPCOMING_PARAM_COLOR( ofColor(255,0,0,64) ); // you can set a custom upcoming color too

	// SHARE AN STRING PARAM //////////////////////////////////////
	OFX_REMOTEUI_SERVER_SHARE_PARAM(currentSentence, ofColor(0,0,255,64));	// you can also set a color on a per-param basis

	// SHARE A FLOAT //////////////////////////////////////
	OFX_REMOTEUI_SERVER_SHARE_PARAM(currentMouseX, 0, ofGetWidth(), ofColor(255,64));

	// SHARE AN ENUM PARAM //////////////////////////////////////
	vector<string> menuItems;
	menuItems.push_back("MENU_OPTION_0");menuItems.push_back("MENU_OPTION_1");
	menuItems.push_back("MENU_OPTION_2"); menuItems.push_back("MENU_OPTION_3");
	OFX_REMOTEUI_SERVER_SHARE_ENUM_PARAM(menu, MENU_OPTION_0, MENU_OPTION_3, menuItems);

	// SHARE A COLOR PARAM //////////////////////////////////////
	OFX_REMOTEUI_SERVER_SHARE_COLOR_PARAM(color);


	OFX_REMOTEUI_SERVER_LOAD_FROM_XML();	//load values from XML, if you want to do so
											//this will result on the UI showing the params
											//as they were when last saved (on quit in this case)


	//OFX_REMOTEUI_SERVER_START_THREADED();   //if you want all the communication to happen on a different
											//thread, call this. This has implications though.
											//your params can be changed at anytime by the client,
											//potentially leading to problems. String params are
											//especially very likely to cause crashes!
											//so don't use this unless you know you need it!
}