Example #1
0
void	btContinuousConvexCollisionDemo::initPhysics()
{
	fromTrans[0].setOrigin(btVector3(0,10,20));
	  toTrans[0].setOrigin(btVector3(0,10,-20));
	fromTrans[1].setOrigin(btVector3(-2,7,0));
	  toTrans[1].setOrigin(btVector3(-2,10,0));

	  btMatrix3x3 identBasis;
	identBasis.setIdentity();

	btMatrix3x3 basisA;
	basisA.setIdentity();
	basisA.setEulerZYX(0.f,-SIMD_HALF_PI,0.f);

	fromTrans[0].setBasis(identBasis);
	  toTrans[0].setBasis(basisA);

	fromTrans[1].setBasis(identBasis);
	  toTrans[1].setBasis(identBasis);

	toTrans[1].setBasis(identBasis);
	btVector3 boxHalfExtentsA(10,1,1);
	btVector3 boxHalfExtentsB(1.1f,1.1f,1.1f);
	btBoxShape*	boxA = new btBoxShape(boxHalfExtentsA);
//	btBU_Simplex1to4* boxA = new btBU_Simplex1to4(btPoint3(-2,0,-2),btPoint3(2,0,-2),btPoint3(0,0,2),btPoint3(0,2,0));
//	btBU_Simplex1to4* boxA = new btBU_Simplex1to4(btPoint3(-12,0,0),btPoint3(12,0,0));
	

	btBoxShape*	boxB = new btBoxShape(boxHalfExtentsB);
//	btBU_Simplex1to4 boxB(btPoint3(0,10,0),btPoint3(0,-10,0));


	shapePtr[0] = boxA;
	shapePtr[1] = boxB;

	shapePtr[0]->setMargin(0.01f);
	shapePtr[1]->setMargin(0.01f);

	for (int i=0;i<numObjects;i++)
	{
		btTransformUtil::calculateVelocity(fromTrans[i],toTrans[i],1.f,linVels[i],angVels[i]);
	}

}
Example #2
0
void LinearConvexCastDemo::initPhysics()
{
	setCameraDistance(30.f);
	tr[0].setOrigin(SimdVector3(0,0,0));
	tr[1].setOrigin(SimdVector3(0,10,0));

	SimdMatrix3x3 basisA;
	basisA.setValue(0.99999958f,0.00022980258f,0.00090992288f,
		-0.00029313788f,0.99753088f,0.070228584f,
		-0.00089153741f,-0.070228823f,0.99753052f);

	SimdMatrix3x3 basisB;
	basisB.setValue(1.0000000f,4.4865553e-018f,-4.4410586e-017f,
		4.4865495e-018f,0.97979438f,0.20000751f,
		4.4410586e-017f,-0.20000751f,0.97979438f);

	tr[0].setBasis(basisA);
	tr[1].setBasis(basisB);



	SimdVector3 boxHalfExtentsA(0.2,4,4);
	SimdVector3 boxHalfExtentsB(6,6,6);

	BoxShape*	boxA = new BoxShape(boxHalfExtentsA);
/*	BU_Simplex1to4	boxB;
	boxB.AddVertex(SimdPoint3(-5,0,-5));
	boxB.AddVertex(SimdPoint3(5,0,-5));
	boxB.AddVertex(SimdPoint3(0,0,5));
	boxB.AddVertex(SimdPoint3(0,5,0));
*/

	BoxShape*	boxB = new BoxShape(boxHalfExtentsB);
	shapePtr[0] = boxA;
	shapePtr[1] = boxB;

	shapePtr[0]->SetMargin(0.01f);
	shapePtr[1]->SetMargin(0.01f);

	SimdTransform tr;
	tr.setIdentity();
}
Example #3
0
int main(int argc,char** argv)
{
    setCameraDistance(20.f);

    tr[0].setOrigin(SimdVector3(0.0013328250f,8.1363249f,7.0390840f));
    tr[1].setOrigin(SimdVector3(0.00000000f,9.1262732f,2.0343180f));

    //tr[0].setOrigin(SimdVector3(0,0,0));
    //tr[1].setOrigin(SimdVector3(0,10,0));

    SimdMatrix3x3 basisA;
    basisA.setValue(0.99999958f,0.00022980258f,0.00090992288f,
                    -0.00029313788f,0.99753088f,0.070228584f,
                    -0.00089153741f,-0.070228823f,0.99753052f);

    SimdMatrix3x3 basisB;
    basisB.setValue(1.0000000f,4.4865553e-018f,-4.4410586e-017f,
                    4.4865495e-018f,0.97979438f,0.20000751f,
                    4.4410586e-017f,-0.20000751f,0.97979438f);

    tr[0].setBasis(basisA);
    tr[1].setBasis(basisB);



    SimdVector3 boxHalfExtentsA(1.0000004768371582f,1.0000004768371582f,1.0000001192092896f);
    SimdVector3 boxHalfExtentsB(3.2836332321166992f,3.2836332321166992f,3.2836320400238037f);

    BoxShape	boxA(boxHalfExtentsA);
    BoxShape	boxB(boxHalfExtentsB);
    shapePtr[0] = &boxA;
    shapePtr[1] = &boxB;


    SimdTransform tr;
    tr.setIdentity();


    return glutmain(argc, argv,screenWidth,screenHeight,"Collision Demo");
}
Example #4
0
void CollisionDemo::initPhysics()
{
	m_debugMode |= btIDebugDraw::DBG_DrawWireframe;
#ifdef CHECK_GENSHER_TRIANGLE_CASE
	m_azi = 140.f;
#else
	m_azi = 250.f;
#endif
	m_ele = 25.f;

	tr[0].setOrigin(btVector3(0.0013328250f,8.1363249f,7.0390840f));
	tr[1].setOrigin(btVector3(0.00000000f,9.1262732f,2.0343180f));

	//tr[0].setOrigin(btVector3(0,0,0));
	//tr[1].setOrigin(btVector3(0,10,0));

	btMatrix3x3 basisA;
	basisA.setValue(0.99999958f,0.00022980258f,0.00090992288f,
		-0.00029313788f,0.99753088f,0.070228584f,
		-0.00089153741f,-0.070228823f,0.99753052f);

	btMatrix3x3 basisB;
	basisB.setValue(1.0000000f,4.4865553e-018f,-4.4410586e-017f,
		4.4865495e-018f,0.97979438f,0.20000751f,
		4.4410586e-017f,-0.20000751f,0.97979438f);

	tr[0].setBasis(basisA);
	tr[1].setBasis(basisB);

#ifdef CHECK_GENSHER_TRIANGLE_CASE
	tr[0].setIdentity();
	tr[1].setIdentity();
#endif //CHECK_GENSHER_TRIANGLE_CASE

	btVector3 boxHalfExtentsA(1.0000004768371582f,1.0000004768371582f,1.0000001192092896f);
	btVector3 boxHalfExtentsB(3.2836332321166992f,3.2836332321166992f,3.2836320400238037f);

#ifndef CHECK_GENSHER_TRIANGLE_CASE
  	btBoxShape*	boxA = new btBoxShape(boxHalfExtentsA);
  	btBoxShape*	boxB = new btBoxShape(boxHalfExtentsB);
#endif

	float p1[3], p2[3], p3[3], q1[3],q2[3], q3[3]; 

   p1[0] = -3.9242966175; 
   p1[1] = -0.5582823175; 
   p1[2] = 2.0101921558; 
    
   p2[0] = -3.6731941700; 
   p2[1] = -0.5604774356; 
   p2[2] = 2.00301921558; 
    
   p3[0] = -3.6698703766; 
   p3[1] = -0.3097069263; 
   p3[2] = 2.0073683262; 
    
    
    
    
   q1[0] = -2.6317186356; 
   q1[1] = -1.0000005960; 
   q1[2] = 1.9999998808; 
    
   q2[0] = -2.6317174435; 
   q2[1] = 0.9999994636; 
   q2[2] = 1.9999998808; 
    
   q3[0] = -4.6317176819; 
   q3[1] = 1.0f; 
   q3[2] = 1.9999998808; 



	btTriangleShape* trishapeA = new btTriangleShape(btVector3(p1[0], p1[1], p1[2]), btVector3(p2[0], p2[1], p2[2]), btVector3(p3[0], p3[1], p3[2])); 
	trishapeA->setMargin(0.001f); 
  
	btTriangleShape* trishapeB = new btTriangleShape(btVector3(q1[0], q1[1], q1[2]), btVector3(q2[0], q2[1], q2[2]), btVector3(q3[0], q3[1], q3[2])); 
	trishapeB->setMargin(0.001f); 


#ifdef CHECK_GENSHER_TRIANGLE_CASE
	shapePtr[0] = trishapeA;
	shapePtr[1] = trishapeB;
#else
	shapePtr[0] = boxA;
	shapePtr[1] = boxB;
#endif

}