Exemple #1
0
void reshape(int w, int h)
{	

	image_width  = w;
	image_height = h;

#if defined(_GL_CONVOLUTION) && defined(__PBUFFER__)
	pbf_makeCurrent(pbuffer);
#endif

	glViewport (0, 0, w, h);
	camera.reshape (w, h);
	object.reshape (w, h);


	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	if (viewer.view_info.type == PARALLEL){
		glOrtho(viewer.view_info.left, viewer.view_info.right, viewer.view_info.bottom, viewer.view_info.top, 
			viewer.view_info.hither, viewer.view_info.yon );
	}
	else{ // perspective
		float aspect = viewer.view_info.aspect_ratio * float(w)/float(h);
		float real_fov;
		if ( aspect < 1 ){
		  // fovy is a misnomer.. we really mean the fov applies to the
		  // smaller dimension
		  float fovx, fovy; 
		  fovx = fovy = viewer.view_info.view_angle; 
		  real_fov = to_degrees(2 * atan(tan(to_radians(fovx/2))/aspect));
		}
		else{
			real_fov = viewer.view_info.view_angle;
		}

		gluPerspective(real_fov, 
					   aspect,
					   viewer.view_info.hither,
					   viewer.view_info.yon);

	}
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

#if defined(_GL_CONVOLUTION) && defined(__PBUFFER__)
	pbf_makeGlutWindowCurrent(pbuffer);
#endif

#if defined(_GL_CONVOLUTION) && defined(__PBUFFER__)
	// set GL parameters for on-screen frame buffer
	glViewport (0, 0, w, h);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(-1, 1, -1, 1, -1, 1);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
#endif
}
Exemple #2
0
int main(int argc, char **argv)
{
	if (argc!=2){
		printf("%s <input_file\n", argv[0]);
		exit(1);
	}

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);

	loadVolume(argv[1]);
	image_width  = viewer.viewport.Width();
	image_height = viewer.viewport.Height();

	glutInitWindowSize(image_width, image_height); 
	glutCreateWindow("Texture splat");
	glutInitWindowPosition(200, 200);

	initGL();

	initSortedLists();

#if !defined(_GL_CONVOLUTION)
	initSplatTexture();
#endif
	// initilize glut helper
    glut_helpers_initialize();

	cb.keyboard_function = key;
	camera.configure_buttons(1);
	camera.set_camera_mode(true);
	camera.pan.pan = vec3f( 0.0, 0.0, viewer.view_info.eye[2]); 
	object.configure_buttons(1);

	object.dolly.dolly[0] = 0;
	object.dolly.dolly[1] = 0;
	object.dolly.dolly[2] = 0;

	glut_add_interactor(&cb);
	glut_add_interactor(&object);

	glutDisplayFunc(display);
	glutReshapeFunc(reshape);
	glutKeyboardFunc(key);

	glutMainLoop();

	return 0;
}
int main(int argc, char **argv)
{
	sender.setup(HOST, PORT);
	
	XnStatus rc = XN_STATUS_OK;

	rc = g_Context.InitFromXmlFile(SAMPLE_XML_PATH);
	CHECK_RC(rc, "InitFromXml");

	rc = g_Context.FindExistingNode(XN_NODE_TYPE_DEPTH, g_DepthGenerator);
	CHECK_RC(rc, "Find depth generator");
	rc = g_Context.FindExistingNode(XN_NODE_TYPE_USER, g_UserGenerator);
	CHECK_RC(rc, "Find user generator");

	XnCallbackHandle h;

	g_UserGenerator.RegisterUserCallbacks(NewUser, LostUser, NULL, h);
	g_UserGenerator.GetSkeletonCap().SetSkeletonProfile(XN_SKEL_PROFILE_ALL);

	XnCallbackHandle hCalib;
	XnCallbackHandle hPose;
	g_UserGenerator.GetSkeletonCap().RegisterCalibrationCallbacks(&CalibrationStart, &CalibrationEnd, NULL, hCalib);
	g_UserGenerator.GetPoseDetectionCap().RegisterToPoseCallbacks(&PoseDetected, NULL, NULL, hPose);

	rc = g_Context.StartGeneratingAll();
	CHECK_RC(rc, "StartGenerating");

	xn::DepthMetaData depthMD;
	g_DepthGenerator.GetMetaData(depthMD);

	fXRes = depthMD.XRes();
	fYRes = depthMD.YRes();
	fMaxDepth = depthMD.ZRes();
	
	nCutOffMin = 0;
	nCutOffMax = fMaxDepth;

	nPointerX = fXRes / 2;
	nPointerY = fXRes / 2;
	nPointerDiffX = (WIN_SIZE_X / fXRes / 2) + 1;
	nPointerDiffY = (WIN_SIZE_Y / fXRes / 2) + 1;

	if (argc == 2)
	{
		nCutOffMax = atol(argv[1]);
	}

	srand(XnUInt32(time(NULL)));

	glutInit(&argc, argv);
	glutInitDisplayString("stencil depth>16 double rgb samples=0");
    glutInitWindowSize(WIN_SIZE_X, WIN_SIZE_Y);
	glutCreateWindow("Prime Sense Stick Figure Sample");
	glutSetCursor(GLUT_CURSOR_NONE);

	init_opengl();

	glut_helpers_initialize();

	cb.passive_motion_function = MotionCallback;
	cb.keyboard_function = key;

	camera.configure_buttons(0);
	camera.set_camera_mode(true);
	camera.set_parent_rotation( & camera.trackball.r);
	camera.enable();

	object.configure_buttons(1);
	object.translator.t[2] = -1;
	object.translator.scale *= .1f;
	object.trackball.r = rotationf(vec3f(2.0,0.01,0.01), to_radians(180));
	object.set_parent_rotation( & camera.trackball.r);
	object.disable();

	light.configure_buttons(0);
	light.translator.t = vec3f(.5, .5, -1);
	light.set_parent_rotation( & camera.trackball.r);
	light.disable();

	reshaper.zNear = 1;
	reshaper.zFar = 100;

    // make sure all interactors get glut events
	glut_add_interactor(&cb);
	glut_add_interactor(&camera);
	glut_add_interactor(&reshaper);
	glut_add_interactor(&light);
	glut_add_interactor(&object);

	camera.translator.t = vec3f(0, 0, 0);
	camera.trackball.r = rotationf(vec3f(0, 0, 0), to_radians(0));

	light.translator.t = vec3f (0, 1.13, -2.41);
	light.trackball.r = rotationf(vec3f(0.6038, -0.1955, -0.4391), to_radians(102));

	glutIdleFunc(idle);
	glutDisplayFunc(display);
	// Per frame code is in display
	glutMainLoop();


	return (0);
}
int main(int argc, char **argv)
{
	XnBool bChooseDevice = false;
	const char* csRecordingName = NULL;

	if (argc > 1)
	{
		if (strcmp(argv[1], "-devices") == 0)
		{
			bChooseDevice = TRUE;
		}
		else
		{
			csRecordingName = argv[1];
		}
	}

	if (csRecordingName != NULL)
	{	
		// check if running from a different directory. If so, we need to change directory
		// to the real one, so that path to INI file will be OK (for log initialization, for example)
		if (0 != changeDirectory(argv[0]))
		{
			return(ERR_DEVICE);
		}
	}

	// Xiron Init
	XnStatus rc = XN_STATUS_OK;
	EnumerationErrors errors;

	if (csRecordingName != NULL)
	{	
		xnLogInitFromXmlFile(SAMPLE_XML_PATH);
		rc = openDeviceFile(argv[1]);
	}
	else if (bChooseDevice)
	{
		rc = openDeviceFromXmlWithChoice(SAMPLE_XML_PATH, errors);
	}
	else
	{
		rc = openDeviceFromXml(SAMPLE_XML_PATH, errors);
	}

	if (rc == XN_STATUS_NO_NODE_PRESENT)
	{
		XnChar strError[1024];
		errors.ToString(strError, 1024);
		printf("%s\n", strError);
		closeSample(ERR_DEVICE);
		return (rc);
	}
	else if (rc != XN_STATUS_OK)
	{
		printf("Open failed: %s\n", xnGetStatusString(rc));
		closeSample(ERR_DEVICE);
	}

	audioInit();
	captureInit();
	statisticsInit();

	reshaper.zNear = 1;
	reshaper.zFar = 100;
	glut_add_interactor(&reshaper);

	cb.mouse_function = MouseCallback;
	cb.motion_function = MotionCallback;
	cb.passive_motion_function = MotionCallback;
	cb.keyboard_function = KeyboardCallback;
	cb.reshape_function = ReshapeCallback;
	glut_add_interactor(&cb);

	glutInit(&argc, argv);
	glutInitDisplayString("stencil double rgb");
	glutInitWindowSize(WIN_SIZE_X, WIN_SIZE_Y);
	glutCreateWindow("OpenNI Viewer");
	glutFullScreen();
	glutSetCursor(GLUT_CURSOR_NONE);

	init_opengl();

	glut_helpers_initialize();

	camera.configure_buttons(0);
	camera.set_camera_mode(true);
	camera.set_parent_rotation( & camera.trackball.r);
	camera.enable();

	object.configure_buttons(1);
	object.translator.t[2] = -1;
	object.translator.scale *= .1f;
	object.trackball.r = rotationf(vec3f(2.0,0.01,0.01), to_radians(180));
	object.set_parent_rotation( & camera.trackball.r);
	object.disable();

	light.configure_buttons(0);
	light.translator.t = vec3f(.5, .5, -1);
	light.set_parent_rotation( & camera.trackball.r);
	light.disable();

	// make sure all interactors get glut events
	glut_add_interactor(&camera);
	glut_add_interactor(&light);
	glut_add_interactor(&object);

	camera.translator.t = vec3f(0, 0, 0);
	camera.trackball.r = rotationf(vec3f(0, 0, 0), to_radians(0));

	light.translator.t = vec3f (0, 1.13, -2.41);
	light.trackball.r = rotationf(vec3f(0.6038, -0.1955, -0.4391), to_radians(102));

	glutIdleFunc(IdleCallback);
	glutDisplayFunc(drawFrame);

	drawInit();
	createKeyboardMap();
	createMenu();

	atexit(onExit);
	
	// Per frame code is in drawFrame()
	glutMainLoop();

	audioShutdown();

	closeSample(ERR_OK);

	return (ERR_OK);
}
Exemple #5
0
void display(void)
{	

#if defined(_GL_CONVOLUTION) && defined(__PBUFFER__)
	pbf_makeCurrent(pbuffer);
#endif

	// set new model view and projection matrix
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	camera.apply_inverse_transform();
	object.apply_transform();

	glRotatef(1, 1, 0, 0);
	glRotatef(1, 0, 1, 0);

	list_order = GetListOrder();
// for snapshot
/*
	{

		// for hipip
		GLdouble m[16];
		glGetDoublev(GL_MODELVIEW_MATRIX, m);
		printf("m[0]=%10f; m[4]=%10f; m[8]=%10f; m[12]=%10f;\n", m[0], m[4], m[8], m[12]);
		printf("m[1]=%10f; m[5]=%10f; m[9]=%10f; m[13]=%10f;\n", m[1], m[5], m[9], m[13]);
		printf("m[2]=%10f; m[6]=%10f; m[10]=%10f; m[14]=%10f;\n", m[2], m[6], m[10], m[14]);
		printf("m[3]=%10f; m[7]=%10f; m[11]=%10f; m[15]=%10f;\n", m[3], m[7], m[11], m[15]);


		m[0]=  0.050937; m[4]=  0.942415; m[8]= -0.330544; m[12]=  0.000000;
		m[1]=  0.207775; m[5]= -0.333731; m[9]= -0.919485; m[13]=  0.000000;
		m[2]= -0.976849; m[6]= -0.021843; m[10]= -0.212810; m[14]= -5.000000;
		m[3]=  0.000000; m[7]=  0.000000; m[11]=  0.000000; m[15]=  1.000000;

		glLoadMatrixd(m);
		list_order = 5;

	}
*/
#if defined(_GL_CONVOLUTION) && defined(__PBUFFER__)
	pbf_makeGlutWindowCurrent(pbuffer);
#endif


	htimer.Mark();

#ifdef __VERTEX_PROGRAM__ // with nVidia vertex program
		// Enable the vertex program.

#	if defined(_GL_CONVOLUTION) && defined(__PBUFFER__)
	pbf_makeCurrent(pbuffer);
#	endif

		glEnable( GL_VERTEX_PROGRAM_NV );
		glBindProgramNV( GL_VERTEX_PROGRAM_NV, vpid );
		glExecuteProgramNV(GL_VERTEX_STATE_PROGRAM_NV, vspid, NULL_DATA);

#	ifdef _GL_CONVOLUTION
	pbf_makeGlutWindowCurrent(pbuffer);
#	endif


#	if defined( _GL_DISPLAYLIST )
		viewer.RealizeList_NV();

#	elif defined( _GL_IMMEDIATE )
		viewer.RealizeImm_NV();

#	elif defined( _GL_VERTEXSTREAM )
		viewer.RealizeStream_NV();

#	else // _GL_CONVOLUTION
		viewer.RealizeConvolution_NV();
#	endif

#	if defined(_GL_CONVOLUTION) && defined(__PBUFFER__)
		glDisable( GL_VERTEX_PROGRAM_NV );
#	endif

#else // no nVidia vertex program


#	if defined( _GL_DISPLAYLIST )
		viewer.RealizeList();

#	elif defined( _GL_IMMEDIATE )
		viewer.RealizeImm();

#	elif defined( _GL_VERTEXSTREAM )
		viewer.RealizeStream();

#	else // _GL_CONVOLUTION
		viewer.RealizeConvolution();
#	endif

#endif // __VERTEX_PROGRAM__


		LARGE_INTEGER timing = htimer.Elapse_us();

		cout << "micro sec: " << timing.LowPart <<endl;
}