コード例 #1
0
        ///setupRigidBody is only used internally by the constructor
        protected void      SetupRigidBody(RigidBodyConstructionInfo constructionInfo)
        {
            m_internalType = CollisionObjectTypes.CO_RIGID_BODY;

            m_linearVelocity       = IndexedVector3.Zero;
            m_angularVelocity      = IndexedVector3.Zero;
            m_angularFactor        = IndexedVector3.One;
            m_linearFactor         = IndexedVector3.One;
            m_gravity              = IndexedVector3.Zero;
            m_gravity_acceleration = IndexedVector3.Zero;
            m_totalForce           = IndexedVector3.Zero;
            m_totalTorque          = IndexedVector3.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
            {
                SetWorldTransform(ref constructionInfo.m_startWorldTransform);
            }

            m_interpolationWorldTransform  = m_worldTransform;
            m_interpolationLinearVelocity  = IndexedVector3.Zero;
            m_interpolationAngularVelocity = IndexedVector3.Zero;

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

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

            SetMassProps(constructionInfo.m_mass, constructionInfo.m_localInertia);
            UpdateInertiaTensor();
            m_rigidbodyFlags = RigidBodyFlags.BT_NONE;
            m_constraintRefs = new List <TypedConstraint>();

            m_deltaLinearVelocity  = IndexedVector3.Zero;
            m_deltaAngularVelocity = IndexedVector3.Zero;
            m_invMass      = m_inverseMass * m_linearFactor;
            m_pushVelocity = IndexedVector3.Zero;
            m_turnVelocity = IndexedVector3.Zero;
        }
コード例 #2
0
        public RigidBody(Shape shape, RigidBodyTypes bodyType, Material material, RigidBodyFlags flags = 0)
        {
            Debug.Assert(shape != null, "Shape can't be null.");
            Debug.Assert(material != null, "Material can't be null.");

            this.bodyType = bodyType;
            this.material = material;

            // Pseudo-static bodies, by design, are always manually controlled.
            if (bodyType == RigidBodyTypes.PseudoStatic)
            {
                flags |= RigidBodyFlags.IsManuallyControlled;
            }

            // TODO: Should pseudo-static bodies have deactivation allowed?
            // By default, all bodies start active (and with deactivation allowed).
            this.flags = flags | RigidBodyFlags.IsActive | RigidBodyFlags.IsDeactivationAllowed;

            readOnlyArbiters    = new ReadOnlyHashset <Arbiter>(arbiters);
            readOnlyConstraints = new ReadOnlyHashset <Constraint>(constraints);

            instance = Interlocked.Increment(ref instanceCount);
            hashCode = CalculateHash(instance);

            Shape       = shape;
            Damping     = DampingType.Angular | DampingType.Linear;
            orientation = JMatrix.Identity;

            if (!IsParticle)
            {
                updatedHandler      = ShapeUpdated;
                Shape.ShapeUpdated += updatedHandler;
                SetMassProperties();
            }
            else
            {
                inertia        = JMatrix.Zero;
                invInertia     = invInertiaWorld = JMatrix.Zero;
                invOrientation = orientation = JMatrix.Identity;
                inverseMass    = 1.0f;
            }

            Update();
        }
コード例 #3
0
 public void     SetFlags(RigidBodyFlags flags)
 {
     m_rigidbodyFlags = flags;
 }
コード例 #4
0
ファイル: RigidBody.cs プロジェクト: bsamuels453/BulletXNA
        public void	SetFlags(RigidBodyFlags flags)
	    {
		    m_rigidbodyFlags = flags;
	    }
コード例 #5
0
ファイル: RigidBody.cs プロジェクト: bsamuels453/BulletXNA
	    ///setupRigidBody is only used internally by the constructor
	    protected void	SetupRigidBody(RigidBodyConstructionInfo constructionInfo)
        {
	        m_internalType=CollisionObjectTypes.CO_RIGID_BODY;

	        m_linearVelocity = IndexedVector3.Zero;
	        m_angularVelocity = IndexedVector3.Zero;
            m_angularFactor = IndexedVector3.One;
            m_linearFactor = IndexedVector3.One;
	        m_gravity = IndexedVector3.Zero;
	        m_gravity_acceleration = IndexedVector3.Zero;
	        m_totalForce = IndexedVector3.Zero;
	        m_totalTorque = IndexedVector3.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
	        {
		        SetWorldTransform(ref constructionInfo.m_startWorldTransform);
	        }

	        m_interpolationWorldTransform = m_worldTransform;
            m_interpolationLinearVelocity = IndexedVector3.Zero;
            m_interpolationAngularVelocity = IndexedVector3.Zero;
        	
	        //moved to btCollisionObject
	        m_friction = constructionInfo.m_friction;
	        m_restitution = constructionInfo.m_restitution;

	        SetCollisionShape( constructionInfo.m_collisionShape );
	        m_debugBodyId = uniqueId++;
        	
	        SetMassProps(constructionInfo.m_mass, constructionInfo.m_localInertia);
	        UpdateInertiaTensor();
            m_rigidbodyFlags = RigidBodyFlags.BT_NONE;
            m_constraintRefs = new List<TypedConstraint>();

            m_deltaLinearVelocity = IndexedVector3.Zero;
            m_deltaAngularVelocity = IndexedVector3.Zero;
            m_invMass = m_inverseMass * m_linearFactor;
            m_pushVelocity = IndexedVector3.Zero;
            m_turnVelocity = IndexedVector3.Zero;

        }
コード例 #6
0
 static extern void btRigidBody_setFlags(IntPtr obj, RigidBodyFlags flags);
コード例 #7
0
 static extern void btRigidBody_setFlags(IntPtr obj, RigidBodyFlags flags);
コード例 #8
0
 public RigidBody(Shape shape, RigidBodyTypes bodyType, RigidBodyFlags flags = 0) :
     this(shape, bodyType, new Material(), flags)
 {
 }