Exemplo n.º 1
0
        private Vector3[] timeStep(IRigidBody rigidBody, float factor)
        {
            Vector3 accel    = rigidBody.m_PreviousFrameAcceleration;
            Vector3 velocity = rigidBody.m_PreviousFrameVelocity;
            Vector3 pos      = rigidBody.m_PreviousFramePosition;

            if (rigidBody.m_Kinematic)
            {
                if (accel != new Vector3())
                {
                    accel = rigidBody.m_PreviousFrameAcceleration.ReturnMultipleByScalar((float)Constant.elapsedTime * factor);
                }
                if (rigidBody.m_Drag > 0.0f)
                {
                    Vector3 Temp = accel.ReturnMultipleByScalar(rigidBody.m_Drag);
                    accel.SubtractVector(Temp);
                }

                velocity.AddScalarVector(rigidBody.m_PreviousFrameAcceleration, ((float)Constant.elapsedTime * factor));
                pos.AddScalarVector(rigidBody.m_PreviousFrameVelocity, (float)Constant.elapsedTime * factor);

                return(new Vector3[] { velocity, pos });
            }
            else
            {
                Vector3 vectorChange = rigidBody.m_Position.ReturnSubtractVector(pos);
                pos.AddVector(vectorChange.ReturnMultipleByScalar(factor));
                return(new Vector3[] { velocity, pos });
            }
        }