예제 #1
0
    private void ClearTitleEventObjects(TitleEventStatus flag)
    {
        switch (flag)
        {
        case TitleEventStatus.OFF:
            break;

        case TitleEventStatus.META_DATA:
            StartCoroutine(TitleMetaDataFade(ChildObjFadeStatus.CLOSE));
            break;

        case TitleEventStatus.FIGURES:
            StartCoroutine(ThumbnailFade(ChildObjFadeStatus.CLOSE));
            break;

        case TitleEventStatus.TAGS:
            StartCoroutine(TitleTagsFade(ChildObjFadeStatus.CLOSE));
            break;

        case TitleEventStatus.VIDEO:
            StartCoroutine(PageOrg.VideoFade(VideoObj, ChildObjFadeStatus.CLOSE));
            break;

        default:
            Debug.Log("[TitleEvent] unhandled levels:" + flag);
            break;
        }
    }
예제 #2
0
    /// <summary>
    /// Animtate the position and scale of the root canvas of title event objects
    /// </summary>
    /// <param name="status"></param>
    /// <param name="newTitleStatus"></param>
    /// <returns></returns>
    private IEnumerator TitleCanvasFade(CanvasFadeStatus status, TitleEventStatus newTitleStatus, float posX = 0, float posY = 0)
    {
        if (status == CanvasFadeStatus.CLOSE)
        {
            for (float i = CANVAS_CLOSE_TIME; i >= 0; i -= Time.deltaTime)
            {
                float percentage = i / CANVAS_CLOSE_TIME;
                // Cell gets bigger and bigger, until it finally appears.
                gameObject.transform.localScale = Vector3.one * percentage;
                yield return(null);
            }
        }
        else if (status == CanvasFadeStatus.OPEN)
        {
            // For the x-rotation, it is restricted to 0 (vertical) to 90 (flat horizontal). For the y-axis, it is free (user turns head 360 degrees in round desk).
            // And z-rotation is set to 0 so its text is parallel to ground.
            Vector3 targetVec = PageOrg.CalcTargetEulerAngles();
            gameObject.transform.localEulerAngles = targetVec;

            // Update: since the pie menu center is anchored to center, we just need to move a little bit to save space for titles.
            gameObject.transform.position = PageOrg.CurrDocObj.transform.position;
            // Move along top (negative y-axis of AR tag, DOWN)
            gameObject.transform.Translate(-PageOrg.CurrDocObj.transform.up * (0.06f * Mathf.Sin(targetVec.x * Mathf.Deg2Rad)), Space.World);

            //gameObject.transform.Translate(new Vector3(0, 0.06f * Mathf.Sin(targetVec.x * Mathf.Deg2Rad), 0.06f * Mathf.Cos(targetVec.x * Mathf.Deg2Rad)), Space.World);

            Vector3 moveUp = new Vector3(0, 0.06f * Mathf.Cos(targetVec.x * Mathf.Deg2Rad), 0);

            for (float i = 0; i <= CANVAS_OPEN_TIME; i += Time.deltaTime)
            {
                float percentage = i / CANVAS_OPEN_TIME;
                // Cell gets bigger and bigger, until it finally appears.
                gameObject.transform.Translate(moveUp * Time.deltaTime / CANVAS_OPEN_TIME, Space.World);
                gameObject.transform.localScale = Vector3.one * percentage;
                yield return(null);
            }
            Debug.Log("New Opened Title euler angles:" + gameObject.transform.localEulerAngles);
        }
        else if (status == CanvasFadeStatus.MODIFY)
        {
            Vector3 targetVec = PageOrg.CalcTargetEulerAngles();
            gameObject.transform.localEulerAngles = targetVec;

            Vector3 oldPos = gameObject.transform.position;
            gameObject.transform.position = PageOrg.CurrDocObj.transform.position;
            // Move along top (negative y-axis of AR tag, DOWN)
            gameObject.transform.Translate(-PageOrg.CurrDocObj.transform.up * (0.06f * Mathf.Sin(targetVec.x * Mathf.Deg2Rad)), Space.World);
            // Move up (world)
            gameObject.transform.Translate(0, 0.06f * Mathf.Cos(targetVec.x * Mathf.Deg2Rad), 0, Space.World);
            Vector3 posDist = gameObject.transform.position - oldPos;

            for (float i = 0; i <= CANVAS_OPEN_TIME; i += Time.deltaTime)
            {
                float percentage = i / CANVAS_OPEN_TIME;
                //gameObject.transform.localEulerAngles += anglePerSec * Time.deltaTime;
                gameObject.transform.position = oldPos + posDist * percentage;
                yield return(null);
            }
            Debug.Log("Modified Title euler angles:" + gameObject.transform.localEulerAngles);
        }
    }
예제 #3
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="newDoc"></param>
    /// <param name="normPosX">Normalized position X</param>
    /// <param name="normPosY">Normalized position Y</param>
    /// <param name="newTitleEvent"></param>
    public void UpdateTitleEvent(TitleEventStatus newTitleEvent, string newDoc = "", float normPosX = 0, float normPosY = 0)
    {
        bool updateDoc = (newDoc.Length > 0);

        // Same Doc Diff Type: if from OFF: open canvas, open new content, else: clear old, keep canvas, and open new content
        // Diff Doc Diff Type: if from OFF: open canvas, open new content, else: clear old, modify canvas, open new
        // Diff Doc Same Type: modify canvas, close&open new
        switch (newTitleEvent)
        {
        case TitleEventStatus.OFF:
            if (titleFlag != TitleEventStatus.OFF)
            {
                ClearTitleEventObjects(titleFlag);
                StartCoroutine(TitleCanvasFade(CanvasFadeStatus.CLOSE, titleFlag));
                titleFlag = TitleEventStatus.OFF;
            }
            break;

        case TitleEventStatus.META_DATA:
            if (titleFlag != TitleEventStatus.META_DATA)
            {
                if (titleFlag == TitleEventStatus.OFF)
                {
                    StartCoroutine(TitleCanvasFade(CanvasFadeStatus.OPEN, TitleEventStatus.META_DATA, normPosX, normPosY));
                }
                else
                {
                    ClearTitleEventObjects(titleFlag);

                    if (updateDoc)
                    {
                        StartCoroutine(TitleCanvasFade(CanvasFadeStatus.MODIFY, TitleEventStatus.META_DATA, normPosX, normPosY));
                    }
                }
                StartCoroutine(TitleMetaDataFade(ChildObjFadeStatus.OPEN, PageOrg.CurrARDoc));
            }
            else if (updateDoc)
            {
                // Switch to different content (different location),  flag unchanged
                StartCoroutine(TitleCanvasFade(CanvasFadeStatus.MODIFY, TitleEventStatus.META_DATA, normPosX, normPosY));
                StartCoroutine(TitleMetaDataFade(ChildObjFadeStatus.CLOSE_AND_OPEN, PageOrg.CurrARDoc));
            }
            titleFlag = TitleEventStatus.META_DATA;
            break;

        case TitleEventStatus.FIGURES:
            if (titleFlag != TitleEventStatus.FIGURES)
            {
                if (titleFlag == TitleEventStatus.OFF)
                {
                    StartCoroutine(TitleCanvasFade(CanvasFadeStatus.OPEN, TitleEventStatus.FIGURES, normPosX, normPosY));
                }
                else
                {
                    ClearTitleEventObjects(titleFlag);

                    if (updateDoc)
                    {
                        StartCoroutine(TitleCanvasFade(CanvasFadeStatus.MODIFY, TitleEventStatus.FIGURES, normPosX, normPosY));
                    }
                }

                // Turn it ON
                if (thumbList.Count > 0 && thumbList[0].name.Contains(PageOrg.CurrDocStr))
                {
                    // Exists, and is the same, then just resume.
                    StartCoroutine(ThumbnailFade(ChildObjFadeStatus.OPEN, normPosX, normPosY));
                }
                else
                {
                    // Not loaded yet, then load now (to the _thumbObjects dict)
                    LoadNewThumbnails(PageOrg.CurrDocStr);
                    // Open the canvas
                    StartCoroutine(ThumbnailFade(ChildObjFadeStatus.OPEN, normPosX, normPosY));
                }
            }
            else if (updateDoc)
            {
                // Different: destroy old ones and create new ones, flag unchanged
                StartCoroutine(TitleCanvasFade(CanvasFadeStatus.MODIFY, TitleEventStatus.FIGURES, normPosX, normPosY));
                StartCoroutine(ThumbnailFade(ChildObjFadeStatus.CLOSE_AND_OPEN, normPosX, normPosY));
            }
            titleFlag = TitleEventStatus.FIGURES;
            break;

        case TitleEventStatus.TAGS:
            if (titleFlag != TitleEventStatus.TAGS)
            {
                // Close the old one, and then open the tags

                if (titleFlag == TitleEventStatus.OFF)
                {
                    StartCoroutine(TitleCanvasFade(CanvasFadeStatus.OPEN, TitleEventStatus.TAGS, normPosX, normPosY));
                }
                else
                {
                    ClearTitleEventObjects(titleFlag);

                    if (updateDoc)
                    {
                        StartCoroutine(TitleCanvasFade(CanvasFadeStatus.MODIFY, TitleEventStatus.TAGS, normPosX, normPosY));
                    }
                }

                // Turn it ON
                if (tagsList.Count > 0 && tagsList[0].name.Contains(PageOrg.CurrDocStr))
                {
                    // Exists, and is the same, then just resume.
                    StartCoroutine(TitleTagsFade(ChildObjFadeStatus.OPEN));
                }
                else
                {
                    // Not loaded yet, then load now
                    LoadTags(PageOrg.CurrDocStr);
                    // Start the animation
                    StartCoroutine(TitleTagsFade(ChildObjFadeStatus.OPEN));
                }
            }
            else if (updateDoc)
            {
                // Different: destroy old ones and create new ones, flag unchanged
                StartCoroutine(TitleCanvasFade(CanvasFadeStatus.MODIFY, TitleEventStatus.TAGS, normPosX, normPosY));
                StartCoroutine(TitleTagsFade(ChildObjFadeStatus.CLOSE_AND_OPEN));
            }
            titleFlag = TitleEventStatus.TAGS;
            break;

        case TitleEventStatus.VIDEO:
            if (titleFlag != TitleEventStatus.VIDEO)
            {
                if (titleFlag == TitleEventStatus.OFF)
                {
                    StartCoroutine(TitleCanvasFade(CanvasFadeStatus.OPEN, TitleEventStatus.VIDEO, normPosX, normPosY));
                }
                else
                {
                    ClearTitleEventObjects(titleFlag);
                    if (updateDoc)
                    {
                        StartCoroutine(TitleCanvasFade(CanvasFadeStatus.MODIFY, TitleEventStatus.VIDEO, normPosX, normPosY));
                    }
                }

                if (PageOrg.CurrARDoc != null && PageOrg.CurrARDoc.videoLink.Length > 0)
                {
                    StartCoroutine(PageOrg.VideoFade(VideoObj, ChildObjFadeStatus.OPEN, PageOrg.CurrARDoc.videoLink));
                }
            }
            else if (updateDoc)
            {
                // Play video for anothe document.
                if (PageOrg.CurrARDoc != null && PageOrg.CurrARDoc.videoLink.Length > 0)
                {
                    StartCoroutine(TitleCanvasFade(CanvasFadeStatus.MODIFY, TitleEventStatus.VIDEO, normPosX, normPosY));
                    StartCoroutine(PageOrg.VideoFade(VideoObj, ChildObjFadeStatus.CLOSE_AND_OPEN, PageOrg.CurrARDoc.videoLink));
                }
            }
            titleFlag = TitleEventStatus.VIDEO;
            break;

        default:
            Debug.Log("UpdateTitleEvent: Unrecognized event id " + newTitleEvent);
            break;
        }
    }