示例#1
0
        public void Update(float fDeltaTime)
        {
            if (m_State == eCameraState.Free)
            {
                m_vCurrPan   *= GlobalDefines.fCameraSpeed * fDeltaTime;
                m_vTotalPan  += m_vCurrPan;
                m_vTotalPan.X = MathHelper.Clamp(m_vTotalPan.X, m_vLevelMin.X, m_vLevelMax.X);
                m_vTotalPan.Z = MathHelper.Clamp(m_vTotalPan.Z, m_vLevelMin.Z, m_vLevelMax.Z);
            }
            else
            {
                if (m_fLerp < 1.0f)
                {
                    m_fLerp  += fDeltaTime / m_fLerpTime;
                    m_vTarget = Vector3.Lerp(m_vOldTarget, m_vNewTarget, m_fLerp);
                    m_vEye    = Vector3.Lerp(m_vOldEye, m_vNewEye, m_fLerp);
                }
                else
                {
                    m_State = eCameraState.Free;
                }
            }

            ComputeMatrix();
            m_vCurrPan = Vector3.Zero;
        }
示例#2
0
 public void ResetCamera()
 {
     m_vTotalPan = Vector3.Zero;
     m_vEye      = new Vector3(0, 10, 10);
     m_vTarget   = Vector3.Zero;
     m_State     = eCameraState.Free;
 }
示例#3
0
        public void SetTargetSmooth(Vector3 vTarget)
        {
            m_vOldEye    = m_vEye;
            m_vOldTarget = m_vTarget;

            Vector3 vDiff = vTarget - m_vTarget;

            m_vNewEye    = m_vEye + vDiff;
            m_vNewTarget = vTarget;

            m_vTotalPan = Vector3.Zero;
            m_fLerp     = 0.0f;
            m_fLerpTime = vDiff.Length() / GlobalDefines.fCameraAnimSpeed;

            m_State = eCameraState.Animating;
        }
    /*
     * Goto
     *
     * sets up the camera so that it moves towards
     * a target in future update calls
     *
     * @param Vector3 target - the position to move towards
     * @param Vector3 targetEuler - the euler angle target
     * @param VoidFunc callback - function to call when the target is reached
     * @returns void
     */
    public void Goto(Vector3 target, Vector3 targetEuler, VoidFunc callback)
    {
        //remember the parameters
        m_cameraState    = eCameraState.TARGET;
        m_targetCallback = callback;

        //set the lerp positions and euler angles
        m_start  = transform.position;
        m_target = target;

        m_eulerStart = transform.eulerAngles;
        m_eulerEnd   = targetEuler;

        //reset the input
        m_smoothInput = Vector2.zero;

        m_movementTimer = 0.0f;
    }
    /*
     * UpdateFreeMovement
     *
     * sub-update that gets called when the camera is in TARGET mode
     *
     * @returns void
     */
    public void UpdateTargetMovement()
    {
        m_movementTimer += Time.deltaTime;

        //the timer cannot tick over the maximum
        if (m_movementTimer >= transitionTime)
        {
            //set the timer above the limit
            m_movementTimer = transitionTime + 0.01f;

            //snap to the target
            transform.position    = m_target;
            transform.eulerAngles = m_eulerEnd;
        }
        else
        {
            //evaluate the time curve
            float x = m_movementTimer / transitionTime;
            float y = transitionCurve.Evaluate(x);

            //apply a simple lerp to the position
            transform.position = Vector3.Lerp(m_start, m_target, y);
            //transform.eulerAngles = Vector3.Lerp(m_eulerStart, m_eulerEnd, y);
        }

        //check if the movement has finished
        if (m_movementTimer >= transitionTime)
        {
            //set the camera state back to free movement
            m_cameraState = eCameraState.FREE;

            //only invoke the call-back if one was specified
            if (m_targetCallback != null)
            {
                m_targetCallback.Invoke();
            }
        }
    }
示例#6
0
 public void ResetCamera()
 {
     m_vTotalPan = Vector3.Zero;
     m_vEye = new Vector3(0, 10, 10);
     m_vTarget = Vector3.Zero;
     m_State = eCameraState.Free;
 }
示例#7
0
        public void Update(float fDeltaTime)
        {
            if (m_State == eCameraState.Free)
            {
                m_vCurrPan *= GlobalDefines.fCameraSpeed * fDeltaTime;
                m_vTotalPan += m_vCurrPan;
                m_vTotalPan.X = MathHelper.Clamp(m_vTotalPan.X, m_vLevelMin.X, m_vLevelMax.X);
                m_vTotalPan.Z = MathHelper.Clamp(m_vTotalPan.Z, m_vLevelMin.Z, m_vLevelMax.Z);
            }
            else
            {
                if (m_fLerp < 1.0f)
                {
                    m_fLerp += fDeltaTime / m_fLerpTime;
                    m_vTarget = Vector3.Lerp(m_vOldTarget, m_vNewTarget, m_fLerp);
                    m_vEye = Vector3.Lerp(m_vOldEye, m_vNewEye, m_fLerp);
                }
                else
                {
                    m_State = eCameraState.Free;
                }
            }

            ComputeMatrix();
            m_vCurrPan = Vector3.Zero;
        }
示例#8
0
        public void SetTargetSmooth(Vector3 vTarget)
        {
            m_vOldEye = m_vEye;
            m_vOldTarget = m_vTarget;

            Vector3 vDiff = vTarget - m_vTarget;
            m_vNewEye = m_vEye + vDiff;
            m_vNewTarget = vTarget;

            m_vTotalPan = Vector3.Zero;
            m_fLerp = 0.0f;
            m_fLerpTime = vDiff.Length() / GlobalDefines.fCameraAnimSpeed;

            m_State = eCameraState.Animating;
        }