Ejemplo n.º 1
0
int main( ){
	ofSetupOpenGL( 800, 600, OF_WINDOW);	// <-------- setup the GL context

	TIME_SAMPLE_SET_FRAMERATE(60);	//if you want setup() to get automaticall measured,
									//you need to create the instance once before setup() is called;
									//just call any TIME_SAMPLE_* method to do so

	ofRunApp(new testApp());
}
Ejemplo n.º 2
0
//--------------------------------------------------------------
void ofApp::setup(){
    
    ofBackground(22);
    ofSetFrameRate(60);
    ofEnableSmoothing();
    ofEnableAlphaBlending();
    ofSetVerticalSync(true);
#ifdef TIME_SAMPLE
    TIME_SAMPLE_SET_FRAMERATE(60);
    TIME_SAMPLE_SET_PRECISION(3);
    TIME_SAMPLE_SET_AVERAGE_RATE(0.01);
    TIME_SAMPLE_SET_DRAW_LOCATION(TIME_MEASUREMENTS_BOTTOM_RIGHT);
    TIME_SAMPLE_DISABLE();
#endif
    width = 10;
    
    
    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 );
    }
    
    ball.reset(floorLine - 100);
    ball.setCurve(EASE_IN);
    ball.setRepeatType(LOOP_BACK_AND_FORTH);
    ball.setDuration(0.55);
    ball.animateTo( floorLine );
    
    colorAnim.setColor( ofColor::black );
    colorAnim.setDuration( 0.5f );
    colorAnim.setRepeatType(LOOP_BACK_AND_FORTH);
    colorAnim.setCurve(LINEAR);
    colorAnim.animateTo( ofColor::white );
    
    pointAnim.setDuration(0.3);
    pointAnim.setPosition( ofPoint(100,100) );
    pointAnim.setRepeatType(PLAY_N_TIMES);
    pointAnim.setCurve(QUADRATIC_EASE_OUT);
    pointAnim.setRepeatTimes(3);
    //pointAnim.setAutoFlipCurve(true);
    
}
Ejemplo n.º 3
0
//--------------------------------------------------------------
void ofApp::setup(){
    ofLogToFile("log.txt", true);
    //ofSetLogLevel(OF_LOG_VERBOSE);

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

    TIME_SAMPLE_SET_FRAMERATE(60);
    // TIME_SAMPLE_ENABLE();

    // setup ofxRemoteUI
    RUI_SETUP();
    RUI_SET_CALLBACK(ruiServerCallback);
    // TODO: setup params here
    RUI_NEW_GROUP("App");
    RUI_DEFINE_VAR_WV(bool, "app-fullscreen", false);
    RUI_LOAD_FROM_XML();
}
Ejemplo n.º 4
0
//--------------------------------------------------------------
void testApp::setup(){
	ofSetVerticalSync(true);
	
	cam.initGrabber(640, 480);
	fbo.allocate(WIDTH, HEIGHT, GL_RGBA);
	image.allocate(WIDTH, HEIGHT, OF_IMAGE_COLOR_ALPHA);
	
	glGenBuffersARB(2, pboIds);
	glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[0]);
	glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, WIDTH * HEIGHT * 4, NULL, GL_STREAM_READ_ARB);
	glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[1]);
	glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, WIDTH * HEIGHT * 4, NULL, GL_STREAM_READ_ARB);	
	glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);
	
	index = 0;
	nextIndex = 0;
	
	TIME_SAMPLE_SET_FRAMERATE(60);
}
Ejemplo n.º 5
0
//========================================================================
int main( ){
	ofAppGLFWWindow win;
	win.setNumSamples(0);
	//win.setOrientation(OF_ORIENTATION_90_LEFT);
	//win.setMultiDisplayFullscreen(true);
	//win.set

	ofSetupOpenGL(&win, 1800,400, OF_WINDOW);	// <-------- setup the GL context

	TIME_SAMPLE_SET_FRAMERATE(60);
	TIME_SAMPLE_DISABLE_AVERAGE();
	TIME_SAMPLE_SET_DRAW_LOCATION(TIME_MEASUREMENTS_TOP_RIGHT);

	// this kicks off the running of my app
	// can be OF_WINDOW or OF_FULLSCREEN
	// pass in width and height too:
	ofRunApp(new testApp());

}
Ejemplo n.º 6
0
void testApp::setup(){

	ofBackground(22);

	TIME_SAMPLE_SET_FRAMERATE( 60.0f ); //set the app's target framerate (MANDATORY)

	//specify where the widget is to be drawn
	TIME_SAMPLE_SET_DRAW_LOCATION( TIME_MEASUREMENTS_TOP_RIGHT ); //specify a drawing location (OPTIONAL)


	TIME_SAMPLE_SET_AVERAGE_RATE(0.1);	//averaging samples, (0..1],
										//1.0 gets you no averaging at all
										//use lower values to get steadier readings
	TIME_SAMPLE_DISABLE_AVERAGE();	//disable averaging

	TIME_SAMPLE_SET_REMOVE_EXPIRED_THREADS(true); //inactive threads will be dropped from the table
	//customize color
	//TIME_SAMPLE_GET_INSTANCE()->setHighlightColor(ofColor::yellow);

	startThread();

}
Ejemplo n.º 7
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.º 8
0
void ShapeApp::setup() {

	// setup kinect
//=============================================================================
	kinect.setRegistration(true);
	kinect.init();
	if (kinect.open()) {
		kinect_on = true;
	} else {
		kinect_on = false;
	}

	while (!kinect.isConnected());

	ofSetFrameRate(30);
	TIME_SAMPLE_SET_FRAMERATE(30.0f);

	// setup UI
//=============================================================================
	setupUI();

	// setup tracking data objects
//=============================================================================
	// CPU
	curr_f.init(DEPTH_X_RES, DEPTH_Y_RES);
	curr_f.allocateHost();

	new_f.init(DEPTH_X_RES, DEPTH_Y_RES);
	new_f.allocateHost();

	est_f.init(DEPTH_X_RES, DEPTH_Y_RES);
	est_f.allocateHost();

	view_f.init(DEPTH_X_RES, DEPTH_Y_RES);
	view_f.allocateHost();

	image.allocate(DEPTH_X_RES, DEPTH_Y_RES, OF_IMAGE_COLOR);
	view_image.allocate(DEPTH_X_RES, DEPTH_Y_RES, OF_IMAGE_COLOR);
	est_image.allocate(DEPTH_X_RES, DEPTH_Y_RES, OF_IMAGE_COLOR);

	// GPU
	curr_f.allocateDevice();
	new_f.allocateDevice();
	est_f.allocateDevice();
	view_f.allocateDevice();

	// data for ICP
//=============================================================================
	// GPU
	corresp.blocks_x =
			divUp(DEPTH_X_RES, CORRESPONDENCE_BLOCK_X);
	corresp.blocks_y =
			divUp(DEPTH_Y_RES, CORRESPONDENCE_BLOCK_Y);
	corresp.blocks_n = corresp.blocks_x * corresp.blocks_y;
	corresp.AtA_dev_size = AtA_SIZE * corresp.blocks_n;
	corresp.Atb_dev_size = Atb_SIZE * corresp.blocks_n;

	cudaMalloc((void **) &corresp.AtA_dev,
			corresp.AtA_dev_size * sizeof(float));
	cudaMalloc((void **) &corresp.Atb_dev,
			corresp.Atb_dev_size * sizeof(float));

	cudaMalloc((void **) &corresp.points_dev, curr_f.host.points_bn);

	// CPU
	corresp.AtA_host = (float *)malloc(corresp.AtA_dev_size * sizeof(float));
	corresp.Atb_host = (float *)malloc(corresp.Atb_dev_size * sizeof(float));

	corresp.AtA_sum = (float *)malloc(AtA_SIZE * sizeof(float));
	corresp.Atb_sum = (float *)malloc(Atb_SIZE * sizeof(float));

	correspondence_host = (float *) malloc(curr_f.host.points_bn);
	correspondence_dev = (float *) malloc(curr_f.host.points_bn);
	corresp.points_host = (float *)malloc(curr_f.host.points_bn);

	// voxel data
//=============================================================================
	// CPU
	min.set(-0.5, -0.5, -1.5);
	max.set(0.5, 0.5, -0.5);

	voxels.min = min;
	voxels.side_n = 256;
	voxels.size = (max - min) / (float)voxels.side_n;

	voxels.array_size = voxels.side_n * voxels.side_n * voxels.side_n;
	voxels.bytes_n = sizeof(float) * voxels.array_size;
	voxels.data = (float *)malloc(voxels.bytes_n);

	voxels.w_bytes_n = sizeof(unsigned char) * voxels.array_size;
	voxels.w_data = (unsigned char *)malloc(voxels.w_bytes_n);

	// GPU
	cudaMalloc((void **) &camera_opt.t, sizeof(float) * 16);
	cudaMalloc((void **) &camera_opt.it, sizeof(float) * 16);
	camera_opt.ref_pix_size = kinect.getRefPixelSize();
	camera_opt.ref_distance = kinect.getRefDistance();
	setFloat3(camera_opt.min, min);
	setFloat3(camera_opt.max, max);

	cudaMalloc((void **) &dev_voxels.data, voxels.bytes_n);
	cudaMalloc((void **) &dev_voxels.w_data, voxels.w_bytes_n);
	setFloat3(&dev_voxels.min, voxels.min);
	setFloat3(&dev_voxels.size, voxels.size);

	dev_voxels.side_n = voxels.side_n;
	dev_voxels.side_n2 = dev_voxels.side_n * dev_voxels.side_n;
	dev_voxels.array_size = voxels.array_size;
	dev_voxels.bytes_n = voxels.bytes_n;
	dev_voxels.w_bytes_n = voxels.w_bytes_n;

	resetVoxels();
}