Ejemplo n.º 1
0
        public RigidBody(float mass, MotionState motionState, CollisionShape collisionShape, Vector3 localInertia, float linearDamping, float angularDamping, float friction, float restitution)
        {
            _optionalMotionState = motionState;
            _angularFactor       = 1;
            _angularDamping      = 0.5f;

            if (motionState != null)
            {
                motionState.GetWorldTransform(out _worldTransform);
            }
            else
            {
                WorldTransform = Matrix.Identity;
            }

            InterpolationWorldTransform  = WorldTransform;
            InterpolationLinearVelocity  = new Vector3();
            InterpolationAngularVelocity = new Vector3();

            //moved to btCollisionObject
            Friction    = friction;
            Restitution = restitution;

            CollisionShape = collisionShape;
            _debugBodyId   = UniqueID++;

            //m_internalOwner is to allow upcasting from collision object to rigid body
            Owner = this;

            SetMassProps(mass, localInertia);
            SetDamping(linearDamping, angularDamping);
            UpdateInertiaTensor();
        }
Ejemplo n.º 2
0
		public RigidBody(float mass, MotionState motionState, CollisionShape collisionShape, Vector3 localInertia, float linearDamping, float angularDamping, float friction, float restitution)
		{
			_optionalMotionState = motionState;
			_angularFactor = 1;
			_angularDamping = 0.5f;

			if (motionState != null)
			{
				motionState.GetWorldTransform(out _worldTransform);
			}
			else
			{
				WorldTransform = Matrix.Identity;
			}

			InterpolationWorldTransform = WorldTransform;
			InterpolationLinearVelocity = new Vector3();
			InterpolationAngularVelocity = new Vector3();

			//moved to btCollisionObject
			Friction = friction;
			Restitution = restitution;

			CollisionShape = collisionShape;
			_debugBodyId = UniqueID++;

			//m_internalOwner is to allow upcasting from collision object to rigid body
			Owner = this;

			SetMassProps(mass, localInertia);
			SetDamping(linearDamping, angularDamping);
			UpdateInertiaTensor();
		}
Ejemplo n.º 3
0
        public void SaveKinematicState(float step)
        {
            //todo: clamp to some (user definable) safe minimum timestep, to limit maximum angular/linear velocities
            if (step != 0)
            {
                //if we use motionstate to synchronize world transforms, get the new kinematic/animated world transform
                if (MotionState != null)
                {
                    MotionState.GetWorldTransform(out _worldTransform);
                }

                TransformUtil.CalculateVelocity(InterpolationWorldTransform, WorldTransform, step, ref _linearVelocity, ref _angularVelocity);
                InterpolationLinearVelocity  = _linearVelocity;
                InterpolationAngularVelocity = _angularVelocity;
                InterpolationWorldTransform  = WorldTransform;
            }
        }