/**
     * OnInteractiveHitTest のコールバックに設定する
     * HitTestResult この引数はタップした位置情報
     */
    public void SpawnContent(HitTestResult result)
    {
        Anchor anchor = tracker.CreatePlaneAnchor(Guid.NewGuid().ToString(), result);

        // 床面情報が取得できなかったら関数を終了させる
        if (result == null || anchor == null)
        {
            return;
        }

        // このオブジェクトのインスペクタにアタッチしたプレファブのインスタンスを生成する
        GameObject content = Instantiate(contentPrefab);

        // インスタンスの座標と回転をリセットする
        content.transform.position = result.Position;
        content.transform.rotation = result.Rotation;
        // インスタンスをアクティブにする
        content.SetActive(true);

        // すでにインスタンスがあったら削除する
        if (prevInstance != null)
        {
            Destroy(prevInstance);
        }

        // インスタンスを格納する
        prevInstance = content;
    }
Exemple #2
0
    public void OnInteractiveHitTest(HitTestResult result)
    {
        if (result == null || AnchorStage == null)
        {
            Debug.LogWarning("Hit test is invalid or AnchorStage not set");
            return;
        }

        var anchor = _deviceTracker.CreatePlaneAnchor(Guid.NewGuid().ToString(), result);

        if (anchor != null)
        {
            AnchorStage.transform.parent        = anchor.transform;
            AnchorStage.transform.localPosition = Vector3.zero;
            AnchorStage.transform.localRotation = Quaternion.identity;
            AnchorStage.SetActive(true);
        }

        if (_previousAnchor != null)
        {
            Destroy(_previousAnchor);
        }

        _previousAnchor = anchor;
    }
Exemple #3
0
    public void OnInteractiveHitTest(HitTestResult result)
    {
        GameManager.instance.SetText("pos", result.Position.ToString());
        GameManager.instance.SetText("rot", result.Rotation.ToString());

        var anchor = _deviceTracker.CreatePlaneAnchor(Guid.NewGuid().ToString(), result);

        // but now the anchor doesn't create a GameObject, so we will have to with the HitTestResult position and rotation values
        GameObject anchorParent = Instantiate(cube, result.Position, result.Rotation);
        GameObject anchorGO     = Instantiate(AnchorStage, result.Position, result.Rotation);

        AnchorStage.transform.parent     = anchorParent.transform;
        AnchorStage.transform.localScale = Vector3.zero;
        AnchorStage.transform.rotation   = Quaternion.identity;

        AnchorStage.SetActive(true);

        /*
         * if (_previousAnchor != null)
         * {
         *
         *  Destroy(_previousAnchor);
         *
         * }
         *
         * // Save it
         * _previousAnchor = AnchorStage;
         */
    }
    public void OnInteractiveHitTest(HitTestResult result)
    {
        if (result == null || AnchorStage == null)
        {
            Debug.LogWarning("Hit test is invalid or AnchorStage not set");
            return;
        }
        var anchor = _deviceTracker.CreatePlaneAnchor(Guid.NewGuid().ToString(), result);

        // but now the anchor doesn't create a GameObject, so we will have to with the HitTestResult position and rotation values

        GameObject anchorGO = new GameObject();

        anchorGO.transform.position = result.Position;

        anchorGO.transform.rotation = result.Rotation;

        // Parent the stage to the new GameObject like you would have the anchor before

        if (anchor != null)
        {
            AnchorStage.transform.parent        = anchorGO.transform;
            AnchorStage.transform.localPosition = Vector3.zero;
            AnchorStage.transform.localRotation = Quaternion.identity;
            AnchorStage.SetActive(true);
        }
        if (_previousAnchor != null)
        {
            Destroy(_previousAnchor);
        }
        _previousAnchor = anchorGO;
    }
Exemple #5
0
    /// <summary>
    /// point is the  Measurepoint 1 or 2
    /// </summary>
    /// <param name="result"></param>
    /// <param name="point"></param>
    void PutMeasurePoint(HitTestResult result, GameObject point)
    {
        var anchor = _deviceTracker.CreatePlaneAnchor(Guid.NewGuid().ToString(), result);

        //GameObject anchorGO = new GameObject();
        //anchorGO.transform.position = result.Position;
        //anchorGO.transform.rotation = result.Rotation;
        if (anchor != null)
        {
            ///
            //point.transform.parent = anchorGO.transform;
            point.transform.position = result.Position;
            point.transform.rotation = result.Rotation;
            //point.transform.localPosition = Vector3.zero;
            //point.transform.localRotation = Quaternion.identity;

            point.SetActive(true);
            point.GetComponent <Collider>().enabled     = true;
            point.GetComponent <MeshRenderer>().enabled = true;
            ///
            //AnchorStage.transform.parent = anchor.transform;
            //AnchorStage.transform.localPosition = Vector3.zero;
            //AnchorStage.transform.localRotation = Quaternion.identity;
            //AnchorStage.SetActive(true);
        }
    }
Exemple #6
0
    public void NewAnchorHitTest(HitTestResult result)
    {
        var listenerBehaviour = GetComponent <AnchorInputListenerBehaviour>();

        var anchor = _deviceTracker.CreatePlaneAnchor(Guid.NewGuid().ToString(), result);

        _anchorGameObject = new GameObject();
        AnchorGameObjectSetHitTestPosition(result);

        if (anchor != null)
        {
            listenerBehaviour.enabled = true;
            Debug.Log("running");

            newPosition = _anchorGameObject.transform;


            newPosition = AnchorStage.transform;

            //AnchorStage.transform.parent = _anchorGameObject.transform;

            //AnchorStage.transform.localPosition = Vector3.zero;

            //AnchorStage.transform.localRotation = Quaternion.identity;

            //AnchorStage.SetActive(true);
        }
        if (_previousAnchor != null)
        {
            Destroy(_previousAnchor);
        }
        _previousAnchor = _anchorGameObject;
    }
Exemple #7
0
    public void SpawnContent(HitTestResult result)
    {
        if (result == null || yourContentPrefab == null)
        {
            Debug.LogWarning("Hit test is invalid or content is not set");
            return;
        }
        var anchor = deviceTracker.CreatePlaneAnchor(Guid.NewGuid().ToString(), result);

        if (anchor != null)
        {
            anchor.transform.parent = this.gameObject.transform;
            GameObject content = Instantiate(yourContentPrefab);

            content.transform.parent        = anchor.transform;
            content.transform.localPosition = Vector3.zero;
            content.transform.localRotation = Quaternion.identity;
            content.SetActive(true);
        }
        if (previousAnchor != null)
        {
            Destroy(previousAnchor);
        }
        previousAnchor = anchor;
    }
Exemple #8
0
 public void OnInteractiveHitTest(HitTestResult result)
 {
     if (placed == false && Input.GetMouseButton(0))
     {
         if (result == null || AnchorStage == null)
         {
             Debug.LogWarning("Hit test is invalid or AnchorStage not set");
             return;
         }
         var anchor = _deviceTracker.CreatePlaneAnchor(Guid.NewGuid().ToString(), result);
         if (anchor != null)
         {
             placed = true;
             transform.GetComponent <PlaneFinderBehaviour> ().enabled = false;
             AnchorStage.transform.parent        = anchor.transform;
             AnchorStage.transform.localPosition = Vector3.zero;
             AnchorStage.transform.localRotation = Quaternion.identity;
             AnchorStage.SetActive(true);
             //mainMenu.SetActive (true);
             MainUiController.instance.ActivateMainScreen();
             RotateTowardCamera(boy);
         }
         if (_previousAnchor != null)
         {
             Destroy(_previousAnchor);
         }
         _previousAnchor = anchor;
     }
 }
Exemple #9
0
    public void HandleInteractiveHitTest(HitTestResult result)
    {
        // If the PlaneFinderBehaviour's Mode is Automatic, then the Interactive HitTestResult will be centered.

        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.PLACEMENT:

            if (m_PositionalDeviceTracker != null && m_PositionalDeviceTracker.IsActive)
            {
                if (m_PlacementAnchor == null || TouchHandler.DoubleTap)
                {
                    DestroyAnchors();

                    m_PlacementAnchor      = m_PositionalDeviceTracker.CreatePlaneAnchor("MyPlacementAnchor_" + (++m_AnchorCounter), result);
                    m_PlacementAnchor.name = "PlacementAnchor";

                    if (!VuforiaRuntimeUtilities.IsPlayMode())
                    {
                        Floor.position = m_PlacementAnchor.transform.position;
                    }
                    m_PlacementAugmentation.transform.SetParent(m_PlacementAnchor.transform);
                    m_PlacementAugmentation.transform.localPosition = Vector3.zero;
                }

                m_ResetButton.interactable = true;
            }

            if (!m_PlacementAugmentation.activeInHierarchy)
            {
                Debug.Log("Setting Placement Augmentation to Active");
                // On initial placement, unhide the augmentation
                m_PlacementAugmentation.SetActive(true);

                Debug.Log("Positioning Placement Augmentation at: " + result.Position);
                // parent the augmentation to the anchor
                m_PlacementAugmentation.transform.SetParent(m_PlacementAnchor.transform);
                m_PlacementAugmentation.transform.localPosition = Vector3.zero;
                RotateTowardCamera(m_PlacementAugmentation);
                m_TouchHandler.enableRotation = true;
            }

            break;
        }
    }
    /// <summary>
    /// point is the  Measurepoint 1 or 2
    /// </summary>
    /// <param name="result"></param>
    /// <param name="point"></param>
    void PutMeasurePointPlane(HitTestResult result, GameObject point)
    {
        var anchor = _deviceTracker.CreatePlaneAnchor(Guid.NewGuid().ToString(), result);

        if (anchor != null)
        {
            point.transform.position = result.Position;
            point.transform.rotation = result.Rotation;

            point.SetActive(true);
        }
    }
Exemple #11
0
    public void OnInteractiveHitTest(HitTestResult result)
    {
        if (result == null)
        {
            Debug.LogWarning("Hit test is invalid");
            return;
        }
        if (AnchorStage == null)
        {
            Debug.LogWarning("AnchorStage not set");
            return;
        }

        var anchor = _deviceTracker.CreatePlaneAnchor(Guid.NewGuid().ToString(), result);

        if (anchor != null)
        {
            AnchorStage.transform.parent        = anchor.transform;
            AnchorStage.transform.localPosition = Vector3.zero;
            AnchorStage.transform.localRotation = Quaternion.identity;
            AnchorStage.SetActive(true);
        }

        if (_previousAnchor != null)
        {
            Destroy(_previousAnchor);
        }

        _previousAnchor = anchor;
        Debug.Log("-------------------------------Hit Test Works");

        // 마커 회전에 맞게 회전시키기
        //if (AnchorStage != null)
        //{
        //    Vector3 tempRotation = AnchorStage.transform.rotation.eulerAngles;
        //    tempRotation.y = Camera.main.transform.rotation.eulerAngles.y;
        //    AnchorStage.transform.rotation = Quaternion.Euler(tempRotation);
        //}
        if (AnchorStage != null)
        {
            //float angle = Quaternion.Angle(AnchorStage.transform.rotation, Camera.main.transform.rotation);
            AnchorStage.transform.rotation = ImageTarget.transform.rotation;
        }
    }
Exemple #12
0
    public void OnInteractiveHitTest(HitTestResult result)
    {
        if (_anchorSet)
        {
            //Leave if the anchor has already been set
            return;
        }

        if (result == null || AnchorStage == null)
        {
            Debug.LogWarning("Hit test is invalid or AnchorStage not set");
            return;
        }

        //Let's go ahead and create the anchor at the position of the hit test
        var anchor = _deviceTracker.CreatePlaneAnchor(Guid.NewGuid().ToString(), result);

        if (anchor != null)
        {
            AnchorStage.transform.parent        = anchor.transform;
            AnchorStage.transform.localPosition = Vector3.zero;
            AnchorStage.transform.localRotation = Quaternion.identity;
            AnchorStage.gameObject.SetActive(true);

            //Make sure that the Image Target is currently tracking
            if (ImageTarget.CurrentStatus == TrackableBehaviour.Status.DETECTED ||
                ImageTarget.CurrentStatus == TrackableBehaviour.Status.TRACKED ||
                ImageTarget.CurrentStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
            {
                //Let's move the contents of the image target onto the ground plane
                for (var i = 0; i < ImageTarget.transform.childCount; i++)
                {
                    var content = ImageTarget.transform.GetChild(i);
                    content.parent = AnchorStage.transform;
                }
            }

            _anchorSet = true;
        }
    }
    public void OnInteractiveHitTest(HitTestResult result)
    {
        // same anchor code from before

        var anchor = _deviceTracker.CreatePlaneAnchor(Guid.NewGuid().ToString(), result);

        // but now the anchor doesn't create a GameObject, so we will have to with the HitTestResult position and rotation values

        GameObject anchorGO = new GameObject();

        anchorGO.transform.position = result.Position;

        anchorGO.transform.rotation = result.Rotation;

        // Parent the stage to the new GameObject like you would have the anchor before

        if (anchor != null)
        {
            AnchorStage.transform.parent = anchorGO.transform;

            AnchorStage.transform.localPosition = Vector3.zero;

            AnchorStage.transform.localRotation = Quaternion.identity;

            AnchorStage.SetActive(true);
        }

        // Clean up

        if (_previousAnchor != null)
        {
            Destroy(_previousAnchor);
        }

        // Save it

        _previousAnchor = anchorGO;
    }