private void lockCam(bool isLock)
    {
        isLocked = isLock;


        if (!isLocked)
        {
            topCam.GetComponent <CameraLink>().enabled = true;

            StopAllCoroutines();
            cocounter = 0;
            //ResetCam.resetCam(Camera.main);
            topCam.transform.position = new Vector3(topCam.transform.position.x, 256, topCam.transform.position.z);
            topCam.orthographicSize   = 256;

            lockButton.gameObject.SetActive(false);
            ResetCam.OrientCamera(Camera.main, topCam.transform.position, topCam.transform.rotation, (1f / 120f));

            lockButton.gameObject.GetComponent <Image>().sprite = unlockImage;
        }
        else
        {
            lockButton.gameObject.GetComponent <Image>().sprite = lockImage;
        }
    }
 private void OnEnable()
 {
     ResetCam.resetCam(Camera.main);
     dirIndicator.SetActive(true);
     dirBar.SetActive(true);
     isEnabled = true;
 }
Beispiel #3
0
 public void unpitchCam()
 {
     //if (coroutine != null)
     //  StopCoroutine(coroutine);
     //if pitched, unpitch
     if (isPitched)
     {
         //coroutine = TouchController.OrientCamera(this.GetComponent<Camera>(), transform.position, Quaternion.Euler(new Vector3(0, 1, 0)));
         //coroutine = pitchCam(transform, transform.eulerAngles, new Vector3(90f, 0, 0), Rate);
         //StartCoroutine(coroutine);
         ResetCam.OrientCamera(Camera.main, topCam.transform.position, topCam.transform.rotation, (1f / 120f));
         //transform.eulerAngles = new Vector3(90f, 0, 0);
         isPitched = false;
     }
 }
Beispiel #4
0
    public void changeLoc(int val)
    {
        try
        {
            if (locations.currentStoredLocation != trialPiars[val].locationName)
            {
                locations.locationFunctionPairs[trialPiars[val].locationName].Invoke();
            }

            currentLocNumber = val;
            inputField.text  = val.ToString();
            m_Dropdown.value = val;

            StartCoroutine(setProjectors(val));
            ResetCam.resetCam();
            OnLocationChange(m_Dropdown);
        }
        catch (System.Exception e) { }
    }
Beispiel #5
0
 private void OnEnable()
 {
     pitchButton.SetActive(true);
     ResetCam.resetCam();
 }
Beispiel #6
0
 private void OnEnable()
 {
     ResetCam.resetCam();
 }
Beispiel #7
0
    // Update is called once per frame
    void Update()
    {
        if (!EventSystem.current.IsPointerOverGameObject())
        {
            if (Input.touchCount == 1)
            {
                foreach (Touch t in Input.touches)
                {
                    if (t.phase == TouchPhase.Began)
                    {
                    }
                    else if (t.phase == TouchPhase.Moved)
                    {
                        if (isActive)
                        {
                            Vector2 overlayCoords  = viewPane.GetComponent <RectTransform>().position;
                            Vector3 touchInOverlay = t.position - overlayCoords;

                            Vector2 olWH            = new Vector2((viewPane.GetComponent <RectTransform>().rect.width / 2), (viewPane.GetComponent <RectTransform>().rect.height / 2));
                            Vector2 touchPortCoords = new Vector3(((touchInOverlay.x / olWH.x) + 1.4f) / 2.8f, ((touchInOverlay.y / olWH.y) + 1.1f) / 2.2f);
                            //Debug.Log(touchPortCoords);
                            Vector3 worldP = topCam.ViewportToWorldPoint(new Vector3(touchPortCoords.x, touchPortCoords.y, topCam.transform.position.y));

                            //Vector3 worldP = setCam.ScreenToWorldPoint(new Vector3(t.position.x, t.position.y, 2000));
                            Vector3    dir = (worldP - topCam.transform.position).normalized;
                            RaycastHit hit;
                            Physics.Raycast(topCam.transform.position + (dir * topCam.nearClipPlane), dir, out hit, topCam.farClipPlane);


                            if (move_time == 0)
                            {
                                move_time = Time.time;
                            }
                            stationary_time = 0;
                            endTouch        = hit.point;
                            endSphere.transform.position = hit.point;
                            startSphere.SetActive(false);
                            endSphere.SetActive(true);
                            if (Time.time - move_time >= 0.2)
                            {
                                viewPane.SetActive(true);
                                maskPanel.SetActive(true);
                                viewPane.GetComponent <ViewPaneTexture>().fadeIn((1f / 5f));
                            }
                            touchEndPosPanel.transform.position = t.position;
                            touchEndPosPanel.SetActive(true);
                            if (coroutine != null && Time.time - move_time > 0.1)
                            {
                                cocounter = 0;
                                StopAllCoroutines();// (coroutine);
                            }

                            Vector3 startViewOffset = new Vector3();
                            Vector3 endViewOffset   = new Vector3();

                            while (Physics.Linecast(startTouch + startViewOffset, endTouch + endViewOffset))
                            {
                                startViewOffset += new Vector3(0, 0.1f, 0);
                                endViewOffset   += new Vector3(0, 0.01f, 0);
                            }

                            startViewOffset += new Vector3(0, 0.1f * Vector3.Distance(touchStartPosPanel.transform.position, touchEndPosPanel.transform.position), 0);

                            if (cocounter == 0)
                            {
                                coroutine = TouchController.OrientCamera(Camera.main, startTouch + startViewOffset + ((startTouch - endTouch).normalized * 30), endTouch + endViewOffset, Rate);
                                StartCoroutine(coroutine);
                                cocounter++;
                            }
                        }
                    }
                    else if (t.phase == TouchPhase.Ended)
                    {
                        stationary_time = 0;
                        if (isActive)
                        {
                            move_time = 0;
                            isActive  = false;
                            viewPane.SetActive(false);
                            maskPanel.SetActive(false);
                            endSphere.SetActive(false);
                            startSphere.SetActive(false);
                            touchStartPosPanel.SetActive(false);
                            touchEndPosPanel.SetActive(false);


                            topCam.GetComponent <CameraLink>().enabled = true;

                            StopAllCoroutines();
                            cocounter = 0;
                            //ResetCam.resetCam(Camera.main);
                            topCam.transform.position = new Vector3(topCam.transform.position.x, 256, topCam.transform.position.z);
                            topCam.orthographicSize   = 256;
                            cocounter++;
                            ResetCam.OrientCamera(Camera.main, topCam.transform.position, topCam.transform.rotation, (1f / 120f));

                            //StartCoroutine(TouchController.OrientCamera(Camera.main, topCam.transform.position, topCam.transform.position - new Vector3(0,1,0), Rate * 0.3f));
                        }
                    }
                    else if (t.phase == TouchPhase.Stationary)
                    {
                        move_time = 0;
                        if (stationary_time == 0)
                        {
                            stationary_time = Time.time;
                        }

                        if (isActive == false && (Time.time - stationary_time) > 0.4f)
                        {
                            Vector3    worldP = Camera.main.ScreenToWorldPoint(new Vector3(t.position.x, t.position.y, 1200));
                            Vector3    dir    = (worldP - Camera.main.transform.position).normalized;
                            RaycastHit hit;
                            Physics.Raycast(Camera.main.transform.position + (dir * Camera.main.nearClipPlane), dir, out hit, Camera.main.farClipPlane);

                            isActive   = true;
                            startTouch = hit.point + new Vector3(0, 2, 0);
                            startSphere.transform.position = hit.point;
                            startSphere.SetActive(true);
                            viewPane.SetActive(true);
                            maskPanel.SetActive(true);
                            CameraLink.syncView(Camera.main, topCam);
                            topCam.GetComponent <CameraLink>().enabled = false;
                            //determine where the start touch panel should be
                            //Startwith finding its position on the topcam screen
                            touchStartPosPanel.transform.position = (topCam.WorldToScreenPoint(hit.point));
                            //Then convert to UI space
                            touchStartPosPanel.transform.position = new Vector3(touchStartPosPanel.transform.position.x, touchStartPosPanel.transform.position.y, 0);
                            //Then finally convert to overlay space
                            Vector3 vpSpace = topCam.ScreenToViewportPoint(touchStartPosPanel.transform.position);
                            Vector2 olWH    = new Vector2((viewPane.GetComponent <RectTransform>().rect.width), (viewPane.GetComponent <RectTransform>().rect.height));
                            touchStartPosPanel.transform.localPosition = new Vector3((vpSpace.x * olWH.x) - olWH.x / 2, (vpSpace.y * olWH.y) - olWH.y / 2);

                            touchStartPosPanel.SetActive(true);
                            maskPanel.transform.position = touchStartPosPanel.transform.position;
                        }
                        else
                        {
                            if (Time.time - stationary_time > 1)
                            {
                                if (viewPane.activeSelf)
                                {
                                    viewPane.GetComponent <ViewPaneTexture>().fadeTexture(0, Rate * 3);
                                }

                                //CameraLink.syncCam(Camera.main, topCam);

                                // determine where the start touch panel should be
                                //Startwith finding its position on the topcam screen
                                touchStartPosPanel.transform.position = (topCam.WorldToScreenPoint(startSphere.transform.position));
                                //Then convert to UI space
                                touchStartPosPanel.transform.position = new Vector3(touchStartPosPanel.transform.position.x, touchStartPosPanel.transform.position.y, 0);
                                //Then finally convert to overlay space
                                Vector3 vpSpace = topCam.ScreenToViewportPoint(touchStartPosPanel.transform.position);
                                Vector2 olWH    = new Vector2((viewPane.GetComponent <RectTransform>().rect.width), (viewPane.GetComponent <RectTransform>().rect.height));
                                touchStartPosPanel.transform.localPosition = new Vector3((vpSpace.x * olWH.x) - olWH.x / 2, (vpSpace.y * olWH.y) - olWH.y / 2);
                            }
                            if (Time.time - stationary_time > 3)
                            {
                                endSphere.SetActive(false);
                            }
                            //viewPane.SetActive(false);
                        }
                    }
                }
            }
        }
    }
Beispiel #8
0
 private void OnEnable()
 {
     ResetCam.resetCam(Camera.main);
     ResetCam.resetCam(setCam);
     isEnabled = true;
 }
    // Update is called once per frame
    void Update()
    {
        if (!EventSystem.current.IsPointerOverGameObject())
        {
            if (Input.touchCount == 1)
            {
                foreach (Touch t in Input.touches)
                {
                    if (t.phase == TouchPhase.Began)
                    {
                    }
                    else if (t.phase == TouchPhase.Moved)
                    {
                        if (isActive)
                        {
                            Vector3    worldP = topCam.ScreenToWorldPoint(new Vector3(t.position.x, t.position.y, 1200));
                            Vector3    dir    = (worldP - setCam.transform.position).normalized;
                            RaycastHit hit;
                            Physics.Raycast(topCam.transform.position + (dir * topCam.nearClipPlane), dir, out hit, topCam.farClipPlane);


                            if (move_time == 0)
                            {
                                move_time = Time.time;
                            }
                            stationary_time = 0;
                            endTouch        = hit.point;
                            endSphere.transform.position = hit.point;
                            startSphere.SetActive(false);
                            endSphere.SetActive(true);
                            if (Time.time - move_time >= 0.2)
                            {
                                viewPane.SetActive(true);
                            }

                            touchEndPosPanel.transform.position = t.position;
                            touchEndPosPanel.SetActive(true);
                            if (coroutine != null)
                            {
                                StopCoroutine(coroutine);
                            }

                            Vector3 startViewOffset = new Vector3();
                            Vector3 endViewOffset   = new Vector3();

                            while (Physics.Linecast(startTouch + startViewOffset, endTouch + endViewOffset))
                            {
                                startViewOffset += new Vector3(0, 0.1f, 0);
                                endViewOffset   += new Vector3(0, 0.01f, 0);
                            }
                            //touchStartPosPanel.transform.position = (setCam.WorldToScreenPoint(startTouch + startViewOffset));
                            coroutine = TouchController.OrientCamera(Camera.main, startTouch + startViewOffset, endTouch + endViewOffset, Rate);

                            StartCoroutine(coroutine);
                        }
                    }
                    else if (t.phase == TouchPhase.Ended)
                    {
                        stationary_time = 0;
                        if (isActive)
                        {
                            isActive = false;
                            viewPane.SetActive(false);
                            endSphere.SetActive(false);
                            touchStartPosPanel.SetActive(false);
                            touchEndPosPanel.SetActive(false);
                            ResetCam.resetCam(Camera.main);
                            ResetCam.resetCam(topCam);
                            //StartCoroutine(TouchController.OrientCamera(Camera.main, new Vector3(526,1000,526), new Vector3(90,0,0), Rate * 0.3f));
                            ResetCam.resetCam(setCam);
                            oldTouchPositions[0]             = null;
                            oldTouchPositions[1]             = null;
                            viewPane.transform.localPosition = new Vector3(-8.8f, -7.7f, 0);
                            viewPane.transform.eulerAngles   = new Vector3();
                        }
                    }
                    else if (t.phase == TouchPhase.Stationary)
                    {
                        move_time = 0;
                        if (stationary_time == 0)
                        {
                            stationary_time = Time.time;
                        }

                        if (isActive == false && (Time.time - stationary_time) > 1f)
                        {
                            Vector3    worldP = Camera.main.ScreenToWorldPoint(new Vector3(t.position.x, t.position.y, 1200));
                            Vector3    dir    = (worldP - Camera.main.transform.position).normalized;
                            RaycastHit hit;
                            Physics.Raycast(Camera.main.transform.position + (dir * Camera.main.nearClipPlane), dir, out hit, Camera.main.farClipPlane);

                            isActive   = true;
                            startTouch = hit.point + new Vector3(0, 2, 0);
                            startSphere.transform.position = hit.point;
                            startSphere.SetActive(true);
                            viewPane.SetActive(true);



                            touchStartPosPanel.transform.position = (topCam.WorldToScreenPoint(hit.point));
                            touchStartPosPanel.transform.position = new Vector3(touchStartPosPanel.transform.position.x, touchStartPosPanel.transform.position.y, 0);
                            touchStartPosPanel.SetActive(true);
                        }
                        else
                        {
                            if (Time.time - stationary_time > 0.5 && Time.time - stationary_time < 1.0f)
                            {
                                //topCam.transform.eulerAngles = new Vector3(90, Camera.main.transform.eulerAngles.y, 0);
                                topCam.transform.RotateAround(endSphere.transform.position, new Vector3(0, 1, 0), Camera.main.transform.eulerAngles.y);

                                setCam.transform.eulerAngles = new Vector3(90, Camera.main.transform.eulerAngles.y, 0);
                            }
                            else if (Time.time - stationary_time > 1 && Time.time - stationary_time < 3.0f)
                            {
                                viewPane.SetActive(false);
                            }
                            else if (Time.time - stationary_time > 3)
                            {
                                endSphere.SetActive(false);
                            }
                        }
                    }
                }
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        // if((!Camera.main.GetComponent<CameraState>().isPitched && !Camera.main.GetComponent<CameraState>().isRotated) || isActive)
        if (!EventSystem.current.IsPointerOverGameObject())
        {
            if (Input.touchCount == 1)
            {
                foreach (Touch t in Input.touches)
                {
                    if (t.phase == TouchPhase.Began)
                    {
                    }
                    else if (t.phase == TouchPhase.Moved)
                    {
                        if (isActive)
                        {
                            Vector2 overlayCoords  = viewPane.GetComponent <RectTransform>().position;
                            Vector3 touchInOverlay = t.position - overlayCoords;


                            Vector2 olWH            = new Vector2((viewPane.GetComponent <RectTransform>().rect.width / 2), (viewPane.GetComponent <RectTransform>().rect.height / 2));
                            Vector2 touchPortCoords = new Vector3(((touchInOverlay.x / olWH.x) + 1.4f) / 2.8f, ((touchInOverlay.y / olWH.y) + 1.1f) / 2.2f);


                            Vector3    worldP = topCam.ViewportToWorldPoint(new Vector3(touchPortCoords.x, touchPortCoords.y, topCam.transform.position.y));
                            Vector3    dir    = (worldP - topCam.transform.position).normalized;
                            RaycastHit hit;
                            bool       endHit = Physics.Raycast(topCam.transform.position + (dir * topCam.nearClipPlane), dir, out hit, topCam.farClipPlane);

                            while (!endHit)
                            {
                                worldP = (worldP + startSphere.transform.position) * 0.5f;
                                dir    = (worldP - topCam.transform.position).normalized;
                                endHit = Physics.Raycast(topCam.transform.position + (dir * topCam.nearClipPlane), dir, out hit, topCam.farClipPlane);
                            }



                            if (move_time == 0)
                            {
                                move_time = Time.time;
                            }
                            stationary_time              = 0;
                            endTouch                     = endHit? hit.point : lastFinalLocation;
                            lastFinalLocation            = endTouch;
                            endSphere.transform.position = hit.point;
                            startSphere.SetActive(false);

                            touchEndPosPanel.transform.position = t.position;
                            touchEndPosPanel.SetActive(true);

                            Vector3 startViewOffset = new Vector3();

                            Vector3 startPosAdj = Camera.main.ScreenToViewportPoint(touchStartPosPanel.transform.position);
                            startPosAdj.x = startPosAdj.x * Camera.main.aspect;

                            Vector3 endPosAdj = Camera.main.ScreenToViewportPoint(touchEndPosPanel.transform.position);
                            endPosAdj.x = endPosAdj.x * Camera.main.aspect;
                            float touchDist = Vector3.Distance(startPosAdj, endPosAdj);


                            //Get how far along the interaction we are in linear terms
                            float i = touchDist / interactionMaxDistance;
                            //Convert to a nonlinear for position
                            float jp = TouchController.smoothstep(0, 0.9f, i);
                            //Convert to a different nonlinear for rotation - use smoothstep frame for rotation with new rotation handling.
                            //double jr = System.Math.Tanh(System.Convert.ToDouble((Mathf.Clamp(i, 0, 1) * 2)));
                            float jr = jp * jp;

                            //Find the ground location
                            Physics.Raycast(startTouch, Vector3.down, out hit);
                            Vector3 finalLocation = hit.point + startViewOffset + ((startTouch - endTouch).normalized) * 30;// + endViewOffset;

                            //Lerp from the starting location to the end location
                            Camera.main.transform.position = Vector3.Lerp(startPos, finalLocation, jp);

                            //Set a deadzone on rotations

                            if (Vector3.Distance(Camera.main.ScreenToViewportPoint(touchStartPosPanel.transform.position),
                                                 Camera.main.ScreenToViewportPoint(touchEndPosPanel.transform.position)) > 0.1f)
                            {
                                //Determine where we should be looking by the end of the interaction
                                Quaternion endView = TouchController.LookAngle(startTouch, endTouch);

                                //Determine where we should be looking at the start of the interaction
                                Vector3    startLookDir3      = new Vector3(endTouch.x - startTouch.x, 0, endTouch.z - startTouch.z).normalized;
                                Quaternion startAngleAdjusted = Quaternion.LookRotation(Vector3.down, startLookDir3);

                                //Slerp from our new adjusted starting angle to the end angle
                                Quaternion finalRot = Quaternion.Slerp(startAngleAdjusted, endView, jr);

                                //Apply that slerp with max speed of 10
                                Camera.main.transform.rotation = Quaternion.RotateTowards(Camera.main.transform.rotation, finalRot, 25);
                            }
                        }
                    }
                    else if (t.phase == TouchPhase.Ended)
                    {
                        stationary_time = 0;
                        if (isActive)
                        {
                            move_time = 0;
                            isActive  = false;
                            viewPane.SetActive(false);
                            endSphere.SetActive(false);
                            startSphere.SetActive(false);
                            touchStartPosPanel.SetActive(false);
                            touchEndPosPanel.SetActive(false);

                            //    directionHelper.SetActive(false);


                            if (!isLocked)
                            {
                                lockButton.gameObject.SetActive(false);
                                topCam.GetComponent <CameraLink>().enabled = true;

                                StopAllCoroutines();
                                cocounter = 0;
                                //ResetCam.resetCam(Camera.main);
                                topCam.transform.position = new Vector3(topCam.transform.position.x, 256, topCam.transform.position.z);
                                topCam.orthographicSize   = 256;
                                ResetCam.OrientCamera(Camera.main, topCam.transform.position, topCam.transform.rotation, (1f / 120f));
                                //StartCoroutine(TouchController.OrientCamera(Camera.main, topCam.transform.position, topCam.transform.rotation, (1f/120f)));
                            }
                        }
                    }
                    else if (t.phase == TouchPhase.Stationary)
                    {
                        if (!isLocked)
                        {
                            move_time = 0;
                            if (stationary_time == 0)
                            {
                                stationary_time = Time.time;
                            }

                            if (isActive == false && (Time.time - stationary_time) > 0.4f)
                            {
                                Vector3    worldP = Camera.main.ScreenToWorldPoint(new Vector3(t.position.x, t.position.y, 1200));
                                Vector3    dir    = (worldP - Camera.main.transform.position).normalized;
                                RaycastHit hit;
                                Physics.Raycast(Camera.main.transform.position + (dir * Camera.main.nearClipPlane), dir, out hit, Camera.main.farClipPlane);

                                isActive   = true;
                                startTouch = hit.point + new Vector3(0, 2, 0);
                                startPos   = Camera.main.transform.position;
                                startAngle = Camera.main.transform.rotation;
                                startSphere.transform.position = hit.point;
                                startSphere.SetActive(true);
                                lockButton.gameObject.SetActive(true);
                                endSphere.SetActive(false);
                                viewPane.SetActive(true);
                                //    directionHelper.SetActive(true);
                                viewPane.GetComponent <CanvasRenderer>().SetAlpha(0);
                                CameraLink.syncView(Camera.main, topCam);
                                topCam.GetComponent <CameraLink>().enabled = false;
                                //determine where the start touch panel should be
                                //Startwith finding its position on the topcam screen
                                touchStartPosPanel.transform.position = (topCam.WorldToScreenPoint(hit.point));
                                //Then convert to UI space
                                touchStartPosPanel.transform.position = new Vector3(touchStartPosPanel.transform.position.x, touchStartPosPanel.transform.position.y, 0);
                                //Then finally convert to overlay space
                                Vector3 vpSpace = topCam.ScreenToViewportPoint(touchStartPosPanel.transform.position);
                                Vector2 olWH    = new Vector2((viewPane.GetComponent <RectTransform>().rect.width), (viewPane.GetComponent <RectTransform>().rect.height));
                                touchStartPosPanel.transform.localPosition = new Vector3((vpSpace.x * olWH.x) - olWH.x / 2, (vpSpace.y * olWH.y) - olWH.y / 2);

                                touchEndPosPanel.transform.position = touchStartPosPanel.transform.position + new Vector3(0, 0.1f, 0);
                                //dirBar.GetComponent<RectTransform>().sizeDelta = new Vector2(1, 1);

                                touchStartPosPanel.SetActive(true);
                                lockButton.transform.position = touchStartPosPanel.transform.position + new Vector3(0, -40f, 0);
                            }
                            else
                            {
                                if (Time.time - stationary_time > 1)
                                {
                                    //if (viewPane.activeSelf)
                                    //  viewPane.GetComponent<ViewPaneTexture>().fadeTexture(0, Rate * 12);

                                    //CameraLink.syncCam(Camera.main, topCam);

                                    // determine where the start touch panel should be
                                    //Startwith finding its position on the topcam screen
                                    touchStartPosPanel.transform.position = (topCam.WorldToScreenPoint(startSphere.transform.position));
                                    //Then convert to UI space
                                    touchStartPosPanel.transform.position = new Vector3(touchStartPosPanel.transform.position.x, touchStartPosPanel.transform.position.y, 0);
                                    //Then finally convert to overlay space
                                    Vector3 vpSpace = topCam.ScreenToViewportPoint(touchStartPosPanel.transform.position);
                                    Vector2 olWH    = new Vector2((viewPane.GetComponent <RectTransform>().rect.width), (viewPane.GetComponent <RectTransform>().rect.height));
                                    touchStartPosPanel.transform.localPosition = new Vector3((vpSpace.x * olWH.x) - olWH.x / 2, (vpSpace.y * olWH.y) - olWH.y / 2);
                                }
                                if (Time.time - stationary_time > 3)
                                {
                                    endSphere.SetActive(false);
                                }
                                //viewPane.SetActive(false);
                            }
                        }
                    }
                }
            }
        }
    }
Beispiel #11
0
 private void Start()
 {
     instance = this;
 }