Example #1
0
 public bool StartRotateBySpeed(TSVector startForward, TSVector targetForward, FP angleSpeed)
 {
     if (startForward.IsZero() || targetForward.IsZero())
     {
         return(false);
     }
     startForward.Normalize();
     m_sCurForward = m_sStartForward = startForward;
     targetForward.Normalize();
     m_sTargetForward = targetForward;
     if ((startForward - targetForward).IsZero())
     {
         return(false);
     }
     m_sSpeed          = angleSpeed / 360;
     m_sStartRotation  = TSQuaternion.identity;
     m_sTargetRotation = TSQuaternion.FromToRotation(m_sStartForward, m_sTargetForward);
     m_nRotating       = true;
     m_sLerp           = 0;
     if (null != OnStartRotate)
     {
         OnStartRotate(m_sCurForward, m_sCurForward);
     }
     return(true);
 }
Example #2
0
        public bool StartRotate(TSVector startForward, TSVector targetForward, FP time)
        {
            var rotation   = TSQuaternion.FromToRotation(m_sStartForward, m_sTargetForward);
            FP  angle      = TSQuaternion.Angle(TSQuaternion.identity, rotation);
            FP  angleSpeed = FP.MaxValue;

            if (time > 0)
            {
                angleSpeed = angle / time;
            }
            return(StartRotateBySpeed(startForward, targetForward, angleSpeed));
        }
Example #3
0
    public void SetFromToRotation(TSVector fromDirection, TSVector toDirection)
    {
        TSQuaternion targetRotation = TSQuaternion.FromToRotation(fromDirection, toDirection);

        this.Set(targetRotation.x, targetRotation.y, targetRotation.z, targetRotation.w);
    }