Example #1
0
    public void HandleInteractiveHitTest(HitTestResult result)
    {
        //Debug.Log("WE ARE INSIDE HandleInteractiveHitTest");
        if (result == null)
        {
            Debug.LogError("Invalid hit test result!");
            return;
        }

        if (!m_GroundPlaneUI.IsCanvasButtonPressed())
        {
            Debug.Log("HandleInteractiveHitTest() called.");

            // If the PlaneFinderBehaviour's Mode is Automatic, then the Interactive HitTestResult will be centered.

            m_ContentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>();
            m_ContentPositioningBehaviour.DuplicateStage = false;

            // Place object based on Ground Plane mode
            switch (planeMode)
            {
            case PlaneMode.TGO:

                if (!m_TGOProductPlacement.IsPlaced || TGOTouchHandlerTest.DoubleTap)
                {
                    m_ContentPositioningBehaviour.AnchorStage = m_TGOAnchor;
                    m_ContentPositioningBehaviour.PositionContentAtPlaneAnchor(result);
                    UtilityHelperTest.EnableRendererColliderCanvas(m_TGOAugmentation, true);
                }

                if (!m_TGOProductPlacement.IsPlaced)
                {
                    m_TGOProductPlacement.SetProductAnchor(m_TGOAnchor.transform);
                    m_TGOTouchHandler.enableRotation  = true;
                    m_BEPITouchHandler.enableRotation = false;
                }

                break;

            case PlaneMode.BEPI:

                if (!m_BEPIProductPlacement.IsPlaced || BEPITouchHandlerTest.DoubleTap)
                {
                    m_ContentPositioningBehaviour.AnchorStage = m_BEPIAnchor;
                    m_ContentPositioningBehaviour.PositionContentAtPlaneAnchor(result);
                    UtilityHelperTest.EnableRendererColliderCanvas(m_BEPIAugmentation, true);
                }

                if (!m_BEPIProductPlacement.IsPlaced)
                {
                    m_BEPIProductPlacement.SetProductAnchor(m_BEPIAnchor.transform);
                    m_BEPITouchHandler.enableRotation = true;
                    m_TGOTouchHandler.enableRotation  = false;
                }

                break;
            }
        }
    }
Example #2
0
    public void HandleInteractiveHitTest(HitTestResult result)
    {
        if (result == null)
        {
            Debug.LogError("Invalid hit test result!");
            return;
        }

        if (m_StatusInfo == TrackableBehaviour.StatusInfo.NORMAL ||
            (m_StatusInfo == TrackableBehaviour.StatusInfo.UNKNOWN && !VuforiaRuntimeUtilities.IsPlayMode()))
        {
            if (!m_GroundPlaneUI.IsCanvasButtonPressed())
            {
                Debug.Log("HandleInteractiveHitTest() called.");

                // If the PlaneFinderBehaviour's Mode is Automatic, then the Interactive HitTestResult will be centered.

                // PlaneMode.Ground and PlaneMode.Placement both use PlaneFinder's ContentPositioningBehaviour
                m_ContentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>();
                m_ContentPositioningBehaviour.DuplicateStage = false;

                // Place object based on Ground Plane mode
                switch (planeMode)
                {
                case PlaneMode.GROUND:

                    m_ContentPositioningBehaviour.AnchorStage = m_PlaneAnchor;
                    m_ContentPositioningBehaviour.PositionContentAtPlaneAnchor(result);
                    UtilityHelper.EnableRendererColliderCanvas(m_PlaneAugmentation, true);

                    // Astronaut should rotate toward camera with each placement
                    m_PlaneAugmentation.transform.localPosition = Vector3.zero;
                    //UtilityHelper.RotateTowardCamera(m_PlaneAugmentation);

                    break;

                case PlaneMode.PLACEMENT:

                    if (!m_ProductPlacement.IsPlaced || TouchHandler.DoubleTap)
                    {
                        m_ContentPositioningBehaviour.AnchorStage = m_PlacementAnchor;
                        m_ContentPositioningBehaviour.PositionContentAtPlaneAnchor(result);
                        UtilityHelper.EnableRendererColliderCanvas(m_PlacementAugmentation, true);
                    }

                    if (!m_ProductPlacement.IsPlaced)
                    {
                        m_ProductPlacement.SetProductAnchor(m_PlacementAnchor.transform);
                        m_TouchHandler.enableRotation = true;
                    }

                    break;
                }
            }
        }
    }
Example #3
0
    public void HandleInteractiveHitTest(HitTestResult result)
    {
        if (result == null)
        {
            Debug.LogError("Invalid hit test result!");
            return;
        }

        if (!m_GroundPlaneUI.IsCanvasButtonPressed())
        {
            Debug.Log("HandleInteractiveHitTest() called.");

            // If the PlaneFinderBehaviour's Mode is Automatic, then the Interactive HitTestResult will be centered.

            // PlaneMode.Ground and PlaneMode.Placement both use PlaneFinder's ContentPositioningBehaviour
            m_ContentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>();
            m_ContentPositioningBehaviour.DuplicateStage = false;

            // Place object based on Ground Plane mode
            m_ContentPositioningBehaviour.AnchorStage = m_PlaneAnchor;
            m_ContentPositioningBehaviour.PositionContentAtPlaneAnchor(result);
            UtilityHelper.EnableRendererColliderCanvas(m_PlaneAugmentation, true);

            // Astronaut should rotate toward camera with each placement
            m_PlaneAugmentation.transform.localPosition = Vector3.zero;
            UtilityHelper.RotateTowardCamera(m_PlaneAugmentation);

            AstronautIsPlaced = true;
        }
    }
Example #4
0
    public void HandleInteractiveHitTest(HitTestResult result)
    {
        if (result == null)
        {
            //Debug.LogError("Invalid hit test result!");
            return;
        }

        if (!m_GroundPlaneUI.IsCanvasUIPressed())
        {
            if (indicator.activeSelf)
            {
                indicator.SetActive(false);
            }
            m_ContentPositioningBehaviour = m_PlaneFinderBehaviour.GetComponent <ContentPositioningBehaviour>();
            m_ContentPositioningBehaviour.DuplicateStage = false;

            if (!m_ProductPlacement.IsPlaced || TouchHandler.DoubleTap)
            {
                m_ContentPositioningBehaviour.AnchorStage = m_PlacementAnchor;
                m_ContentPositioningBehaviour.PositionContentAtPlaneAnchor(result);
                UtilityHelper.EnableRendererColliderCanvas(m_PlacementAugmentation, true);
            }

            if (!m_ProductPlacement.IsPlaced)
            {
                //m_ProductPlacement.SetProductAnchor(m_PlacementAnchor.transform);
                m_TouchHandler.enableRotation = true;
            }
        }
    }
Example #5
0
    public void HandleInteractiveHitTest(HitTestResult result)
    {
        Debug.Log("HandleInteractiveHitTest() called.");

        if (result == null)
        {
            Debug.LogError("Invalid hit test result!");
            return;
        }


        if (positionalDeviceTracker != null && positionalDeviceTracker.IsActive)
        {
            DestroyAnchors();

            contentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>();
            contentPositioningBehaviour.PositionContentAtPlaneAnchor(result);
            m_ResetButton.interactable = true;
        }

        if (!m_PlaneAugmentation.activeInHierarchy)
        {
            Debug.Log("Setting Plane Augmentation to Active");
            // On initial run, unhide the augmentation
            m_PlaneAugmentation.SetActive(true);
        }

        Debug.Log("Positioning Plane Augmentation at: " + result.Position);
        m_PlaneAugmentation.PositionAt(result.Position);
        RotateTowardCamera(m_PlaneAugmentation);
    }
Example #6
0
    public void HandleAutomaticHitTest(HitTestResult result)
    {
        AutomaticHitTestFrameCount = Time.frameCount;

        if (!m_Playmat.IsPlaced)
        {
            //m_Playmat.SetPlaymatAnchor(m_PlaymatAnchor.transform);
            m_Playmat.SetPlaced();
            m_ContentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>();
            m_ContentPositioningBehaviour.DuplicateStage = false;
            m_ContentPositioningBehaviour.PositionContentAtPlaneAnchor(result);
        }
    }
    public void HandleInteractiveHitTest(HitTestResult result)
    {
        Debug.Log("HandleInteractiveHitTest() called.");


        if (result == null && primo)
        {
            Debug.LogError("Invalid hit test result!");
            return;
        }

        // Place object based on Ground Plane mode
        switch (planeMode)
        {
        case PlaneMode.GROUND:
            //  Debug.Log("case PlaneGround");
            if (positionalDeviceTracker != null && positionalDeviceTracker.IsActive)
            {
                DestroyAnchors();

                contentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>();
                contentPositioningBehaviour.PositionContentAtPlaneAnchor(result);



                // m_ResetButton.interactable = true;
            }

            if (!m_PlaneAugmentation.activeInHierarchy && !primo)
            {
                Debug.Log("Setting Plane Augmentation to Active");
                // On initial run, unhide the augmentation

                m_PlaneAugmentation.SetActive(true);
                primo = true;
            }


            Debug.Log("Positioning Plane Augmentation at: " + cube.transform.position);

            m_PlaneAugmentation.PositionAt(cube.transform.position);
            RotateTowardImageTarget(m_PlaneAugmentation);


            break;

        default:
            Debug.LogError("Invalid Ground Plane state: " + planeMode);
            break;
        }
    }
Example #8
0
    public void HandleInteractiveHitTest(HitTestResult result)
    {
        Debug.Log("HandleInteractiveHitTest() called.");

        if (result == null)
        {
            Debug.LogError("Invalid hit test result!");
            return;
        }


        // Place object based on Ground Plane mode
        switch (planeMode)
        {
        case PlaneMode.GROUND:

            if (positionalDeviceTracker != null && positionalDeviceTracker.IsActive)
            {
                DestroyAnchors();

                contentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>();
                contentPositioningBehaviour.PositionContentAtPlaneAnchor(result);

//					if (!m_MidAirToggle.interactable)
//					{
                // Runs only once after first successful Ground Anchor is created
//						m_MidAirToggle.interactable = true;
//						m_ResetButton.interactable = true;
//					}
            }

            if (blockToggle.isOn)
            {
                Vector2d geoloc = result.Position.GetGeoPosition(_map.CenterMercator, _map.WorldRelativeScale);
                BlocksSpawner.Instance.SaveMessage("test", result.Position.y, geoloc.x, geoloc.y, Input.location.lastData.altitude, 1, 1);
                BlocksSpawner.Instance.CleanPool(true);
            }
            //Debug.Log("Positioning Plane Augmentation at: " + result.Position);
            //m_PlaneAugmentation.PositionAt(result.Position);
            //RotateTowardCamera(m_PlaneAugmentation);

            break;

        default:
            Debug.LogError("Invalid Ground Plane state: " + planeMode);
            break;
        }
    }
Example #9
0
    public void HandleInteractiveHitTest(HitTestResult result)
    {
        Debug.Log("HandleInteractiveHitTest() called.");

        if (result == null)
        {
            Debug.LogError("Invalid hit test result!");
            return;
        }

        // Place object based on Ground Plane mode
        switch (planeMode)
        {
        case PlaneMode.GROUND:

            if (positionalDeviceTracker != null && positionalDeviceTracker.IsActive)
            {
                DestroyAnchors();

                contentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>();
                contentPositioningBehaviour.PositionContentAtPlaneAnchor(result);

                if (!m_MidAirToggle.interactable)
                {
                    // Runs only once after first successful Ground Anchor is created
                    m_MidAirToggle.interactable = true;
                    m_ResetButton.interactable  = true;
                }
            }

            if (!m_PlaneAugmentation.activeInHierarchy)
            {
                Debug.Log("Setting Plane Augmentation to Active");
                // On initial run, unhide the augmentation
                m_PlaneAugmentation.SetActive(true);
            }

            Debug.Log("Positioning Plane Augmentation at: " + result.Position);
            m_PlaneAugmentation.PositionAt(result.Position);
            RotateTowardCamera(m_PlaneAugmentation);

            break;

        default:
            Debug.LogError("Invalid Ground Plane state: " + planeMode);
            break;
        }
    }
Example #10
0
    public void HandleInteractiveHitTest(HitTestResult result)
    {
        if (result == null)
        {
            Debug.LogError("Invalid hit test result!");
            return;
        }

        if (!m_GroundPlaneUI.IsCanvasButtonPressed() && allowInterActive)
        {
            Debug.Log("HandleInteractiveHitTest() called.");

            // If the PlaneFinderBehaviour's Mode is Automatic, then the Interactive HitTestResult will be centered.

            // PlaneMode.Ground and PlaneMode.Placement both use PlaneFinder's ContentPositioningBehaviour
            m_ContentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>();
            m_ContentPositioningBehaviour.DuplicateStage = false;

            // Place object based on Ground Plane mode
            switch (planeMode)
            {
            case PlaneMode.GROUND:

                m_ContentPositioningBehaviour.AnchorStage = m_PlaneAnchor;
                m_ContentPositioningBehaviour.PositionContentAtPlaneAnchor(result);
                UtilityHelper.EnableRendererColliderCanvas(m_PlaneAugmentation, true);

                // Astronaut should rotate toward camera with each placement
                m_PlaneAugmentation.transform.localPosition = Vector3.zero;
                UtilityHelper.RotateTowardCamera(m_PlaneAugmentation);

                CityIsPlaced     = true;
                allowInterActive = false;
                if (CommonData.currentUser == null)
                {
                    CommonData.currentUser = new DBStruct <UserData>("player");
                }
                // CommonData.currentUser.data.Plus += 300;
                // CommonData.currentUser.data.Minus -= 200;
                CommonData.mainManager.stateManager.PushState(new ShowTitle());
                CommonData.prefabs.gameobjectLookup[StringConstants.ARCamera].GetComponent <AudioSource>().Play();
                // CommonData.StateAnimal = true;
                setOblect = true;
                break;
            }
        }
    }
Example #11
0
    public void HandleInteractiveHitTest(HitTestResult result)
    {
        if (PlaymatIsPlaced)
        {
            return;
        }
        if (result == null)
        {
            Debug.LogError("Invalid hit test result!");
            return;
        }

        m_ContentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>();
        m_ContentPositioningBehaviour.DuplicateStage = false;
        m_ContentPositioningBehaviour.PositionContentAtPlaneAnchor(result);
        m_PlaneFinder.enabled = false;
        PlaymatIsPlaced       = true;
    }
Example #12
0
    //Place the selected model on the ground plane
    public void placeOnGroundPlane(HitTestResult result)
    {
        if (!modelPlaced)
        {
            debugText.text = "modelSelected: " + modelSelected + " modelBrowserWindow: " + modelBrowserWindow.activeSelf;
        }
        else
        {
            debugText.text = "Model Placed!" + " modelSelected: " + modelSelected + " modelBrowserWindow: " + modelBrowserWindow.activeSelf;
        }

        if (!modelPlaced && modelSelected && !modelBrowserWindow.activeSelf)
        {
            debugText.text = selectedModel.name + ": " + selectedModel.transform.position;
            selectedModel.SetActive(true);
            selectedModel.transform.SetParent(groundPlane);          //Make ground plane parent of model
            contentPositioning.PositionContentAtPlaneAnchor(result); //Place model
            modelPlaced   = true;
            modelSelected = false;
            selectedModel.GetComponentInChildren <MeshRenderer>().enabled = false;
        }
    }
Example #13
0
    private void SpawnDroid()
    {
        Debug.Log("SpawnDroid Setting Plane Augmentation to Active");

        if (positionalDeviceTracker != null && positionalDeviceTracker.IsActive)
        {
            DestroyAnchors();

            contentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>();
            contentPositioningBehaviour.PositionContentAtPlaneAnchor(currentResult);
            m_ResetButton.interactable = true;
        }

        if (!m_PlaneAugmentation.activeInHierarchy)
        {
            Debug.Log("Setting Plane Augmentation to Active");
            // On initial run, unhide the augmentation
            m_PlaneAugmentation.SetActive(true);
        }

        Debug.Log("Positioning Plane Augmentation at: " + currentResult.Position);
        m_PlaneAugmentation.PositionAt(currentResult.Position);
        RotateTowardCamera(m_PlaneAugmentation);
    }
Example #14
0
    public virtual void HandleInteractiveHitTest(HitTestResult result)
    {
        if (result == null)
        {
            Debug.LogError("Invalid hit test result!");
            return;
        }
        if (!m_GroundPlaneUI.IsCanvasButtonPressed())
        {
            Debug.Log("HandleInteractiveHitTest() called.");
            // If the PlaneFinderBehaviour's Mode is Automatic, then the Interactive HitTestResult will be centered.
            // PlaneMode.Ground and PlaneMode.Placement both use PlaneFinder's ContentPositioningBehaviour
            m_ContentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>();
            m_ContentPositioningBehaviour.DuplicateStage = false;
            // Place object based on Ground Plane mode
            if (showGameObject != null && lastName != showGameObjectName)
            {
                lastName = showGameObjectName;
                showGameObject.gameObject.SetActive(true);
                isPlaced = true;
                if (showGameObjectName == "haiou")
                {
                    showGameObject.GetComponent <Haiou>().Init();
                }
                else
                {
                    FingerTouchEL.Instance.targetGameObject = showGameObject;
                }


                UtilityHelper.EnableRendererColliderCanvas(showGameObject, true);

                switch (showGameObject.GetComponent <WriteItem>().goodsPositionEnum)
                {
                case PlaneMode.None:
                    break;

                case PlaneMode.GROUND:
                    m_ContentPositioningBehaviour.AnchorStage = m_PlaneAnchor;
                    m_ContentPositioningBehaviour.PositionContentAtPlaneAnchor(result);
                    showGameObject.transform.parent = planeAnchor.transform;

                    break;

                case PlaneMode.MIDAIR:
                    m_ContentPositioningBehaviour.AnchorStage = m_MidAirAnchor;
                    m_ContentPositioningBehaviour.PositionContentAtMidAirAnchor(showGameObject.transform);
                    showGameObject.transform.parent = midAirAnchor.transform;
                    break;

                default:
                    break;
                }


                showGameObject.transform.localPosition    = Vector3.zero;
                showGameObject.transform.localEulerAngles = Vector3.zero;
                if (showGameObject.name == "wurenji")
                {
                    showGameObject.GetComponentInChildren <Cloth>().enabled = false;
                }
                showGameObject.transform.localScale = Vector3.one * 0.5f;
                if (showGameObject.name == "wurenji")
                {
                    showGameObject.GetComponentInChildren <Cloth>().enabled = true;
                }
                UtilityHelper.RotateTowardCameraVuforia(showGameObject);
                // YiyouStaticDataManager.Instance.ShowModel = showGameObject;
                FirstUseTipManager.Instance.ShowNextTip(TipType.WriteTip);
                WriteItem writeItem = showGameObject.GetComponent <WriteItem>();
                if (writeItem != null && writeItem.goodsEnum != GoodsWriteEnum.None)
                {
                    ShowInput();
                    GroundPlaneUI.Instance.SetIntroductionText("请选择字体并输入文字");
                }
                else
                {
                    GroundPlaneUI.Instance.SetIntroductionText("", false);

                    ShowButtonPanel();
                }

                ShowEffectPanel();
                GroundPlaneUI.Instance.SetReticleVisiblity(false);
                WriteManager.Instance.SetGoodsEnum(showGameObject.GetComponent <WriteItem>().goodsEnum);
                InitLight(showGameObject.name);
            }
            else
            {
                if (showGameObject == null)
                {
                    GroundPlaneUI.Instance.SetIntroductionText("请先选择合影道具");
                }
            }
        }
    }
Example #15
0
 public void OnInteractiveHitTest(HitTestResult result)
 {
     contentPositioningBehaviour.PositionContentAtPlaneAnchor(result);
     contentPositioningBehaviour.gameObject.SetActive(false);
     board.SetActive(true);
 }