Exemplo n.º 1
0
		///setupRigidBody is only used internally by the constructor
		public void setupRigidBody( btRigidBodyConstructionInfo constructionInfo )
		{

			m_internalType = CollisionObjectTypes.CO_RIGID_BODY;

			m_linearVelocity = btVector3.Zero;
			m_angularVelocity = btVector3.Zero;
			m_angularFactor = btVector3.One;
			m_linearFactor = btVector3.One;
			m_gravity = btVector3.Zero;
			m_gravity_acceleration = btVector3.Zero;
			m_totalForce = btVector3.Zero;
			m_totalTorque = btVector3.Zero;
			setDamping( constructionInfo.m_linearDamping, constructionInfo.m_angularDamping );

			m_linearSleepingThreshold = constructionInfo.m_linearSleepingThreshold;
			m_angularSleepingThreshold = constructionInfo.m_angularSleepingThreshold;
			m_optionalMotionState = constructionInfo.m_motionState;
			//m_contactSolverType = 0;
			//m_frictionSolverType = 0;
			m_additionalDamping = constructionInfo.m_additionalDamping;
			m_additionalDampingFactor = constructionInfo.m_additionalDampingFactor;
			m_additionalLinearDampingThresholdSqr = constructionInfo.m_additionalLinearDampingThresholdSqr;
			m_additionalAngularDampingThresholdSqr = constructionInfo.m_additionalAngularDampingThresholdSqr;
			m_additionalAngularDampingFactor = constructionInfo.m_additionalAngularDampingFactor;

			if( m_optionalMotionState != null )
			{
				m_optionalMotionState.getWorldTransform( out m_worldTransform );
			}
			else
			{
				m_worldTransform = constructionInfo.m_startWorldTransform;
			}

			m_interpolationWorldTransform = m_worldTransform;
			m_interpolationLinearVelocity.setValue( 0, 0, 0 );
			m_interpolationAngularVelocity.setValue( 0, 0, 0 );

			//moved to btCollisionObject
			m_friction = constructionInfo.m_friction;
			m_rollingFriction = constructionInfo.m_rollingFriction;
			m_restitution = constructionInfo.m_restitution;

			setCollisionShape( constructionInfo.m_collisionShape );
			m_debugBodyId = uniqueId++;

			setMassProps( constructionInfo.m_mass, ref constructionInfo.m_localInertia );
			updateInertiaTensor();

			m_rigidbodyFlags = btRigidBodyFlags.BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_BODY;

			m_deltaLinearVelocity.setZero();
			m_deltaAngularVelocity.setZero();
			m_linearFactor.Mult( m_inverseMass, out m_invMass );
			//m_invMass = m_inverseMass * m_linearFactor;
			m_pushVelocity.setZero();
			m_turnVelocity.setZero();
		}
Exemplo n.º 2
0
			// interia default = btVector3.Zero
			public btRigidBodyConstructionInfo( double mass, btMotionState motionState
					, btCollisionShape collisionShape
					, ref btVector3 localInertia )
			{
				m_mass = ( mass );
				m_motionState = ( motionState );
				m_collisionShape = ( collisionShape );
				m_localInertia = ( localInertia );
				m_linearDamping = ( btScalar.BT_ZERO );
				m_angularDamping = ( btScalar.BT_ZERO );
				m_friction = ( (double)( 0.5 ) );
				m_rollingFriction = ( (double)( 0 ) );
				m_restitution = ( btScalar.BT_ZERO );
				m_linearSleepingThreshold = ( (double)( 0.8 ) );
				m_angularSleepingThreshold = ( (double)( 1 ) );
				m_additionalDamping = ( false );
				m_additionalDampingFactor = (double)( 0.005 );
				m_additionalLinearDampingThresholdSqr = ( (double)( 0.01 ) );
				m_additionalAngularDampingThresholdSqr = ( (double)( 0.01 ) );
				m_additionalAngularDampingFactor = ( (double)( 0.01 ) );
				m_startWorldTransform = btTransform.Identity;
			}
Exemplo n.º 3
0
		///btRigidBody constructor for backwards compatibility. 
		///To specify friction (etc) during rigid body construction, please use the other constructor (using btRigidBodyConstructionInfo)
		//    btRigidBody( double mass, btMotionState* motionState, btCollisionShape* collisionShape, ref btVector3 localInertia = btVector3.Zero );
		// cannot give default to ref parameter
		public btRigidBody( double mass, btMotionState motionState, btCollisionShape collisionShape, ref btVector3 localInertia )
		{
			btRigidBodyConstructionInfo cinfo = new btRigidBodyConstructionInfo( mass, motionState, collisionShape, ref localInertia );
			setupRigidBody( cinfo );
		}