示例#1
0
void FractureDemo::showMessage()
{
	if((getDebugMode() & btIDebugDraw::DBG_DrawText))
	{
		setOrthographicProjection();
		glDisable(GL_LIGHTING);
		glColor3f(0, 0, 0);
		char buf[124];

		int lineWidth=380;
		int xStart = m_glutScreenWidth - lineWidth;
		int yStart = 20;

		btFractureDynamicsWorld* world = (btFractureDynamicsWorld*)m_dynamicsWorld;
		if (world->getFractureMode())
		{
			sprintf(buf,"Fracture mode");
		} else
		{
			sprintf(buf,"Glue mode");
		}
		GLDebugDrawString(xStart,yStart,buf);
		sprintf(buf,"f to toggle fracture/glue mode");		
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);
		sprintf(buf,"space to restart, mouse to pick/shoot");
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);

		resetPerspectiveProjection();
		glEnable(GL_LIGHTING);
	}

}
示例#2
0
void Screens::Render()
{
    setOrthographicProjection();
    glColor3f (1.0, 1.0, 1.0);
    writeString("lives remaining: ", 100, 100, GLUT_BITMAP_TIMES_ROMAN_24);
    resetPerspectiveProjection();
}
示例#3
0
//to be implemented by the demo
void ForkLiftDemo::renderme()
{
	
	updateCamera();

	btScalar m[16];
	int i;

	btVector3 wheelColor(1,0,0);

	btVector3	worldBoundsMin,worldBoundsMax;
	getDynamicsWorld()->getBroadphase()->getBroadphaseAabb(worldBoundsMin,worldBoundsMax);



	for (i=0;i<m_vehicle->getNumWheels();i++)
	{
		//synchronize the wheels with the (interpolated) chassis worldtransform
		m_vehicle->updateWheelTransform(i,true);
		//draw wheels (cylinders)
		m_vehicle->getWheelInfo(i).m_worldTransform.getOpenGLMatrix(m);
		m_shapeDrawer->drawOpenGL(m,m_wheelShape,wheelColor,getDebugMode(),worldBoundsMin,worldBoundsMax);
	}


	int lineWidth=250;
	int xStart = m_glutScreenWidth - lineWidth;
	int yStart = 20;

	if((getDebugMode() & btIDebugDraw::DBG_NoHelpText)==0)
	{
		setOrthographicProjection();
		glDisable(GL_LIGHTING);
		glColor3f(0, 0, 0);
		char buf[124];
		
		glRasterPos3f(xStart, yStart, 0);
		sprintf(buf,"SHIFT+Cursor Left/Right - rotate lift");
		GLDebugDrawString(xStart,20,buf);
		yStart+=20;
		glRasterPos3f(xStart, yStart, 0);
		sprintf(buf,"SHIFT+Cursor UP/Down - move fork up/down");
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);
		glRasterPos3f(xStart, yStart, 0);
		sprintf(buf,"F5 - toggle camera mode");
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);
		glRasterPos3f(xStart, yStart, 0);
        sprintf(buf,"Click inside this window for keyboard focus");
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);


		resetPerspectiveProjection();
		glEnable(GL_LIGHTING);
	}
	DemoApplication::renderme();
}
示例#4
0
void renderScene2(int currentWindow)
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glPushMatrix();
	glColor3f(1.0, 0.0, 0.0);
	glTranslatef(x, y, z);
	glRotatef(180 - angle*180.0 / 3.14, 0.0, 1.0, 0.0);
	glutSolidCone(0.2, 0.8f, 4, 4);
	glPopMatrix();

	// Draw ground
	glColor3f(0.9f, 0.9f, 0.9f);
	glBegin(GL_QUADS);
	glVertex3f(-100.0f, 0.0f, -100.0f);
	glVertex3f(-100.0f, 0.0f, 100.0f);
	glVertex3f(100.0f, 0.0f, 100.0f);
	glVertex3f(100.0f, 0.0f, -100.0f);
	glEnd();

	// Draw 36 SnowMen
	// call the function that contains the rendering commands
	for (int i = -3; i < 3; i++)
	{
		for (int j = -3; j < 3; j++)
		{
			glPushMatrix();
			glTranslatef(i*10.0, 0, j*10.0);
			drawSnowMan();
			glPopMatrix();
		}
	}

	if (currentWindow == subWindow1)
	{
		frame++;
		time = glutGet(GLUT_ELAPSED_TIME);
		if (time - timebase > 1000) {
			sprintf(s, "FPS: %4.2f", frame*1000.0 / (time - timebase));
			timebase = time;
			frame = 0;
		}

		glColor3f(0.0, 1.0, 1.0);
		setOrthographicProjection();
		glPushMatrix();
		glLoadIdentity();
		renderBitmapString(30, 15, (void *)font, "IPCA - EDJG - P3D");
		renderBitmapString(30, 35, (void *)font, s);
		renderBitmapString(30, 55, (void *)font, "Esc - Quit");
		glPopMatrix();
		resetPerspectiveProjection();
	}

	glutSwapBuffers();
}
示例#5
0
void CcdPhysicsDemo::displayText()
{
#ifndef __QNX__
	int lineWidth=440;
	int xStart = m_glutScreenWidth - lineWidth;
	int yStart = 20;

	if((getDebugMode() & btIDebugDraw::DBG_DrawText)!=0)
	{
		setOrthographicProjection();
		glDisable(GL_LIGHTING);
		glColor3f(0, 0, 0);
		char buf[124];
		
		glRasterPos3f(xStart, yStart, 0);
		switch (m_ccdMode)
		{
		case USE_CCD:
			{
				sprintf(buf,"Predictive contacts and motion clamping");
				break;
			}
		case USE_NO_CCD:
			{
				sprintf(buf,"CCD handling disabled");
				break;
			}
		default:
			{
				sprintf(buf,"unknown CCD setting");
			};
		};

		GLDebugDrawString(xStart,20,buf);
		glRasterPos3f(xStart, yStart, 0);
		sprintf(buf,"Press 'p' to change CCD mode");
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);
		glRasterPos3f(xStart, yStart, 0);
		sprintf(buf,"Press '.' or right mouse to shoot bullets");
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);
		glRasterPos3f(xStart, yStart, 0);
		sprintf(buf,"space to restart, h(elp), t(ext), w(ire)");
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);
		
		resetPerspectiveProjection();
		glEnable(GL_LIGHTING);
	}	
#endif
}
示例#6
0
void BasicDemo::renderme()
{
	renderscene(0);
	if(gbDrawBatches)
	{
		((btGpuDemoDynamicsWorld*)m_dynamicsWorld)->debugDrawConstraints(gSelectedBatch, cBatchColorTab);
	}

//	if (0)
	if ((m_debugMode & btIDebugDraw::DBG_NoHelpText)==0)
	{
		setOrthographicProjection();
		int  xOffset = 10.f;
		int  yStart = 20.f;
		int  yIncr = 20.f;
		showProfileInfo(xOffset, yStart, yIncr);
		DrawConstraintInfo();
		outputDebugInfo(xOffset, yStart, yIncr);
		resetPerspectiveProjection();
	}
}
示例#7
0
    void testTextOverlay() {
    
        // text overlay
        glColor3ub(220,220,220);
        setOrthographicProjection(width,height);

        glPushMatrix();
        glLoadIdentity();

        glScalef(1,-1,1);

        font.preDrawString();
        real lineFeed = 0;
        for (unsigned i=0;i<console.size();i++) {
            font.drawString(console[i],0,lineFeed-=font.lineHeight());
        }
        font.posDrawString();

        glPopMatrix();

        resetPerspectiveProjection();
    }
void BasicDemo3D::renderme()
{
	updateCamera();

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	if(gDrawWire)
	{
		glColor3f(1.f, 1.f, 1.f);
		glDisable(GL_LIGHTING);
		setTexturing(false);
	}
	else
	{
		myinit();
		setTexturing(true);
	}
		
	renderscene(0);

	if(gbDrawBatches)
	{
		((btCudaDemoDynamicsWorld3D*)m_dynamicsWorld)->debugDrawConstraints(gSelectedBatch, cBatchColorTab);
	}
	glColor3f(0, 0, 0);
	if ((m_debugMode & btIDebugDraw::DBG_NoHelpText)==0)
	{
		setOrthographicProjection();
		int  xOffset = 10.f;
		int  yStart = 20.f;
		int  yIncr = 20.f;
		showProfileInfo(xOffset, yStart, yIncr);
		DrawConstraintInfo();
		outputDebugInfo(xOffset, yStart, yIncr);
		resetPerspectiveProjection();
	}
}
示例#9
0
void onRender() {
	//Calculate fps
	totalFrames++;
	int current = glutGet(GLUT_ELAPSED_TIME);
	if((current - startTime) > 1000) {
		float elapsedTime = float(current-startTime);
		fps = ((float)(totalFrames * 1000) / elapsedTime) ;
		startTime = current;
		totalFrames=0;
	}

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

	resetPerspectiveProjection();

	// Handle reshaping (preparing NiViewer)
	glViewport(0, 0, nw, nh);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(60, (GLfloat)nw / (GLfloat)nh, 0.1f, 100.0f);
	glMatrixMode(GL_MODELVIEW);

	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
	glTranslatef(0,0,dist);
	glRotatef(rX,0,1,0);
	glRotatef(rY,1,0,0);

	renderModels();

	setOrthoForFont();
	glColor3f(1,1,1);
	//Show the fps
	renderSpacedBitmapString(20, 20, 0, GLUT_BITMAP_HELVETICA_12, buffer);

	glutSwapBuffers();
}
示例#10
0
static void RenderCallback()
{
	// Clear buffers
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
	// Setup camera
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(60.0f, ((float)glutGet(GLUT_WINDOW_WIDTH))/((float)glutGet(GLUT_WINDOW_HEIGHT)), 1.0f, 10000.0f);
	gluLookAt(Eye.x(), Eye.y(), Eye.z(), Eye.x() + Dir.x(), Eye.y() + Dir.y(), Eye.z() + Dir.z(), 0.0f, 1.0f, 0.0f);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	glEnable(GL_LIGHTING);

	//clear previous frames result
	gNormal.setValue(10,0,0);
	gPoint.setValue(0,0,0);
	gDepth = 999.999;
	gLastUsedMethod = -1;
	gNumGjkIterations = -1;


	TestEPA(gConvex0, gConvex1);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	btVector3 RefSep(btScalar(0.), btScalar(0.), btScalar(0.));
	float RefDMin=0.f;
	bool RefResult = false;
	if(gRefMode)
		RefResult = ReferenceCode(gConvex0, gConvex1, RefDMin, RefSep);

//	DrawLine(gPoint, gPoint + gNormal*20.0f, btVector3(1,0,0), 2.0f);
//	printf("%f:  %f  %f  %f\n", gDepth, gNormal.x(), gNormal.y(), gNormal.z());

#ifdef VERBOSE_TEXT_ONSCREEN
	glColor3f(255.f, 255.f, 255.f);

	setOrthographicProjection();
	float xOffset = 10.f;
	float yStart = 20.f;
	float yIncr = 20.f;
	char buf[124];

	sprintf(buf,"gDepth=%f:  gNormal=(%f  %f  %f)\n", gDepth, gNormal.x(), gNormal.y(), gNormal.z());
	GLDebugDrawString(xOffset,yStart,buf);
	yStart += yIncr;

	sprintf(buf,"num GJK iterations =%d\n", gNumGjkIterations);
	GLDebugDrawString(xOffset,yStart,buf);
	yStart += yIncr;

	sprintf(buf,"gLastUsedMethod=%d\n", gLastUsedMethod);
	GLDebugDrawString(xOffset,yStart,buf);
	yStart += yIncr;

	

	

	if (gLastUsedMethod >= 3)
	{
		switch (	gMethod)
		{
		case 0:
			sprintf(buf,"Bullet GjkEpa Penetration depth solver (zlib free\n" );
			break;
		case 1:
			sprintf(buf,"Bullet Minkowski sampling Penetration depth solver\n" );
			break;
		case 2:
				sprintf(buf,"Solid35 EPA Penetration depth solver\n" );
				break;
		case 3:
			sprintf(buf,"EPA Penetration depth solver (Experimental/WorkInProgress, zlib free\n" );
			break;
		default:
				sprintf(buf,"Unknown Penetration Depth\n" );
		}
		GLDebugDrawString(xOffset,yStart,buf);
		yStart += yIncr;

	} else
	{
		sprintf(buf,"Hybrid GJK method %d\n", gLastUsedMethod);
		GLDebugDrawString(xOffset,yStart,buf);
		yStart += yIncr;
	}

	if (gLastDegenerateSimplex)
	{
		sprintf(buf,"DegenerateSimplex %d\n", gLastDegenerateSimplex);
		GLDebugDrawString(xOffset,yStart,buf);
		yStart += yIncr;
	}

	


	resetPerspectiveProjection();
#endif //VERBOSE_TEXT_ONSCREEN

	btVector3 color(0,0,0);
	gConvex0.Render(false, color);
	gConvex1.Render(false, color);

	if(gDepth<0.0f)
	{
		btTransform Saved = gConvex0.mTransform;
		gConvex0.mTransform.setOrigin(gConvex0.mTransform.getOrigin() - btVector3(gNormal*gDepth));
		gConvex0.Render(true, btVector3(1.0f, 0.5f, 0.0f));
		gConvex0.mTransform = Saved;
	}
	else
	{
		DrawLine(gPoint, gPoint + gNormal, btVector3(0,1,0), 2.0f);
	}

	if(RefResult & gRefMode)
	{
		btTransform Saved = gConvex0.mTransform;
		gConvex0.mTransform.setOrigin(gConvex0.mTransform.getOrigin() + btVector3(RefSep*RefDMin));
		gConvex0.Render(true, btVector3(0.0f, 0.5f, 1.0f));
		gConvex0.mTransform = Saved;
	}

	glutSwapBuffers();	
}
示例#11
0
void displayScene (struct winampVisModule *this_mod)
{
	glClear(GL_COLOR_BUFFER_BIT  | GL_DEPTH_BUFFER_BIT);

	GLfloat lcolor = (GLfloat)winampDetectBass(this_mod,0,100)/100.0;

	rotateFactor += rotateRate;
	if (rotateFactor >= 1.0) rotateFactor = 0.0;
	
	/*Draw circle surface*/
	if(SURFACE) {
		glColor3d(0.86,0.86,0.86);
		
		glBegin(GL_POLYGON);
		glVertex3d(0.0,0.0,0.0);
		for(double x = 1.02; x >=0; x -= .02) 
		{
			glVertex3d(groundRad*my_cos(x), 
				       0.0, 
					   groundRad*my_sin(x) );
		}
		glEnd();
	}
	if (WAVEFORMCIRCLES)
	{
		drawWaveformCircles(this_mod, NUM_CIRCLES);
	}

	/*Draw spheres and belonging cones to bump them*/
	for(int o=0; o<NUMSPHERES; o++) {
		glPushMatrix(); //store the origin
		
		//get the next sphere from the ordered list by index i
		int i=order[o][0];

		//Draw cones
		if(CONES) {

			glColor3d(0.9,0.9,0.9);
			glTranslatef(sphere[i].x,0.0,sphere[i].z);
			glRotatef(-90.0,1.0,0.0,0.0);
			
			//The cone is always 1/10 high as the height of its sphere
			if(sphere[i].firstUp) {
				glutSolidCone(sphere[i].r/1.5,
					         sphere[i].height/10, 
							 20.0+sphere[i].height/10,
							 10.0+sphere[i].height/8);
			}
			//if ball is bouncing draw the cone pretty small
			else {
				glutSolidCone(sphere[i].r/1.5,
					         0.1, 
					         20.0+(int)((1-NUMSPHERES/MAXSPHERES)*(sphere[i].r/10)),
							 3.0);
			}
				
			glPopMatrix();
			glPushMatrix();
		}

//-------->>>>>	
		//Sound input for the balls goes here for sphere with size sphere[i].r
		//Input ranges from 0-MAXSTRENGTH, so now from 0-100		
		
		//the input is only computed if the ball is not in the air
		if (!sphere[i].inAir) 
			input=computeSoundInput(i, NUMSPHERES, this_mod, BT_BEAT);
	
		//this function bumps the ball up and is called each time, it actually just bumps the ball up,
		//when it is on the ground and so just disregard the input if not.
		bump(&sphere[i], input);
		
//-------->>>>>

		//Draw the sphere
		if (SPHERES)
		{
			glColor3fv(sphere[i].color);
			glTranslatef(sphere[i].x,sphere[i].r+sphere[i].height,sphere[i].z);
			if(SQUASH) {
                double squash = (sphere[i].height/100.0)*0.6 + 0.5;
				glScaled(1.0, squash,1.0);
			}
			glutSolidSphere(sphere[i].r,
			           20.0+(int)((1-NUMSPHERES/MAXSPHERES)*(sphere[i].r/10)),
					   50.0+(int)((1-NUMSPHERES/MAXSPHERES)*(sphere[i].r))); 
		}

		glPopMatrix(); //restore the origin

		
	}
	
/*Text output*/
	setOrthographicProjection(); //switch to orthographic projection to easier print out text
	glPushMatrix();
	glLoadIdentity();

	//Data ouput of current settings
	if(OUTPUT) {
		char temp[50];
		glColor4f(1.0,1.0,1.0, 1.0);
		
		//Number of Balls
		sprintf(temp,"       # Balls: %.d", NUMSPHERES);
		printOut(10,10,temp);
		//Balls on/off?
		sprintf(temp,"         Balls: %s", (SPHERES)?"on":"off");
		printOut(10,25,temp);
		//Airtime
		sprintf(temp,"  max. Airtime: %.1f", NUMSEC);
		printOut(10,40,temp);
		//Speedfactor
		sprintf(temp,"   Speedfactor: %.1f", SPEEDFACTOR);
		printOut(10,55,temp);
		//Cones on/off?
		sprintf(temp,"         Cones: %s", (CONES)?"on":"off");
		printOut(10,70,temp);
		//Surface on/off?
		sprintf(temp,"       Surface: %s", (SURFACE)?"on":"off");
		printOut(10,85,temp);
		//Bouncing balls?
		sprintf(temp,"Bouncing Balls: %s", (BOUNCE)?"on":"off");
		printOut(10,100,temp);
		//Squash balls?
		sprintf(temp,"  Squash Balls: %s", (SQUASH)?"on":"off");
		printOut(10,115,temp);
		//Beat Circles?
		sprintf(temp,"  Beat Circles: %s", (WAVEFORMCIRCLES)?"on":"off");
		printOut(10, 130, temp);
		//Color change?
		sprintf(temp,"  Change color: %s", (COLORCHANGE)?"on":"off");
		printOut(10,145,temp);
		//Index color of balls
		printOut(10,160,"   Start color: ");
		char * color;
		if(COLOR==0) color="white";
		if(COLOR==1) {color="red"; glColor3f(1.0,0.0,0.0);}
		if(COLOR==2) {color="green"; glColor3f(0.0,1.0,0.0);}
		if(COLOR==3) {color="blue";  glColor3f(0.0,0.0,1.0);}
		if(COLOR==4) {color="yellow";  glColor3f(1.0,1.0,0.0);}
		if(COLOR==5) {color="magenta";  glColor3f(1.0,0.0,1.0);}
		if(COLOR==6) {color="cyan";  glColor3f(0.0,1.0,1.0);}
		sprintf(temp,"%s", color);
		printOut(138,160,temp);
		glColor3f(1.0, 1.0, 1.0);
		//help message
		if(!HELP) {
			glColor3f(1.0,1.0,0.0);
			printOut(width-20*8,10,"Press \'h\' for help!");	
		}
	}

	//help instructions
	if(HELP) {
		glColor3f(1.0,1.0,0.0);
		int x=200;
		int y=0;

		printOut(x,y+10,"  h = switch help on/off");
		printOut(x,y+25,"  o = switch output of the current settings on/off");

		printOut(x,y+55,"z/x = decrease/increase number of balls");
		printOut(x,y+70,"u/i = decrease/increase the maximum airtime of the balls");
		printOut(x,y+85,"j/k = decrease/increase the speed factor of the balls");
        printOut(x,y+100,"n/m = decrease/increase the start color of the balls");
		printOut(x,y+130,"  c = display cones?");
		printOut(x,y+145,"  s = display white circle surface?");
		printOut(x,y+160,"  w = display beat circles?");
		printOut(x,y+175,"  a = display balls?");
		printOut(x,y+190,"  b = allow balls to bounce on the ground?");
		printOut(x,y+205,"  t = allow balls to be squashed?");
		printOut(x,y+220,"  l = allow balls to change color?");

		printOut(x,y+250,"  r = reset all settings to default value");

		printOut(x,y+280,"by Ryan Messner and Simon Beisel");
	}

	glPopMatrix();
	resetPerspectiveProjection(); //reset to old view

	glFlush(); /* clear buffers */

	//glutSwapBuffers(); /*swap the buffers*/
}
示例#12
0
//to be implemented by the demo
void Hinge2Vehicle::renderScene()
{
	m_guiHelper->syncPhysicsToGraphics(m_dynamicsWorld);
#if 0
	for (int i=0;i<m_vehicle->getNumWheels();i++)
	{
		//synchronize the wheels with the (interpolated) chassis worldtransform
		m_vehicle->updateWheelTransform(i,true);

		CommonRenderInterface* renderer = m_guiHelper->getRenderInterface();
		if (renderer)
		{
			btTransform tr = m_vehicle->getWheelInfo(i).m_worldTransform;
			btVector3 pos=tr.getOrigin();
			btQuaternion orn = tr.getRotation();
			renderer->writeSingleInstanceTransformToCPU(pos,orn,m_wheelInstances[i]);
		}
	}
#endif
	
	m_guiHelper->render(m_dynamicsWorld);

	btVector3 wheelColor(1,0,0);

	btVector3	worldBoundsMin,worldBoundsMax;
	getDynamicsWorld()->getBroadphase()->getBroadphaseAabb(worldBoundsMin,worldBoundsMax);




#if 0
	int lineWidth=400;
	int xStart = m_glutScreenWidth - lineWidth;
	int yStart = 20;

	if((getDebugMode() & btIDebugDraw::DBG_NoHelpText)==0)
	{
		setOrthographicProjection();
		glDisable(GL_LIGHTING);
		glColor3f(0, 0, 0);
		char buf[124];
		
		sprintf(buf,"SHIFT+Cursor Left/Right - rotate lift");
		GLDebugDrawString(xStart,20,buf);
		yStart+=20;
		sprintf(buf,"SHIFT+Cursor UP/Down - fork up/down");
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);

		if (m_useDefaultCamera)
		{
			sprintf(buf,"F5 - camera mode (free)");
		} else
		{
			sprintf(buf,"F5 - camera mode (follow)");
		}
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);

		yStart+=20;
		if (m_dynamicsWorld->getConstraintSolver()->getSolverType()==BT_MLCP_SOLVER)
		{
			sprintf(buf,"F6 - solver (direct MLCP)");
		} else
		{
			sprintf(buf,"F6 - solver (sequential impulse)");
		}
		GLDebugDrawString(xStart,yStart,buf);
		btDiscreteDynamicsWorld* world = (btDiscreteDynamicsWorld*) m_dynamicsWorld;
		if (world->getLatencyMotionStateInterpolation())
		{
			sprintf(buf,"F7 - motionstate interpolation (on)");
		} else
		{
			sprintf(buf,"F7 - motionstate interpolation (off)");
		}
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);

		sprintf(buf,"Click window for keyboard focus");
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);


		resetPerspectiveProjection();
		glEnable(GL_LIGHTING);
	}
#endif
}
示例#13
0
void SpheresGridDemo::renderme()
{


	glPointSize(5.0f);
	glEnable(GL_POINT_SPRITE_ARB);
	glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);
#ifndef __APPLE__
	glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_NV);
#endif //__APPLE__
	
	glDepthMask(GL_TRUE);
	glEnable(GL_DEPTH_TEST);

	glUseProgram(m_shaderProgram);

	btScalar dist = (m_glutScreenWidth > m_glutScreenHeight) ? m_glutScreenHeight : m_glutScreenWidth;
	glUniform1f( glGetUniformLocation(m_shaderProgram, "pointScale"), dist  );
//	glUniform1f( glGetUniformLocation(m_shaderProgram, "pointRadius"), 0.5f );
#ifdef SPHERES_DEMO
#ifdef INTEGRATION_DEMO
	int numSpheres = (m_demoType == DEMO_INTEGRATION) ? m_pWorldI->getNumSpheres() : m_pWorldS->getNumSpheres();
	int	col_vbo = (m_demoType == DEMO_INTEGRATION) ? m_pWorldI->m_colVbo : m_pWorldS->m_colVbo;
	int curr_vbo = (m_demoType == DEMO_INTEGRATION) ? m_pWorldI->m_vbo : m_pWorldS->m_vbo;
	float sphere_rad = (m_demoType == DEMO_INTEGRATION) ? m_pWorldI->m_sphereRad : m_pWorldS->m_sphereRad;
#else
	int numSpheres = m_pWorldS->getNumSpheres();
	int	col_vbo = m_pWorldS->m_colVbo;
	int curr_vbo =  m_pWorldS->m_vbo;
	float sphere_rad = m_pWorldS->m_sphereRad;
#endif
#else
	int numSpheres = m_pWorldI->getNumSpheres();
	int	col_vbo = m_pWorldI->m_colVbo;
	int curr_vbo =  m_pWorldI->m_vbo;
	float sphere_rad = m_pWorldI->m_sphereRad;
#endif

	

	glUniform1f( glGetUniformLocation(m_shaderProgram, "pointRadius"), sphere_rad );
	glColor3f(1, 1, 1);

	// render from the vbo
    glBindBuffer(GL_ARRAY_BUFFER, curr_vbo);
    glVertexPointer(4, GL_FLOAT, 0, 0);
    glEnableClientState(GL_VERTEX_ARRAY);
    if(col_vbo) 
	{
		glBindBufferARB(GL_ARRAY_BUFFER_ARB, col_vbo);
		glColorPointer(4, GL_FLOAT, 0, 0);
		glEnableClientState(GL_COLOR_ARRAY);
	}
	glDrawArrays(GL_POINTS, 0, numSpheres);
    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY); 
	glUseProgram(0);
	glDisable(GL_POINT_SPRITE_ARB);
	glBindBufferARB(GL_ARRAY_BUFFER,0);
#ifdef SPHERES_DEMO
	if((m_demoType != DEMO_INTEGRATION) && m_drawGridMode)
	{
		btVector3& wmin =  m_pWorldS->m_worldMin;
		btVector3& wmax =  m_pWorldS->m_worldMax;
		glBegin(GL_LINE_LOOP);
		glVertex3f(wmin[0], wmin[1], wmin[2]);
		glVertex3f(wmin[0], wmax[1], wmin[2]);
		glVertex3f(wmax[0], wmax[1], wmin[2]);
		glVertex3f(wmax[0], wmin[1], wmin[2]);
		glVertex3f(wmax[0], wmin[1], wmax[2]);
		glVertex3f(wmax[0], wmax[1], wmax[2]);
		glVertex3f(wmin[0], wmax[1], wmax[2]);
		glVertex3f(wmin[0], wmin[1], wmax[2]);
		glEnd();
		glBegin(GL_LINES);
		glVertex3f(wmin[0], wmin[1], wmin[2]);
		glVertex3f(wmax[0], wmin[1], wmin[2]);
		glVertex3f(wmin[0], wmin[1], wmax[2]);
		glVertex3f(wmax[0], wmin[1], wmax[2]);
		glVertex3f(wmin[0], wmax[1], wmin[2]);
		glVertex3f(wmin[0], wmax[1], wmax[2]);
		glVertex3f(wmax[0], wmax[1], wmin[2]);
		glVertex3f(wmax[0], wmax[1], wmax[2]);
		glEnd();
		if(m_drawGridMode == 2)
		{
			int szx = m_pWorldS->m_simParams.m_gridSize[0];
			int szy = m_pWorldS->m_simParams.m_gridSize[1];
			glBegin(GL_LINES);
			for(int i = 1; i < (szx-1); i++)
			{
				float wgt = (float)i / (float)(szx-1);
				btVector3 vtx = wmax * wgt + wmin * (1.0f - wgt); 
				glVertex3f(vtx[0], wmin[1], wmin[2]);
				glVertex3f(vtx[0], wmax[1], wmin[2]);
			}
			for(int i = 1; i < (szy-1); i++)
			{
				float wgt = (float)i / (float)(szy-1);
				btVector3 vtx = wmax * wgt + wmin * (1.0f - wgt); 
				glVertex3f(wmin[0], vtx[1], wmin[2]);
				glVertex3f(wmax[0], vtx[1], wmin[2]);
			}
		glEnd();
		}
	}
#endif

	if ((m_debugMode & btIDebugDraw::DBG_NoHelpText)==0)
	{
		setOrthographicProjection();
		int  xOffset = 10.f;
		int  yStart = 20.f;
		int  yIncr = 20.f;
		if(m_demoType == DEMO_INTEGRATION)
		{
#ifdef INTEGRATION_DEMO
			switch(m_pWorldI->m_usedDevice)
			{
				case 0:
					GLDebugDrawString(xOffset,yStart,"CPU");
					break;
				case 1:
					GLDebugDrawString(xOffset,yStart,"OpenCL");
					break;
				case 2:
					GLDebugDrawString(xOffset,yStart,"CUDA");
					break;
			}
			yStart += 30.f;
#endif

		}
		showProfileInfo(xOffset, yStart, yIncr);
		outputDebugInfo(xOffset, yStart, yIncr);
		resetPerspectiveProjection();
	}
}
示例#14
0
//------------------------------------------------------------------------------
void GimpactConcaveDemo::renderme()
{
	updateCamera();


	btScalar m[16];

	if (m_dynamicsWorld)
	{
		btVector3	worldBoundsMin,worldBoundsMax;
		getDynamicsWorld()->getBroadphase()->getBroadphaseAabb(worldBoundsMin,worldBoundsMax);


		int numObjects = m_dynamicsWorld->getNumCollisionObjects();
		btVector3 wireColor(1,0,0);
		for (int i=0;i<numObjects;i++)
		{
			btCollisionObject* colObj = m_dynamicsWorld->getCollisionObjectArray()[i];
			btRigidBody* body = btRigidBody::upcast(colObj);

			if (body && body->getMotionState())
			{
				btDefaultMotionState* myMotionState = (btDefaultMotionState*)body->getMotionState();
				myMotionState->m_graphicsWorldTrans.getOpenGLMatrix(m);
			} else
			{
				colObj->getWorldTransform().getOpenGLMatrix(m);
			}

			btVector3 wireColor(1.f,1.0f,0.5f); //wants deactivation
			if (i & 1)
			{
				wireColor = btVector3(0.f,0.0f,1.f);
			}
			///color differently for active, sleeping, wantsdeactivation states
			if (colObj->getActivationState() == 1) //active
			{
				if (i & 1)
				{
					wireColor += btVector3 (0.8f,0.1f,0.1f);
				} else
				{
					wireColor += btVector3 (0.5f,0.f,0.f);
				}
			}
			if (colObj->getActivationState() == 2) //ISLAND_SLEEPING
			{
				if (i & 1)
				{
					wireColor += btVector3 (0.5f,0.8f, 0.5f);
				} else
				{
					wireColor += btVector3 (0.f,0.5f,0.f);
				}
			}

			m_shapeDrawer->drawOpenGL(m,colObj->getCollisionShape(),wireColor,getDebugMode(),worldBoundsMin,worldBoundsMax);
		}


			float xOffset = 10.f;
			float yStart = 20.f;
			float yIncr = 20.f;
			char buf[124];

			glColor3f(0, 0, 0);

			setOrthographicProjection();

			glRasterPos3f(xOffset,yStart,0);
			sprintf(buf,"mouse to interact");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;

		/*	glRasterPos3f(xOffset,yStart,0);
			sprintf(buf,"space to reset");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
		*/
			glRasterPos3f(xOffset,yStart,0);
			sprintf(buf,"cursor keys and z,x to navigate");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;

			glRasterPos3f(xOffset,yStart,0);
			sprintf(buf,"i to toggle simulation, s single step");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;

			glRasterPos3f(xOffset,yStart,0);
			sprintf(buf,"q to quit");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;

			glRasterPos3f(xOffset,yStart,0);
			sprintf(buf,". to shoot TRIMESH (dot)");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;

			// not yet hooked up again after refactoring...

/*			glRasterPos3f(xOffset,yStart,0);
			sprintf(buf,"d to toggle deactivation");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
*/

		/*
			glRasterPos3f(xOffset,yStart,0);
			sprintf(buf,"a to draw temporal AABBs");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
		*/

			glRasterPos3f(xOffset,yStart,0);
			sprintf(buf,"h to toggle help text");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;

			//bool useBulletLCP = !(getDebugMode() & btIDebugDraw::DBG_DisableBulletLCP);

			bool useCCD = ((getDebugMode() & btIDebugDraw::DBG_EnableCCD) != 0);

			glRasterPos3f(xOffset,yStart,0);
			sprintf(buf,"1 CCD mode (adhoc) = %i",useCCD);
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;

			glRasterPos3f(xOffset,yStart,0);
			sprintf(buf,"+- shooting speed = %10.2f",m_ShootBoxInitialSpeed);
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;

			#ifdef SHOW_NUM_DEEP_PENETRATIONS
				
				glRasterPos3f(xOffset,yStart,0);
				sprintf(buf,"gNumDeepPenetrationChecks = %d",gNumDeepPenetrationChecks);
				GLDebugDrawString(xOffset,yStart,buf);
				yStart += yIncr;

				glRasterPos3f(xOffset,yStart,0);
				sprintf(buf,"gNumSplitImpulseRecoveries= %d",gNumSplitImpulseRecoveries);
				GLDebugDrawString(xOffset,yStart,buf);
				yStart += yIncr;

				


				glRasterPos3f(xOffset,yStart,0);
				sprintf(buf,"gNumGjkChecks= %d",gNumGjkChecks);
				GLDebugDrawString(xOffset,yStart,buf);
				yStart += yIncr;

			#endif //SHOW_NUM_DEEP_PENETRATIONS


			resetPerspectiveProjection();


	}

}
void DemoApplication::renderme()
{
	myinit();

	updateCamera();

	if (m_dynamicsWorld)
	{			
		if(m_enableshadows)
		{
			glClear(GL_STENCIL_BUFFER_BIT);
			glEnable(GL_CULL_FACE);
			renderscene(0);

			glDisable(GL_LIGHTING);
			glDepthMask(GL_FALSE);
			glDepthFunc(GL_LEQUAL);
			glEnable(GL_STENCIL_TEST);
			glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
			glStencilFunc(GL_ALWAYS,1,0xFFFFFFFFL);
			glFrontFace(GL_CCW);
			glStencilOp(GL_KEEP,GL_KEEP,GL_INCR);
			renderscene(1);
			glFrontFace(GL_CW);
			glStencilOp(GL_KEEP,GL_KEEP,GL_DECR);
			renderscene(1);
			glFrontFace(GL_CCW);

			glPolygonMode(GL_FRONT,GL_FILL);
			glPolygonMode(GL_BACK,GL_FILL);
			glShadeModel(GL_SMOOTH);
			glEnable(GL_DEPTH_TEST);
			glDepthFunc(GL_LESS);
			glEnable(GL_LIGHTING);
			glDepthMask(GL_TRUE);
			glCullFace(GL_BACK);
			glFrontFace(GL_CCW);
			glEnable(GL_CULL_FACE);
			glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);

			glDepthFunc(GL_LEQUAL);
			glStencilFunc( GL_NOTEQUAL, 0, 0xFFFFFFFFL );
			glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
			glDisable(GL_LIGHTING);
			renderscene(2);
			glEnable(GL_LIGHTING);
			glDepthFunc(GL_LESS);
			glDisable(GL_STENCIL_TEST);
			glDisable(GL_CULL_FACE);
		}
		else
		{
			glDisable(GL_CULL_FACE);
			renderscene(0);
		}

		int	xOffset = 10;
		int yStart = 20;
		int yIncr = 20;


		glDisable(GL_LIGHTING);
		glColor3f(0, 0, 0);

		if ((m_debugMode & btIDebugDraw::DBG_NoHelpText)==0)
		{
			setOrthographicProjection();

			showProfileInfo(xOffset,yStart,yIncr);

#ifdef USE_QUICKPROF

		
			if ( getDebugMode() & btIDebugDraw::DBG_ProfileTimings)
			{
				static int counter = 0;
				counter++;
				std::map<std::string, hidden::ProfileBlock*>::iterator iter;
				for (iter = btProfiler::mProfileBlocks.begin(); iter != btProfiler::mProfileBlocks.end(); ++iter)
				{
					char blockTime[128];
					sprintf(blockTime, "%s: %lf",&((*iter).first[0]),btProfiler::getBlockTime((*iter).first, btProfiler::BLOCK_CYCLE_SECONDS));//BLOCK_TOTAL_PERCENT));
					glRasterPos3f(xOffset,yStart,0);
					GLDebugDrawString(BMF_GetFont(BMF_kHelvetica10),blockTime);
					yStart += yIncr;

				}

			}
#endif //USE_QUICKPROF


			

			resetPerspectiveProjection();
		}

		glEnable(GL_LIGHTING);


	}

	updateCamera();

}
示例#16
0
void ParticlesDemo::renderme()
{

    glColor3f(1.0, 1.0, 1.0);
	glutWireCube(2*WORLD_SIZE);

	glPointSize(5.0f);
	glEnable(GL_POINT_SPRITE_ARB);

	glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);
#ifndef __APPLE__
//	glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_NV);
	glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
#endif //__APPLE__
	
	glDepthMask(GL_TRUE);
	glEnable(GL_DEPTH_TEST);

	glUseProgram(m_shaderProgram);

	btScalar dist = (m_glutScreenWidth > m_glutScreenHeight) ? m_glutScreenHeight : m_glutScreenWidth;
	glUniform1f( glGetUniformLocation(m_shaderProgram, "pointScale"), dist  );
//	glUniform1f( glGetUniformLocation(m_shaderProgram, "pointRadius"), 0.5f );
	int numParticles = m_pWorld->getNumParticles();
	int	col_vbo = m_pWorld->m_colVbo;
	int curr_vbo = m_pWorld->m_vbo;
	float sphere_rad = m_pWorld->m_particleRad;

	glUniform1f( glGetUniformLocation(m_shaderProgram, "pointRadius"), sphere_rad );
	glColor3f(1, 1, 1);

	// render from the vbo
    glBindBuffer(GL_ARRAY_BUFFER, curr_vbo);
    glVertexPointer(4, GL_FLOAT, 0, 0);
    glEnableClientState(GL_VERTEX_ARRAY);
    if(col_vbo) 
	{
		glBindBufferARB(GL_ARRAY_BUFFER_ARB, col_vbo);
		glColorPointer(4, GL_FLOAT, 0, 0);
		glEnableClientState(GL_COLOR_ARRAY);
	}
	glDrawArrays(GL_POINTS, 0, numParticles);
    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY); 
	glUseProgram(0);
	glDisable(GL_POINT_SPRITE_ARB);
	glBindBufferARB(GL_ARRAY_BUFFER,0);
	if(m_drawGridMode)
	{
		btVector3& wmin =  m_pWorld->m_worldMin;
		btVector3& wmax =  m_pWorld->m_worldMax;
		glBegin(GL_LINE_LOOP);
		glVertex3f(wmin[0], wmin[1], wmin[2]);
		glVertex3f(wmin[0], wmax[1], wmin[2]);
		glVertex3f(wmax[0], wmax[1], wmin[2]);
		glVertex3f(wmax[0], wmin[1], wmin[2]);
		glVertex3f(wmax[0], wmin[1], wmax[2]);
		glVertex3f(wmax[0], wmax[1], wmax[2]);
		glVertex3f(wmin[0], wmax[1], wmax[2]);
		glVertex3f(wmin[0], wmin[1], wmax[2]);
		glEnd();
		glBegin(GL_LINES);
		glVertex3f(wmin[0], wmin[1], wmin[2]);
		glVertex3f(wmax[0], wmin[1], wmin[2]);
		glVertex3f(wmin[0], wmin[1], wmax[2]);
		glVertex3f(wmax[0], wmin[1], wmax[2]);
		glVertex3f(wmin[0], wmax[1], wmin[2]);
		glVertex3f(wmin[0], wmax[1], wmax[2]);
		glVertex3f(wmax[0], wmax[1], wmin[2]);
		glVertex3f(wmax[0], wmax[1], wmax[2]);
		glEnd();
		if(m_drawGridMode == 2)
		{
			int szx = m_pWorld->m_simParams.m_gridSize[0];
			int szy = m_pWorld->m_simParams.m_gridSize[1];
			glBegin(GL_LINES);
			for(int i = 1; i < (szx-1); i++)
			{
				float wgt = (float)i / (float)(szx-1);
				btVector3 vtx = wmax * wgt + wmin * (1.0f - wgt); 
				glVertex3f(vtx[0], wmin[1], wmin[2]);
				glVertex3f(vtx[0], wmax[1], wmin[2]);
			}
			for(int i = 1; i < (szy-1); i++)
			{
				float wgt = (float)i / (float)(szy-1);
				btVector3 vtx = wmax * wgt + wmin * (1.0f - wgt); 
				glVertex3f(wmin[0], vtx[1], wmin[2]);
				glVertex3f(wmax[0], vtx[1], wmin[2]);
			}
		glEnd();
		}
	}

	if ((m_debugMode & btIDebugDraw::DBG_NoHelpText)==0)
	{
		setOrthographicProjection();
		int  xOffset = 10.f;
		int  yStart = 20.f;
		int  yIncr = 20.f;
		showProfileInfo(xOffset, yStart, yIncr);
		outputDebugInfo(xOffset, yStart, yIncr);
		resetPerspectiveProjection();
	}
}
示例#17
0
void InternalEdgeDemo::clientMoveAndDisplay()
{
	 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

	float dt = getDeltaTimeMicroseconds() * 0.000001f;

	if (m_animatedMesh)
	{
		static float offset=0.f;
		offset+=0.01f;

	//	setVertexPositions(waveheight,offset);
#if 0 ///not currently supported, we need to update the btInternalTriangleInfoMap
		int i;
		int j;
		btVector3 aabbMin(BT_LARGE_FLOAT,BT_LARGE_FLOAT,BT_LARGE_FLOAT);
		btVector3 aabbMax(-BT_LARGE_FLOAT,-BT_LARGE_FLOAT,-BT_LARGE_FLOAT);

		for ( i=NUM_VERTS_X/2-3;i<NUM_VERTS_X/2+2;i++)
		{
			for (j=NUM_VERTS_X/2-3;j<NUM_VERTS_Y/2+2;j++)
			{
			
			aabbMax.setMax(gVertices[i+j*NUM_VERTS_X]);
			aabbMin.setMin(gVertices[i+j*NUM_VERTS_X]);
			
				gVertices[i+j*NUM_VERTS_X].setValue((i-NUM_VERTS_X*0.5f)*TRIANGLE_SIZE,
					0.f,
					//waveheight*sinf((float)i+offset)*cosf((float)j+offset),
					(j-NUM_VERTS_Y*0.5f)*TRIANGLE_SIZE);
					
			aabbMin.setMin(gVertices[i+j*NUM_VERTS_X]);
			aabbMax.setMax(gVertices[i+j*NUM_VERTS_X]);

			}
		}
		trimeshShape->partialRefitTree(aabbMin,aabbMax);
#else
		btVector3 aabbMin,aabbMax;
		trimeshShape->getMeshInterface()->calculateAabbBruteForce(aabbMin,aabbMax);
		trimeshShape->refitTree(aabbMin,aabbMax);
	
#endif

		
		//for debugging: clear all contact points involving mesh proxy. Note: this is a slow/unoptimized operation.
		//m_dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(staticBody->getBroadphaseHandle(),getDynamicsWorld()->getDispatcher());
	}



	m_dynamicsWorld->stepSimulation(dt);
	///enable one of the following to debug (render debug lines each frame)
	//m_dynamicsWorld->stepSimulation(1./800.,0);
	//m_dynamicsWorld->stepSimulation(1./60.,100,1./800.);
	//m_dynamicsWorld->stepSimulation(1./60.,0);

	
	int lineWidth=450;
	int xStart = m_glutScreenWidth - lineWidth;
	int yStart = 20;

 #ifndef __QNX__
	if((getDebugMode() & btIDebugDraw::DBG_DrawText)!=0)
	{
		setOrthographicProjection();
		glDisable(GL_LIGHTING);
		glColor3f(0, 0, 0);
		char buf[124];
		
		glRasterPos3f(xStart, yStart, 0);
		if (enable)
		{
			sprintf(buf,"InternalEdgeUtility enabled");
		} else
		{
			sprintf(buf,"InternalEdgeUtility disabled");
		}
		GLDebugDrawString(xStart,20,buf);
		yStart+=20;
		glRasterPos3f(xStart, yStart, 0);
		sprintf(buf,"Press 'n' to toggle InternalEdgeUtility");
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);
		glRasterPos3f(xStart, yStart, 0);
		
		resetPerspectiveProjection();
		glEnable(GL_LIGHTING);
	}
#endif
	
	renderme();

	//optional but useful: debug drawing
	m_dynamicsWorld->debugDrawWorld();


    glFlush();
    swapBuffers();

}
void bulletBaseApp::renderme()
{
	myinit();
	
	updateCamera();
	
	if (m_dynamicsWorld)
	{			
		if(m_enableshadows)
		{
			glClear(GL_STENCIL_BUFFER_BIT);
			glEnable(GL_CULL_FACE);
			renderscene(0);
			
			glDisable(GL_LIGHTING);
			glDepthMask(GL_FALSE);
			glDepthFunc(GL_LEQUAL);
			glEnable(GL_STENCIL_TEST);
			glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
			glStencilFunc(GL_ALWAYS,1,0xFFFFFFFFL);
			glFrontFace(GL_CCW);
			glStencilOp(GL_KEEP,GL_KEEP,GL_INCR);
			renderscene(1);
			glFrontFace(GL_CW);
			glStencilOp(GL_KEEP,GL_KEEP,GL_DECR);
			renderscene(1);
			glFrontFace(GL_CCW);
			
			glPolygonMode(GL_FRONT,GL_FILL);
			glPolygonMode(GL_BACK,GL_FILL);
			glShadeModel(GL_SMOOTH);
			glEnable(GL_DEPTH_TEST);
			glDepthFunc(GL_LESS);
			glEnable(GL_LIGHTING);
			glDepthMask(GL_TRUE);
			glCullFace(GL_BACK);
			glFrontFace(GL_CCW);
			glEnable(GL_CULL_FACE);
			glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
			
			glDepthFunc(GL_LEQUAL);
			glStencilFunc( GL_NOTEQUAL, 0, 0xFFFFFFFFL );
			glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
			glDisable(GL_LIGHTING);
			renderscene(2);
			glEnable(GL_LIGHTING);
			glDepthFunc(GL_LESS);
			glDisable(GL_STENCIL_TEST);
			glDisable(GL_CULL_FACE);
		}
		else
		{
			glDisable(GL_CULL_FACE);
			renderscene(0);
		}
		
		int	xOffset = 10;
		int yStart = 20;
		int yIncr = 20;
		char buf[124];
		
		glDisable(GL_LIGHTING);
		glColor3f(0, 0, 0);
		
		if ((m_debugMode & btIDebugDraw::DBG_NoHelpText)==0)
		{
			setOrthographicProjection();
			
			showProfileInfo(xOffset,yStart,yIncr);
			
#ifdef USE_QUICKPROF
			
			
			if ( getDebugMode() & btIDebugDraw::DBG_ProfileTimings)
			{
				static int counter = 0;
				counter++;
				std::map<std::string, hidden::ProfileBlock*>::iterator iter;
				for (iter = btProfiler::mProfileBlocks.begin(); iter != btProfiler::mProfileBlocks.end(); ++iter)
				{
					char blockTime[128];
					sprintf(blockTime, "%s: %lf",&((*iter).first[0]),btProfiler::getBlockTime((*iter).first, btProfiler::BLOCK_CYCLE_SECONDS));//BLOCK_TOTAL_PERCENT));
					glRasterPos3f(xOffset,yStart,0);
					GLDebugDrawString(BMF_GetFont(BMF_kHelvetica10),blockTime);
					yStart += yIncr;
					
				}
				
			}
#endif //USE_QUICKPROF
			
			
			sprintf(buf,"mouse to interact");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
			
			sprintf(buf,"ALT + mouse to move camera");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
			
			sprintf(buf,"space to reset");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
			
			sprintf(buf,"cursor keys and z,x to navigate");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
			
			sprintf(buf,"i to toggle simulation, s single step");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
			
			sprintf(buf,"q to quit");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
			
			sprintf(buf,". to shoot box");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
			
			// not yet hooked up again after refactoring...
			
			sprintf(buf,"d to toggle deactivation");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
			
			
			sprintf(buf,"g to toggle mesh animation (ConcaveDemo)");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
			
			
			sprintf(buf,"h to toggle help text");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
			
			sprintf(buf,"o to toggle orthogonal/perspective view");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
			
			
			//bool useBulletLCP = !(getDebugMode() & btIDebugDraw::DBG_DisableBulletLCP);
			//bool useCCD = (getDebugMode() & btIDebugDraw::DBG_EnableCCD);
			//glRasterPos3f(xOffset,yStart,0);
			//sprintf(buf,"1 CCD mode (adhoc) = %i",useCCD);
			//GLDebugDrawString(BMF_GetFont(BMF_kHelvetica10),buf);
			//yStart += yIncr;
			
			
			
			sprintf(buf,"+- shooting speed = %10.2f",m_ShootBoxInitialSpeed);
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
			
#ifdef SHOW_NUM_DEEP_PENETRATIONS
			
			
			sprintf(buf,"gNumDeepPenetrationChecks = %d",gNumDeepPenetrationChecks);
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
			
			sprintf(buf,"gNumGjkChecks= %d",gNumGjkChecks);
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
			
			sprintf(buf,"gNumClampedCcdMotions = %d",gNumClampedCcdMotions);
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
			
			sprintf(buf,"gNumSplitImpulseRecoveries= %d",gNumSplitImpulseRecoveries);
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
			
			sprintf(buf,"gNumAlignedAllocs = %d",gNumAlignedAllocs);
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
			
			sprintf(buf,"gNumAlignedFree= %d",gNumAlignedFree);
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
			
			sprintf(buf,"# alloc-free = %d",gNumAlignedAllocs-gNumAlignedFree);
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
			
			//enable BT_DEBUG_MEMORY_ALLOCATIONS define in Bullet/src/LinearMath/btAlignedAllocator.h for memory leak detection
#ifdef BT_DEBUG_MEMORY_ALLOCATIONS
			glRasterPos3f(xOffset,yStart,0);
			sprintf(buf,"gTotalBytesAlignedAllocs = %d",gTotalBytesAlignedAllocs);
			GLDebugDrawString(BMF_GetFont(BMF_kHelvetica10),buf);
			yStart += yIncr;
#endif //BT_DEBUG_MEMORY_ALLOCATIONS
			
			if (getDynamicsWorld())
			{
				glRasterPos3f(xOffset,yStart,0);
				sprintf(buf,"# objects = %d",getDynamicsWorld()->getNumCollisionObjects());
				GLDebugDrawString(xOffset,yStart,buf);
				yStart += yIncr;
				glRasterPos3f(xOffset,yStart,0);
				sprintf(buf,"# pairs = %d",getDynamicsWorld()->getBroadphase()->getOverlappingPairCache()->getNumOverlappingPairs());
				GLDebugDrawString(xOffset,yStart,buf);
				yStart += yIncr;
				sprintf(buf,"# hitPos = %f,%f,%f",gHitPos.getX(),gHitPos.getY(),gHitPos.getZ());
				GLDebugDrawString(xOffset,yStart,buf);
				yStart += yIncr;
				
			}
			
			
#endif //SHOW_NUM_DEEP_PENETRATIONS
			
			resetPerspectiveProjection();
		}
		
		glEnable(GL_LIGHTING);
		
		
	}
	
	updateCamera();
	
}
示例#19
0
void DoublePrecisionDemo::displayCallback(void) 
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
	glDisable(GL_LIGHTING);

	collisionWorld->getDispatchInfo().m_debugDraw = &debugDrawer;
	
  if (collisionWorld)
    collisionWorld->performDiscreteCollisionDetection();

  int i;

	btVector3	worldBoundsMin,worldBoundsMax;
	collisionWorld->getBroadphase()->getBroadphaseAabb(worldBoundsMin,worldBoundsMax);


  ///one way to draw all the contact points is iterating over contact manifolds / points:
  int numManifolds = collisionWorld->getDispatcher()->getNumManifolds();
  for (i=0;i<numManifolds;i++)
  {
    btPersistentManifold* contactManifold = collisionWorld->getDispatcher()->getManifoldByIndexInternal(i);
    btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
    btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
    contactManifold->refreshContactPoints(obA->getWorldTransform(),obB->getWorldTransform());

    int numContacts = contactManifold->getNumContacts();
    for (int j=0;j<numContacts;j++)
    {
      btManifoldPoint& pt = contactManifold->getContactPoint(j);

      glBegin(GL_LINES);
      glColor3f(1, 1, 1);

      btVector3 ptA = pt.getPositionWorldOnA() - m_cameraPosition;
      btVector3 ptB = pt.getPositionWorldOnB() - m_cameraPosition;

      glVertex3d(ptA.x(),ptA.y(),ptA.z());
      glVertex3d(ptB.x(),ptB.y(),ptB.z());
      glEnd();
    }

    //you can un-comment out this line, and then all points are removed
    //contactManifold->clearManifold();	
  }

	btScalar m[16];
	btTransform temp;
	

  btVector3 color;
  //int i;
	for (i=0;i<numObjects;i++)
	{
	  if (i % 2)
	  {
	    color = btVector3(1,0,0);
	  }
	  else
	  {
      color = btVector3(0,0,1);
	  }
	  temp = objects[i].getWorldTransform();
	  temp.setOrigin(temp.getOrigin() - m_cameraPosition);
		temp.getOpenGLMatrix( m );
		m_shapeDrawer->drawOpenGL(m,objects[i].getCollisionShape(),color,getDebugMode(),worldBoundsMin,worldBoundsMax);
	}

  objects[1].getWorldTransform().setOrigin(objects[1].getWorldTransform().getOrigin()+btVector3(-VERY_SMALL_INCREMENT,-VERY_SMALL_INCREMENT,0));
  objects[0].getWorldTransform().setOrigin(objects[0].getWorldTransform().getOrigin()+btVector3(VERY_SMALL_INCREMENT,VERY_SMALL_INCREMENT,0));
  
  float yStart = 20.f;
  float yIncr = 20.f;
  char buf[124];

  glColor3f(0, 0, 0);

  setOrthographicProjection();

  glRasterPos3f(10.0f,yStart,0);
  #ifdef BT_USE_DOUBLE_PRECISION
  GLDebugDrawString(10.f,yStart,"Double Precision Mode");
  #else
  GLDebugDrawString(10.f,yStart,"Single Precision Mode");
  #endif
  yStart += yIncr;
  
  glRasterPos3f(10.0f,yStart,0);
  sprintf(buf,"Movement distance in x and y axis = %lf", VERY_SMALL_INCREMENT);

  GLDebugDrawString(10.f,yStart,buf);
  yStart += yIncr;
  
  glRasterPos3f(10.0f,yStart,0);
  btScalar xValue = objects[0].getWorldTransform().getOrigin().x();
  btScalar yValue = objects[0].getWorldTransform().getOrigin().y();
  btScalar zValue = objects[0].getWorldTransform().getOrigin().z();
  sprintf(buf,"Cube 0 location = ( %lf, %lf, %lf )", xValue, yValue, zValue);
  GLDebugDrawString(10.f,yStart,buf);
  yStart += yIncr;

  xValue = objects[1].getWorldTransform().getOrigin().x();
  yValue = objects[1].getWorldTransform().getOrigin().y();
  zValue = objects[1].getWorldTransform().getOrigin().z();
  glRasterPos3f(10.0f,yStart,0);
  sprintf(buf,"Cube 1 location = ( %lf, %lf, %lf )", xValue, yValue, zValue);
  GLDebugDrawString(10.f,yStart,buf);
  yStart += yIncr;

  glRasterPos3f(10.0f,yStart,0);
  GLDebugDrawString(10.f,yStart,"w=toggle wireframe/solid");

  resetPerspectiveProjection();

	glFlush();
  glutSwapBuffers();
}