Example #1
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 #2
0
    void Update()
    {
        if (PlaneManager.planeMode == PlaneManager.PlaneMode.PLACEMENT)
        {
            // shadowRenderer.enabled =
            foreach (Renderer shoeRenderer in shoeRenderers)
            {
                shoeRenderer.enabled = (IsPlaced || PlaneManager.GroundPlaneHitReceived || PlaneManager.indicator);
            }
            foreach (MeshCollider meshCollider in meshColliders)
            {
                meshCollider.enabled = !doesHitShoe;
            }
        }
        else
        {
            foreach (Renderer shoeRenderer in shoeRenderers)
            {
                shoeRenderer.enabled = !IsPlaced;
            }
        }

        if (PlaneManager.planeMode == PlaneManager.PlaneMode.PLACEMENT && !IsPlaced)
        {
            m_RotationIndicator.SetActive(Input.touchCount == 2);
            if (m_RotationIndicator.activeSelf)
            {
                m_RotationIndicator.transform.position  = copyShoe.transform.position;
                m_RotationIndicator.transform.position -= Vector3.up * 0.2f;
            }

            m_TranslationIndicator.SetActive(
                !m_GroundPlaneUI.IsCanvasUIPressed() && (TouchHandler.IsSingleFingerDragging || TouchHandler.IsSingleFingerStationary) && doesHitShoe);
            if (m_TranslationIndicator.activeSelf)
            {
                m_TranslationIndicator.transform.position  = copyShoe.transform.position;
                m_TranslationIndicator.transform.position -= Vector3.up * 0.2f;
            }

            if (!m_GroundPlaneUI.IsCanvasUIPressed())
            {
                if (Input.GetMouseButtonDown(0))
                {
                    cameraToPlaneRay = mainCamera.ScreenPointToRay(Input.mousePosition);
                    if (Physics.Raycast(cameraToPlaneRay, out hit))
                    {
                        if (hit.collider.name.Equals(VuforiaRuntimeUtilities.IsPlayMode() ? EmulatorGroundPlane : Floor.name))
                        {
                            doesHitShoe = false;
                        }
                        else
                        {
                            doesHitShoe = true;
                        }
                    }
                }
                else if (TouchHandler.IsSingleFingerDragging || (VuforiaRuntimeUtilities.IsPlayMode() && Input.GetMouseButton(0)))
                {
                    cameraToPlaneRay = mainCamera.ScreenPointToRay(Input.mousePosition);
                    if (Physics.Raycast(cameraToPlaneRay, out hit))
                    {
                        if (hit.collider.gameObject.name ==
                            (VuforiaRuntimeUtilities.IsPlayMode() ? EmulatorGroundPlane : Floor.name) && doesHitShoe)
                        {
                            gameObject.PositionAt(hit.point);
                        }
                    }
                }
                else if (Input.GetMouseButtonUp(0))
                {
                    doesHitShoe = false;
                }
            }
        }
        else
        {
            m_RotationIndicator.SetActive(false);
            m_TranslationIndicator.SetActive(false);
        }
    }