/*
  *	Switch from perspective to ortographic and back
  */
 public void SwitchPerspective(float seconds)
 {
     orthoOn = !orthoOn;
     if (orthoOn)
     {
         blender.BlendToMatrix(camera, ortho, seconds);
     }
     else
     {
         blender.BlendToMatrix(camera, perspective, seconds);
     }
 }
    //void Update()
    //{
    //    if (Input.GetKeyDown(KeyCode.Space))
    //    {
    //        SwitchPerspective(1.5f,);
    //    }
    //}

    public void SwitchPerspective(float os, float t)
    {
        orthoOn = !orthoOn;
        ortho   = Matrix4x4.Ortho(-os * aspect, os * aspect, -os, os, near, far);
        if (orthoOn)
        {
            blender.BlendToMatrix(ortho, t);
        }
        else
        {
            blender.BlendToMatrix(perspective, t);
        }
    }
Beispiel #3
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         orthoOn = !orthoOn;
         if (orthoOn)
         {
             blender.BlendToMatrix(ortho, lerpTime);
         }
         else
         {
             blender.BlendToMatrix(perspective, lerpTime);
         }
     }
 }
Beispiel #4
0
    private void Update()
    {
        angle = target.eulerAngles.y;


        if (Input.GetKeyDown(KeyCode.Space))
        {
            orthoOn = !orthoOn;
            if (orthoOn)
            {
                blender.BlendToMatrix(ortho, point, offset, angle, 1f);
            }
            else
            {
                blender.BlendToMatrix(perspective, point, offset, angle, 1f);
            }
        }
    }
Beispiel #5
0
 private void Blend()
 {
     if (m_Camera != null)
     {
         if (orthoOn)
         {
             blender.BlendToMatrix(ortho, animationTime, currentCallback);
         }
         else
         {
             blender.BlendToMatrix(perspective, animationTime, currentCallback);
         }
     }
     else
     {
         Invoke("Blend", 0.1f);
     }
 }
Beispiel #6
0
 public void SwitchToPerspectiveMode()
 {
     blender.BlendToMatrix(perspective, 2f);
 }
Beispiel #7
0
 public void Activate(Transform targetPosition)
 {
     activeTargetPosition = targetPosition;
     _matrixBlender.BlendToMatrix(Matrix4x4.Ortho(-orthographicSize * aspect, orthographicSize * aspect, -orthographicSize, orthographicSize, near, far), transitionTime);
 }
Beispiel #8
0
 void Orthoon(float duration)
 {
     orthoOn = true;
     blender.BlendToMatrix(ortho, duration);
 }
Beispiel #9
0
    // This function handles movement of the camera between 2D and 3D shots,
    // and the changing of projection mode
    void Shift(bool dim, float time)
    {
        // Assign global variables to values of event parameters
        dimension = dim;
        GetComponent <CinemachineBrain> ().m_DefaultBlend.m_Time = time;

        // if shifting to 3d...
        if (dim)
        {
            // switch to the freelook camera.
            MoveCamera(5);

            // Refers to the Matrixblender script to change perspective
            if (blendingOrtho)
            {
                blender.BlendToMatrix(pers, time);
            }
        }

        // else, if shifting to 2d...
        else
        {
            // if this is the very first time shift is called...
            if (startFlag)
            {
                // if the game starts in 2D, camera is moved by shotchange,
                // and we instantly blend to orthographic
                if (blendingOrtho)
                {
                    blender.BlendToMatrix(ortho, 0.001f);
                }
            }

            else
            {
                // Get the location of the freelook camera
                List <GameObject>  temp         = shot_reference.GetRange(0, 4);
                ICinemachineCamera locationtemp = GetComponent <CinemachineBrain> ().ActiveVirtualCamera;
                GameObject         location     = locationtemp.VirtualCameraGameObject;

                // iterate through the 4 2d shots, can move to the one closest to the freelook camera
                float shortest = Mathf.Infinity;
                float distance = 0;
                int   index    = 0;

                foreach (GameObject camera in temp)
                {
                    distance = Vector3.Distance(location.transform.position, camera.transform.position);
                    if (distance < shortest)
                    {
                        shortest = distance;
                        index    = temp.IndexOf(camera);
                    }
                }

                // trigger a shotchange event, which will in turn move the camera.
                if (world_controller)
                {
                    world_controller.ShotChangeOnExternalCall(index + 1);
                }


                // Refers to the Matrixblender script to change perspective
                if (blendingOrtho)
                {
                    blender.BlendToMatrix(ortho, time);
                }
            }
        }

        startFlag = false;
    }