void BasicDemo3D::clientMoveAndDisplay()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

	//simple dynamics world doesn't handle fixed-time-stepping
	float ms = getDeltaTimeMicroseconds();

	///step the simulation
	if (m_dynamicsWorld)
	{
//		btCudaDemoPairCache* pc = (btCudaDemoPairCache*)m_dynamicsWorld->getPairCache();
//		pc->m_numSmallProxies = m_dynamicsWorld->getNumCollisionObjects(); //  - 1; // exclude floor
		m_dynamicsWorld->stepSimulation(gTimeStep,0);//ms / 1000000.f);
		//optional but useful: debug drawing
		m_dynamicsWorld->debugDrawWorld();
	}
	renderme(); 

	ms = getDeltaTimeMicroseconds();

	glFlush();

	glutSwapBuffers();

}
示例#2
0
void BasicDemo::clientMoveAndDisplay()
{
	updateCamera();
	glDisable(GL_LIGHTING);
	glColor3f(1.f, 1.f, 1.f);

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

	glDisable(GL_TEXTURE_2D); // we always draw wireframe in this demo

	//simple dynamics world doesn't handle fixed-time-stepping
	float ms = getDeltaTimeMicroseconds();

	///step the simulation
	if (m_dynamicsWorld)
	{
#if USE_CUDA_DEMO_PAIR_CASHE
		btGpuDemoPairCache* pc = (btGpuDemoPairCache*)m_dynamicsWorld->getPairCache();
		pc->m_numSmallProxies = m_dynamicsWorld->getNumCollisionObjects(); //  - 1; // exclude floor
#endif
		m_dynamicsWorld->stepSimulation(gTimeStep,0);//ms / 1000000.f);
		//optional but useful: debug drawing
		m_dynamicsWorld->debugDrawWorld();
	}
	renderme(); 

	ms = getDeltaTimeMicroseconds();

	glFlush();

	glutSwapBuffers();

}
示例#3
0
void FeatherstoneMultiBodyDemo::clientMoveAndDisplay()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

	//simple dynamics world doesn't handle fixed-time-stepping
	float ms = getDeltaTimeMicroseconds();
	
	///step the simulation
	if (m_dynamicsWorld)
	{
		m_dynamicsWorld->stepSimulation(ms / 1000000.f);
		//optional but useful: debug drawing
		m_dynamicsWorld->debugDrawWorld();

		btVector3 aabbMin(1,1,1);
		btVector3 aabbMax(2,2,2);

		
	}
		
	renderme(); 

	glFlush();

	swapBuffers();

}
void CcdPhysicsDemo::clientMoveAndDisplay()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

	//simple dynamics world doesn't handle fixed-time-stepping
	float ms = getDeltaTimeMicroseconds();
	
	///step the simulation
	if (m_dynamicsWorld)
	{
		m_dynamicsWorld->stepSimulation(1./60.);//ms / 1000000.f);
		//optional but useful: debug drawing
		m_dynamicsWorld->debugDrawWorld();
	}
		
	renderme(); 

	displayText();
#if 0
	for (int i=0;i<debugContacts.size();i++)
	{
		getDynamicsWorld()->getDebugDrawer()->drawContactPoint(debugContacts[i],debugNormals[i],0,0,btVector3(1,0,0));
	}
#endif

	glFlush();

	swapBuffers();

}
示例#5
0
void SerializeDemo::clientMoveAndDisplay()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

	//simple dynamics world doesn't handle fixed-time-stepping
	float ms = getDeltaTimeMicroseconds();
	
	///step the simulation
	if (m_dynamicsWorld)
	{
		
		m_dynamicsWorld->stepSimulation(ms / 1000000.f);
		if (sbsolver)
			sbsolver->copyBackToSoftBodies();
		//optional but useful: debug drawing
		m_dynamicsWorld->debugDrawWorld();
	}
	

	renderme(); 

	glFlush();

	swapBuffers();

}
void BasicDemo::clientMoveAndDisplay()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

	//simple dynamics world doesn't handle fixed-time-stepping
	float ms = getDeltaTimeMicroseconds();
	
	///step the simulation
	if (m_dynamicsWorld)
	{
		
		m_cameraTargetPosition = m_sphere->getWorldTransform().getOrigin();
		updateCamera();
		m_dynamicsWorld->stepSimulation(ms / 1000000.f);
		//optional but useful: debug drawing
		m_dynamicsWorld->debugDrawWorld();
	}
		
	renderme(); 

	glFlush();

	swapBuffers();

}
void ArtificialBirdsDemoApp::clientMoveAndDisplay()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

	//simple dynamics world doesn't handle fixed-time-stepping
	float ms = getDeltaTimeMicroseconds();

	float minFPS = 1000000.f/60.f;
	if (ms > minFPS)
		ms = minFPS;

	if (m_dynamicsWorld) {
		m_dynamicsWorld->stepSimulation(ms / 1000000.f);
		
		//optional but useful: debug drawing
		m_dynamicsWorld->debugDrawWorld();
	}

	if (m_bigbirds.size() > 0)
		m_cameraTargetPosition = m_bigbirds[0]->getPosition();
	else if (m_birdOpt)
		m_cameraTargetPosition = m_birdOpt->getBirdPosition();
	else if (m_birdDemo)
		m_cameraTargetPosition = m_birdDemo->getPosition();

	renderme(); 

	glFlush();
	glutSwapBuffers();

}
示例#8
0
void BasicDemo::clientMoveAndDisplay()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

	//simple dynamics world doesn't handle fixed-time-stepping
	float ms = getDeltaTimeMicroseconds();
	
	///step the simulation
	if (m_dynamicsWorld)
	{
		m_dynamicsWorld->stepSimulation(ms / 1000000.f);
		//optional but useful: debug drawing
		m_dynamicsWorld->debugDrawWorld();

		btVector3 aabbMin(1,1,1);
		btVector3 aabbMax(2,2,2);

		MyOverlapCallback aabbOverlap(aabbMin,aabbMax);
		m_dynamicsWorld->getBroadphase()->aabbTest(aabbMin,aabbMax,aabbOverlap);
		
		//if (aabbOverlap.m_numOverlap)
		//	printf("#aabb overlap = %d\n", aabbOverlap.m_numOverlap);
	}
		
	renderme(); 

	glFlush();

	swapBuffers();

}
示例#9
0
    void BulletOpenGLViewer::clientMoveAndDisplay()
    {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        //simple dynamics world doesn't handle fixed-time-stepping
        double ms = getDeltaTimeMicroseconds();

        double minFPS = 1000000.f / 60.f;

        if (ms > minFPS)
        {
            ms = minFPS;
        }

        if (m_dynamicsWorld)
        {
            btScalar dt1 = btScalar(ms / 1000000.0f);

            m_dynamicsWorld->stepSimulation(dt1, 4);

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

        renderme();

        glFlush();

        swapBuffers();
    }
示例#10
0
void BasicDemo::clientMoveAndDisplay()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    //simple dynamics world doesn't handle fixed-time-stepping
    float ms = getDeltaTimeMicroseconds();

    ///step the simulation
    if (m_dynamicsWorld)
    {
        m_dynamicsWorld->stepSimulation(ms / 1000000.f);
        //optional but useful: debug drawing
        m_dynamicsWorld->debugDrawWorld();
    }

    renderme();

    renderSurfacePoints();


    glFlush();

    swapBuffers();

}
示例#11
0
void BasicDemo::clientMoveAndDisplay()
{

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

	//simple dynamics world doesn't handle fixed-time-stepping
	float ms = getDeltaTimeMicroseconds();
	
	GL_ShapeDrawer::drawCoordSystem();

	///step the simulation
	if (m_dynamicsWorld)
	{
		//m_dynamicsWorld->stepSimulation(ms / 1000000.f);
		m_dynamicsWorld->stepSimulation(ms / 1000000.f,10,1./240.);
		//optional but useful: debug drawing
		m_dynamicsWorld->debugDrawWorld();
	}
		
	renderme(); 


	glFlush();


	glutSwapBuffers();
	

}
示例#12
0
void BasicDemo::clientMoveAndDisplay()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

	//simple dynamics world doesn't handle fixed-time-stepping
	float ms = getDeltaTimeMicroseconds();

	int key;
	int x = 0, y = 0;
	//step the simulation
	if (m_dynamicsWorld)
	{
		specialKeyboard(key, x, y);
		if (gStepSim == true)
		{	
			printf("Simulation step is %d\n", i);		
			m_dynamicsWorld->stepSimulation(ms / 1000000.f);
			i += 1;
		}
		gStepSim = false;
		//optional but useful: debug drawing
		m_dynamicsWorld->debugDrawWorld();
	}
		
	renderme(); 

	glFlush();

	swapBuffers();

}
/** Old main simulation function that also renders the simulation to GLUT
*
**/
void Physics::clientMoveAndDisplay(boolean fixed){
	float ms = getDeltaTimeMicroseconds();
	static float time2=0;
	time2+=ms;
	static float timeBehind2= 0;
	timeBehind2+=ms;
	if(fixed){
		if(timeBehind2>1000){
			static int update=20;

			simulationLoopStep(1 / 1000.f);
			timeBehind2-=1000;
		}
	}else{
		simulationLoopStep(ms / 1000000.f); //normal speed
		//simulationLoopStep(ms / 100000000.f); //slow-mode
		timeBehind=0;
	}
	frameRate=1000000./time2+0.5;
	time2=0;

	pointCamera();

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	m_dynamicsWorld->debugDrawWorld();

	renderme();

	glFlush();

	swapBuffers();
}
示例#14
0
void SimulationVisual::clientMoveAndDisplay()
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

  //simple dynamics world doesn't handle fixed-time-stepping
  float ms = getDeltaTimeMicroseconds();

  float minFPS = 1000000.f/60.f;
  if (ms > minFPS)
    ms = minFPS;

  if (Simulation::m_dynamicsWorld)
    {
      Simulation::m_dynamicsWorld->stepSimulation(ms / 1000000.f);
		
      //optional but useful: debug drawing
      Simulation::m_dynamicsWorld->debugDrawWorld();


    }

  renderme(); 

  glFlush();

  glutSwapBuffers();
}
示例#15
0
void ConcaveRaycastDemo::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);

		btVector3 worldMin(-1000,-1000,-1000);
		btVector3 worldMax(1000,1000,1000);

		trimeshShape->refitTree(worldMin,worldMax);
		
		//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(1./60.,0);
	
	//optional but useful: debug drawing
	m_dynamicsWorld->debugDrawWorld();
	
	raycastBar.move (dt);
	raycastBar.cast (m_dynamicsWorld);
	renderme();
	raycastBar.draw ();
    glFlush();
    glutSwapBuffers();

}
示例#16
0
void MotorDemo::clientMoveAndDisplay()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

	//simple dynamics world doesn't handle fixed-time-stepping
	float deltaTime = getDeltaTimeMicroseconds()/1000000.f;
	

	if (m_dynamicsWorld)
	{
		m_dynamicsWorld->stepSimulation(deltaTime);
		m_dynamicsWorld->debugDrawWorld();
	}

	renderme(); 

	for (int i=2; i>=0 ;i--)
	{
		btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
		btRigidBody* body = btRigidBody::upcast(obj);
		drawFrame(body->getWorldTransform());
	}

	glFlush();

	glutSwapBuffers();
}
示例#17
0
void PendulumApplication::clientMoveAndDisplay()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	//simple dynamics world doesn't handle fixed-time-stepping
	m_dt = getDeltaTimeMicroseconds()/1000000.f;
	temp += m_dt;
	///step the simulation
	if (m_dynamicsWorld)
	{
		m_dynamicsWorld->stepSimulation(m_dt);
		//optional but useful: debug drawing
		m_dynamicsWorld->debugDrawWorld();
	}
	btTransform trans;
	m_pendulumBody->getMotionState()->getWorldTransform(trans);
	Integrator_rk4();
	trans.getOrigin() = btVector3(0,20,0)+pol2cart(m_r.m_value,m_theta.m_value);
	//printf("%f %f %f\n",m_position.x(),m_po sition.y(),m_position.z());
	m_pendulumBody->getMotionState()->setWorldTransform(trans);
    m_r.m_value = m_r.m_value + 0.1 * sin (temp);
	//draw the rope
	btVector3 anchor(0,20,0);
	glLineWidth(2.0);
	glBegin(GL_LINES);
	glVertex3fv(anchor.m_floats);
	glVertex3fv(trans.getOrigin());
	glEnd();

	renderme();
	swapBuffers();
}
示例#18
0
void ConcaveConvexcastDemo::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;

		
		
		int i;
		int j;
		btVector3 aabbMin(1e30,1e30,1e30);
		btVector3 aabbMax(-1e30,-1e30,-1e30);

		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);


		//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);
	
	//optional but useful: debug drawing
	m_dynamicsWorld->debugDrawWorld();

	convexcastBatch.move (dt);
	convexcastBatch.cast (m_dynamicsWorld);
	renderme();
	convexcastBatch.draw ();
    glFlush();
    glutSwapBuffers();

}
示例#19
0
void KeplerBtDynamics::update()
{
	//simple dynamics world doesn't handle fixed-time-stepping
	float ms = getDeltaTimeMicroseconds();
    
	float minFPS = 1000000.f/60.f;
	if (ms > minFPS)
		ms = minFPS;
    
	if (m_dynamicsWorld)
		m_dynamicsWorld->stepSimulation(ms / 1000000.f);
}
示例#20
0
void ParticlesDemo::clientMoveAndDisplay()
{


	updateCamera();
	glDisable(GL_LIGHTING);
	glColor3f(1.f, 1.f, 1.f);

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

	glDisable(GL_TEXTURE_2D); // we always draw wireframe in this demo

	//simple dynamics world doesn't handle fixed-time-stepping
	float ms = getDeltaTimeMicroseconds();

	renderme(); 

	if (m_dialogDynamicsWorld)
		m_dialogDynamicsWorld->draw(gTimeStep);

	///step the simulation
	if (m_dynamicsWorld)
	{
		m_dynamicsWorld->stepSimulation(gTimeStep,0);//ms / 1000000.f);
		//optional but useful: debug drawing
		m_dynamicsWorld->debugDrawWorld();
	}

	

	ms = getDeltaTimeMicroseconds();

	glFlush();

	glutSwapBuffers();

}
示例#21
0
void SerializeDemo::clientMoveAndDisplay()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

	//simple dynamics world doesn't handle fixed-time-stepping
	float ms = getDeltaTimeMicroseconds();
	
	///step the simulation
	if (m_dynamicsWorld)
	{
		m_dynamicsWorld->stepSimulation(ms / 1000000.f);

		
#ifdef DESERIALIZE_SOFT_BODIES
		if (fSoftBodySolver)
            fSoftBodySolver->copyBackToSoftBodies();
#endif

		m_dynamicsWorld->debugDrawWorld();

#ifdef DESERIALIZE_SOFT_BODIES
		if (m_dynamicsWorld->getWorldType()==BT_SOFT_RIGID_DYNAMICS_WORLD)
		{
			//optional but useful: debug drawing
			btSoftRigidDynamicsWorld* softWorld = (btSoftRigidDynamicsWorld*)m_dynamicsWorld;

			for (  int i=0;i<softWorld->getSoftBodyArray().size();i++)
			{
				btSoftBody*	psb=(btSoftBody*)softWorld->getSoftBodyArray()[i];
				if (softWorld->getDebugDrawer() && !(softWorld->getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe)))
				{
					btSoftBodyHelpers::DrawFrame(psb,softWorld->getDebugDrawer());
					btSoftBodyHelpers::Draw(psb,softWorld->getDebugDrawer(),softWorld->getDrawFlags());
				}
			}
		}
#endif //DESERIALIZE_SOFT_BODIES

	}
		
	renderme(); 

	glFlush();

	swapBuffers();

}
示例#22
0
void ColladaDemo::clientMoveAndDisplay()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

	float dt = getDeltaTimeMicroseconds() * 0.000001f;

	m_dynamicsWorld->stepSimulation(dt);

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

	renderme();

	glFlush();
	glutSwapBuffers();

}
示例#23
0
void PendulumApplication::clientMoveAndDisplay()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    //simple dynamics world doesn't handle fixed-time-stepping
    float dt = getDeltaTimeMicroseconds()/1000000.f;
    ///step the simulation
    if (m_dynamicsWorld)
    {
        m_dynamicsWorld->stepSimulation(dt);
        //optional but useful: debug drawing
        m_dynamicsWorld->debugDrawWorld();
    }

    renderme();
    swapBuffers();
}
示例#24
0
void PendulumApplication::clientMoveAndDisplay()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	//simple dynamics world doesn't handle fixed-time-stepping
	float dt = getDeltaTimeMicroseconds()/1000000.f;
	///step the simulation
	if (m_dynamicsWorld)
	{
		m_dynamicsWorld->stepSimulation(dt);
		//optional but useful: debug drawing
		m_dynamicsWorld->debugDrawWorld();
	}

    /*
    if(m_corde != NULL && m_corde2 != NULL)
    {
    /// contrainte p1
    btVector3 beg = m_corde->m_nodes[0].m_x;
    btVector3 end = m_corde->m_nodes[m_corde->m_nodes.size()-1].m_x;

    btVector3 res = beg - end;

    btScalar mid = m_corde->m_nodes.size()/2;

    if(res.x() > m_size_corde.x()+4 || res.y() > m_size_corde.y()+4||res.z() > m_size_corde.z()+4)
    m_corde->cutLink(mid,mid+1,0.5);
    /// contrainte p2
    beg = m_corde2->m_nodes[0].m_x;
    end = m_corde2->m_nodes[m_corde2->m_nodes.size()-1].m_x;

    res = beg - end;

    mid = m_corde2->m_nodes.size()/2;

    if(res.x() > m_size_corde2.x()+3 || res.y() > m_size_corde2.y()+3 || res.z() > m_size_corde2.z()+3)
    m_corde2->cutLink(mid,mid+1,0.5);
    }
    */
	renderme();
	swapBuffers();
}
示例#25
0
void TerrainDemo::clientMoveAndDisplay(void)
{
	// elapsed time
	float us = getDeltaTimeMicroseconds();
	float seconds = 1.0e-6 * us;

	// we'll carefully iterate through each time step so we can update
	//   the dynamic model if necessary
	long nStepsPerIteration = 1;
	while (seconds > 1.0e-6) {
		float dt = nStepsPerIteration * s_engineTimeStep;
		if (dt > seconds) {
			dt = seconds;
		}
		seconds -= dt;
	//	std::cerr << "  Stepping through " << dt << " seconds\n";

		// if dynamic and radial, go ahead and update the field
		if (m_rawHeightfieldData && m_isDynamic && eRadial == m_model) {
			m_phase += s_deltaPhase * dt;
			if (m_phase > 2.0 * SIMD_PI) {
				m_phase -= 2.0 * SIMD_PI;
			}
			int bpe = getByteSize(m_type);
			btAssert(bpe > 0 && "Bad bytes per element");
			setRadial(m_rawHeightfieldData, bpe, m_type, m_phase);
		}

		if (m_dynamicsWorld) {
			m_dynamicsWorld->stepSimulation(dt,
			    nStepsPerIteration + 1, s_engineTimeStep);
		}
	}

	// okay, render
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	renderme();
	glFlush();
	glutSwapBuffers();
}
示例#26
0
void RaytestDemo::clientMoveAndDisplay()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

	castRays();
	
	if (m_dynamicsWorld)
	{
		float ms = getDeltaTimeMicroseconds();
		m_dynamicsWorld->stepSimulation(ms / 1000000.f);

		m_dynamicsWorld->debugDrawWorld();
	}


		
	renderme(); 

	glFlush();

	swapBuffers();

}
示例#27
0
void BulletXmlImportDemo::clientMoveAndDisplay()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

	//simple dynamics world doesn't handle fixed-time-stepping
	float ms = getDeltaTimeMicroseconds();
	
	///step the simulation
	if (m_dynamicsWorld)
	{
	

		m_dynamicsWorld->stepSimulation(ms / 1000000.f);
		m_dynamicsWorld->debugDrawWorld();
	}
		
	renderme(); 

	glFlush();

	swapBuffers();

}
void RagdollDemo::clientMoveAndDisplay()
{
  int i;
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

	//simple dynamics world doesn't handle fixed-time-stepping
	float ms = getDeltaTimeMicroseconds();

	float minFPS = 1000000.f/60.f;
	if (ms > minFPS)
		ms = minFPS;

	if (m_dynamicsWorld)
	{
    if (!pause || (pause && oneStep)) {
      for (i = 0; i < 8; i++) {
        double angle = drand48()*90. - 45.;
        angle = 45.;
        ActuateJoint2(i, angle, ms / 1000000.f);
      }
      //ActuateJoint(0, -45., ms / 1000000.f);
      m_dynamicsWorld->stepSimulation(ms / 1000000.f);
      oneStep = false;
    }

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


	}

	renderme(); 

	glFlush();

	glutSwapBuffers();
}
void RagdollDemo::clientMoveAndDisplay()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

	//simple dynamics world doesn't handle fixed-time-stepping
	float ms = getDeltaTimeMicroseconds();

	float minFPS = 1000000.f/60.f;
	if (ms > minFPS)
		ms = minFPS;

	if (m_dynamicsWorld)
	{
        if(!pause)
        {
            m_dynamicsWorld->stepSimulation(ms / 1000000.f);
        }
        
        if (pause && oneStep)
            {
                m_dynamicsWorld->stepSimulation(ms / 1000000.f);
                oneStep = !oneStep;
            }
        
		//optional but useful: debug drawing
		m_dynamicsWorld->debugDrawWorld();
        

	}

	renderme(); 

	glFlush();

	glutSwapBuffers();
}
示例#30
0
void SliderConstraintDemo::clientMoveAndDisplay()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    float dt = float(getDeltaTimeMicroseconds()) * 0.000001f;
    //during idle mode, just run 1 simulation step maximum
    int maxSimSubSteps = m_idle ? 1 : 1;
    if(m_idle)
    {
        dt = 1.0/420.f;
    }
    int numSimSteps = m_dynamicsWorld->stepSimulation(dt,maxSimSubSteps);
    //optional but useful: debug drawing
    m_dynamicsWorld->debugDrawWorld();
    bool verbose = false;
    if (verbose)
    {
        if (!numSimSteps)
            printf("Interpolated transforms\n");
        else
        {
            if (numSimSteps > maxSimSubSteps)
            {
                //detect dropping frames
                printf("Dropped (%i) simulation steps out of %i\n",numSimSteps - maxSimSubSteps,numSimSteps);
            } else
            {
                printf("Simulated (%i) steps\n",numSimSteps);
            }
        }
    }
    renderme();
    drawSlider(spSlider1);
    drawSlider(spSlider2);
    glFlush();
    glutSwapBuffers();
} // SliderConstraintDemo::clientMoveAndDisplay()