Example #1
0
        /// <summary>
        /// Update the position after a certain time 'dt'
        /// </summary>
        /// <param name="dt">Time that passed</param>
        public void Integrate(float dt)
        {
            //fake dyanmic constraint
            float   maxDelta = Parameters.MaxAcceleration * dt;
            Vector3 dv       = NVel - Vel;
            float   ds       = dv.Length();

            if (ds > maxDelta)
            {
                dv = dv * (maxDelta / ds);
            }
            Vel = Vel + dv;

            //integrate
            if (Vel.Length() > 0.0001f)
            {
                currentPos = currentPos + Vel * dt;
            }
            else
            {
                Vel = new Vector3(0, 0, 0);
            }
        }
 public float Length()
 {
     return(_vector.Length());
 }