コード例 #1
0
ファイル: aMain.cpp プロジェクト: arifsetiawan/htrviewer
void RenderSceneAnim()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// increment frame
	frame++;
	time=glutGet(GLUT_ELAPSED_TIME);
	if (time - timebase > ((int)1000/htr.NumFPS())) 
	{
		/*
		sprintf(s,"FPS:%4.2f",frame*1000.0/(time-timebase));
		timebase = time;		
		frame = 0;
		*/
		cframe = cframe + 1;
		if(cframe == htr.NumFrames())
			cframe = 0;

		timebase = time;
	}

	// display something on view
	glColor3f(0.0f,1.0f, 0.0f);
	SetOrthographicProjection();
	glPushMatrix();
	glLoadIdentity();
	RenderBitmapString(10,15,(void *)font,"HTR Mocap Data Viewer"); 
	RenderBitmapString(10,35,(void *)font,"Loaded Animation Data");
	glPopMatrix();
	ResetPerspectiveProjection();
	

	glutPostRedisplay();
//	glutSwapBuffers();
}
コード例 #2
0
ファイル: aMain.cpp プロジェクト: arifsetiawan/htrviewer
void RenderScene(void) 
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	/*
	glPushMatrix();
		glColor3f(0.0f,0.0f, 0.0f);
		glutSolidCube(0.02);		
		
		glTranslatef(-0.5*2, 0.0, -0.5*2);
		glutSolidCube(0.02);
		
		glTranslatef(1.0*2, 0.0, 0.0);
		glutSolidCube(0.02);
		
		glTranslatef(0.0, 0.0, 1.0*2);
		glutSolidCube(0.02);
		
		glTranslatef(-1.0*2, 0.0, 0.0);
		glutSolidCube(0.02);
	glPopMatrix();

	glPushMatrix();
		glColor3f(0.0f,0.0f, 0.0f);
		glTranslatef(0.0, 2.0, 0.0);
		glutSolidCube(0.02);		
		
		glTranslatef(-0.5*2, 0.0, -0.5*2);
		glutSolidCube(0.02);
		
		glTranslatef(1.0*2, 0.0, 0.0);
		glutSolidCube(0.02);
		
		glTranslatef(0.0, 0.0, 1.0*2);
		glutSolidCube(0.02);
		
		glTranslatef(-1.0*2, 0.0, 0.0);
		glutSolidCube(0.02);
	glPopMatrix();
	*/

	printf("Current Frame to draw %d\n", cframe);
	htr.DrawFrame(cframe);

	// display something on view
	glColor3f(0.0f,1.0f, 0.0f);
	SetOrthographicProjection();
	glPushMatrix();
	glLoadIdentity();
	RenderBitmapString(10,15,(void *)font,"HTR Mocap Data Viewer"); 
	//RenderBitmapString(10,35,(void *)font,"Base Pose Rendering");
	glPopMatrix();
	ResetPerspectiveProjection();
	

	glutSwapBuffers();
}
コード例 #3
0
// main render function called by glut
void OnRender() {
	//Calculate fps
	totalFrames++;
	int current = glutGet(GLUT_ELAPSED_TIME);
	float elapsedTime = float(current - startTime);
	static float lastfpsTime = 0.0f;
	if ((current - lastfpsTime) > 1000.0f)
	{
		fps = ((totalFrames * 1000.0f) / ((current - lastfpsTime)));
		totalFrames = 0;
		lastfpsTime = float(current);
	}
	startTime = current;

	sprintf_s(buffer, "FPS: %3.2f", fps);

	//Update PhysX	
	if (gScene)
	{
		stepPhysics(elapsedTime / 1000.0f);
	}

	// start render
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glLoadIdentity();
	glTranslatef(0, 0, dist);
	glRotatef(rX, 1, 0, 0);
	glRotatef(rY, 0, 1, 0);

	//Draw the grid and axes
	DrawAxes();
	DrawGrid(100);
	// draw physics objects
	glEnable(GL_LIGHTING);
	RenderPhysXScene();
	glDisable(GL_LIGHTING);

	//Show the fps
	SetOrthoForFont(WINDOW_WIDTH, WINDOW_HEIGHT);
	glColor3f(1, 1, 1);
	RenderSpacedBitmapString(20, 20, 0, GLUT_BITMAP_HELVETICA_12, buffer);

	ResetPerspectiveProjection();
	// finish render
	glutSwapBuffers();
}
コード例 #4
0
// main render function called by glut
void OnRender() {
	//Calculate fps
	totalFrames++;
	int current = glutGet(GLUT_ELAPSED_TIME);
	float elapsedTime = float(current - startTime);
	static float lastfpsTime = 0.0f;
	if ((current - lastfpsTime) > 1000.0f)
	{
		fps = ((totalFrames * 1000.0f) / ((current - lastfpsTime)));
		totalFrames = 0;
		lastfpsTime = float(current);
	}
	startTime = current;

	sprintf_s(buffer, "FPS: %3.2f", fps);

	//Update PhysX	
	if (gScene)
	{
		stepPhysics(elapsedTime / 1000.0f);
	}

	// start render
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();

	glTranslatef(0, 0, dist);
	glRotatef(rX, 1, 0, 0);
	glRotatef(rY, 0, 1, 0);
	// shoot
	if (shoot)
	{
		GLdouble matModelView[16], matProjection[16];
		GLdouble camera_pos[3];
		int viewport[4];
		// get matrixs and viewport:
		glGetDoublev(GL_MODELVIEW_MATRIX, matModelView);
		glGetDoublev(GL_PROJECTION_MATRIX, matProjection);
		glGetIntegerv(GL_VIEWPORT, viewport);
		gluUnProject((viewport[2] - viewport[0]) / 2, (viewport[3] - viewport[1]) / 2,
			0.0, matModelView, matProjection, viewport,
			&camera_pos[0], &camera_pos[1], &camera_pos[2]);

		//PxVec3 p(camera_pos[0], camera_pos[1], camera_pos[2]);
		//AddBullet(p, -p.getNormalized() * 10.0f);
		shoot = false;

		//
		//GLdouble mpos[3];
		//gluUnProject(oldX, oldY, 0,
		//	matModelView,
		//	matProjection, viewport, &mpos[0], &mpos[1], &mpos[2]);
		GLfloat winX, winY, winZ; //variables to hold screen x,y,z coordinates
		GLdouble worldX, worldY, worldZ; //variables to hold world x,y,z coordinates

		winX = (float)(viewport[2] - viewport[0]) / 2;
		winY = (float)(viewport[3] - viewport[1]) / 2;
		glReadPixels(winX, winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ);


		//get the world coordinates from the screen coordinates
		gluUnProject(winX, winY, 0.0, matModelView, matProjection
			, viewport, &worldX, &worldY, &worldZ);
		GLdouble fx, fy, fz;
		gluUnProject(winX, winY, 1.0, matModelView, matProjection
			, viewport, &fx, &fy, &fz);

		PxVec3 pp(worldX, worldY, worldZ);
		PxVec3 vv(fx - worldX, fy - worldY, fz - worldZ);
		AddBullet(pp, vv.getNormalized() * 10.0f);
	}
	//Draw the grid and axes
	DrawAxes();
	DrawGrid(100);
	// draw physics objects
	glEnable(GL_LIGHTING);
	RenderPhysXScene();
	glDisable(GL_LIGHTING);

	//Show the fps
	SetOrthoForFont(WINDOW_WIDTH, WINDOW_HEIGHT);
	glColor3f(1, 1, 1);
	RenderSpacedBitmapString(20, 20, 0, GLUT_BITMAP_HELVETICA_12, buffer);

	ResetPerspectiveProjection();
	// finish render
	glutSwapBuffers();
}