Exemplo n.º 1
0
		void Setup()
		{
			world = new btDiscreteDynamicsWorld();
			world.setDebugDrawer( Program.Drawer );

			btVector3 tmp; btVector3.yAxis.Add( ref btVector3.xAxis, out tmp );
			tmp.normalized( out tmp );
			btCollisionShape groundShape;
			if( sloped )
				groundShape = new btStaticPlaneShape( ref btVector3.Zero, ref tmp );
			else
				groundShape = new btStaticPlaneShape( ref btVector3.Zero, ref btVector3.yAxis );

			btDefaultMotionState groundMotionState = new btDefaultMotionState();

			btRigidBody.btRigidBodyConstructionInfo
				groundRigidBodyCI = new btRigidBody.btRigidBodyConstructionInfo( 0, groundMotionState
							, groundShape, ref btVector3.Zero );
			btRigidBody groundRigidBody = new btRigidBody( groundRigidBodyCI );
			world.addRigidBody( groundRigidBody );


			btCollisionShape fallShape = new btSphereShape( btScalar.BT_ONE );

			btVector3 origin = new btVector3( 0, 50, 0 );
			btTransform init = new btTransform( ref btQuaternion.Identity, ref origin );
			btDefaultMotionState fallMotionState = new btDefaultMotionState( ref init );

			btScalar mass = 1;
			btVector3 fallInertia;
			fallShape.calculateLocalInertia( mass, out fallInertia );

			btRigidBody.btRigidBodyConstructionInfo
				fallingRigidBodyCI = new btRigidBody.btRigidBodyConstructionInfo( mass, fallMotionState
							, fallShape, ref fallInertia );

			fallingRigidBody = new btRigidBody( fallingRigidBodyCI );

			world.addRigidBody( fallingRigidBody );
		}
Exemplo n.º 2
0
		void Setup()
		{
			world = new btDiscreteDynamicsWorld();
			world.setDebugDrawer( Program.Drawer );

			btVector3 tmp; btVector3.yAxis.Add( ref btVector3.xAxis, out tmp );
			tmp.normalized( out tmp );
			btCollisionShape groundShape;
			if( sloped )
				groundShape = new btStaticPlaneShape( ref btVector3.Zero, ref tmp );
			else
				groundShape = new btStaticPlaneShape( ref btVector3.Zero, ref btVector3.yAxis );

			btDefaultMotionState groundMotionState = new btDefaultMotionState();

			btRigidBody.btRigidBodyConstructionInfo
				groundRigidBodyCI = new btRigidBody.btRigidBodyConstructionInfo( 0, groundMotionState
							, groundShape, ref btVector3.Zero );
			btRigidBody groundRigidBody = new btRigidBody( groundRigidBodyCI );
			world.addRigidBody( groundRigidBody );

			//-------------------------------------------------------

			btCollisionShape staticShape = new btBoxShape( ref btVector3.One );

			btVector3 origin = new btVector3( -3, 4, 0 );
			btTransform init = new btTransform( ref btQuaternion.Identity, ref origin );
			btDefaultMotionState fallMotionState = new btDefaultMotionState( ref init );

			btScalar mass = 0;
			btVector3 fallInertia;
			staticShape.calculateLocalInertia( mass, out fallInertia );

			btRigidBody.btRigidBodyConstructionInfo
				fallingRigidBodyCI = new btRigidBody.btRigidBodyConstructionInfo( mass, fallMotionState
							, staticShape, ref fallInertia );

			staticRigidBody[0] = new btRigidBody( fallingRigidBodyCI );

			world.addRigidBody( staticRigidBody[0] );

			//-------------------------------------------------------

			btCollisionShape fallShape = new btBoxShape( ref btVector3.One );

			origin = new btVector3( -3, 10, 0 );
			init = new btTransform( ref btQuaternion.Identity, ref origin );
			fallMotionState = new btDefaultMotionState( ref init );

			mass = 1;
			fallShape.calculateLocalInertia( mass, out fallInertia );

			fallingRigidBodyCI = new btRigidBody.btRigidBodyConstructionInfo( mass, fallMotionState
							, fallShape, ref fallInertia );

			fallingRigidBody = new btRigidBody( fallingRigidBodyCI );

			world.addRigidBody( fallingRigidBody );

			//-------------------------------------------------------

			btCollisionShape fallShape2 = new btBoxShape( ref btVector3.One );

			origin = new btVector3( 3, 10, 0 );
			init = new btTransform( ref btQuaternion.Identity, ref origin );
			fallMotionState = new btDefaultMotionState( ref init );

			mass = 1;
			fallShape2.calculateLocalInertia( mass, out fallInertia );

			fallingRigidBodyCI = new btRigidBody.btRigidBodyConstructionInfo( mass, fallMotionState
							, fallShape2, ref fallInertia );

			fallingRigidBody2 = new btRigidBody( fallingRigidBodyCI );

			world.addRigidBody( fallingRigidBody2 );

			//---------------------------------------------------
			// Hinge them together
			btVector3 pivotInA; btVector3.xAxis.Mult( 3, out pivotInA );
			btVector3 axisInA = btVector3.yAxis;
			btVector3 pivotInB; btVector3.xAxis.Mult( -3, out pivotInB );
			btVector3 axisInB = btVector3.yAxis;

			btHingeConstraint constraint = new btHingeConstraint( fallingRigidBody, fallingRigidBody2
				, ref pivotInA, ref pivotInB, ref axisInA, ref axisInB );

			//constraint.enableMotor( true );
			//constraint.setMotorTargetVelocity( 1 );
			//constraint.setLimit( -btScalar.SIMD_2_PI, btScalar.SIMD_2_PI );

			constraint.enableAngularMotor( true, -1, -0.1 );

			world.addConstraint( constraint );
		}
Exemplo n.º 3
0
		public btContinuousConvexCollision( btConvexShape convexA, btStaticPlaneShape plane )
		{
			m_simplexSolver = ( null );
			m_penetrationDepthSolver = ( null );
			m_convexA = ( convexA ); m_convexB1 = ( null ); m_planeShape = ( plane );
		}
Exemplo n.º 4
0
		internal void Initialize( btConvexShape convexA, btConvexShape convexB, btSimplexSolverInterface simplexSolver, btConvexPenetrationDepthSolver penetrationDepthSolver )
		{
			m_simplexSolver = ( simplexSolver );
			m_penetrationDepthSolver = ( penetrationDepthSolver );
			m_convexA = ( convexA ); m_convexB1 = ( convexB ); m_planeShape = null;
		}
Exemplo n.º 5
0
		internal void Initialize( btConvexShape convexA, btStaticPlaneShape plane )
		{
			m_simplexSolver = ( null );
			m_penetrationDepthSolver = ( null );
			m_convexA = ( convexA ); m_convexB1 = ( null ); m_planeShape = ( plane );
		}
Exemplo n.º 6
0
		public void Setup()
		{
			world = new btDiscreteDynamicsWorld();
			world.setDebugDrawer( Program.Drawer );
			btVector3 tmp; btVector3.yAxis.Add( ref btVector3.xAxis, out tmp );
			tmp.normalized( out tmp );
			btCollisionShape groundShape;
			if( sloped )
				groundShape = new btStaticPlaneShape( ref btVector3.Zero, ref tmp );
			else
				groundShape = new btStaticPlaneShape( ref btVector3.Zero, ref btVector3.yAxis );

			btDefaultMotionState groundMotionState = new btDefaultMotionState();

			btRigidBody.btRigidBodyConstructionInfo
				groundRigidBodyCI = new btRigidBody.btRigidBodyConstructionInfo( 0, groundMotionState
							, groundShape, ref btVector3.Zero );
			btRigidBody groundRigidBody = new btRigidBody( groundRigidBodyCI );
			world.addRigidBody( groundRigidBody );


			btCollisionShape fallShape = new btBoxShape( ref btVector3.One );
			if( large_count )
			{
				int n;
				int cubes = 5;
				for( n = 0; n < cubes * cubes * cubes; n++ )
				{
					btVector3 origin = new btVector3( ( n %cubes - cubes/2) * 3, 50 + ( n/(cubes*cubes))*3, (( n / cubes)%cubes - cubes/2 ) * 3 );
					btTransform init = new btTransform( ref btQuaternion.Identity, ref origin );
					btDefaultMotionState fallMotionState = new btDefaultMotionState( ref init );

					btScalar mass = 1;
					btVector3 fallInertia;
					fallShape.calculateLocalInertia( mass, out fallInertia );

					btRigidBody.btRigidBodyConstructionInfo
						fallingRigidBodyCI = new btRigidBody.btRigidBodyConstructionInfo( mass, fallMotionState
									, fallShape, ref fallInertia );

					fallingRigidBody = new btRigidBody( fallingRigidBodyCI );

					world.addRigidBody( fallingRigidBody );
					if( n % (cubes* cubes ) == 0 )
						Console.Write( "." );
				}
			}
			else
			{
				btVector3 origin = new btVector3( 1, 50, 1 );
				btTransform init = new btTransform( ref btQuaternion.Identity, ref origin );
				btDefaultMotionState fallMotionState = new btDefaultMotionState( ref init );

				btScalar mass = 1;
				btVector3 fallInertia;
				fallShape.calculateLocalInertia( mass, out fallInertia );

				btRigidBody.btRigidBodyConstructionInfo
					fallingRigidBodyCI = new btRigidBody.btRigidBodyConstructionInfo( mass, fallMotionState
								, fallShape, ref fallInertia );

				fallingRigidBody = new btRigidBody( fallingRigidBodyCI );

				world.addRigidBody( fallingRigidBody );
			}
		}