private void AddVisualizer(AugmentedImage image)
    {
        var anchor     = image.CreateAnchor(image.CenterPose);
        var visualizer = Instantiate(_augmentedImageVisualizer, anchor.transform);

        _visualizers.Add(image.DatabaseIndex, visualizer);
    }
Exemplo n.º 2
0
        public void setAugmentedImage(AugmentedImage image, AugmentedImageVisualizer visualizer, AugmentedImageVisualizer prefab)
        {
            Anchor anchor = image.CreateAnchor(image.CenterPose);

            visualizer       = (AugmentedImageVisualizer)Instantiate(prefab, anchor.transform);
            visualizer.Image = image;
            m_Visualizers.Add(image.DatabaseIndex, visualizer);
        }
    private void AddVisualizer(AugmentedImage image)
    {
        _ShowAndroidToastMessage("Adding visualizer");
        var anchor     = image.CreateAnchor(image.CenterPose);
        var visualizer = Instantiate(augmentedImageVisualizer, anchor.transform);

        visualizer.image = image;
        visualizers.Add(image.DatabaseIndex, visualizer);
    }
    private AugmentedImageVisualizer AddVisualizer(AugmentedImage image, AugmentedImageVisualizer visualizer)
    {
        Anchor anchor = image.CreateAnchor(image.CenterPose);

        visualizer       = (AugmentedImageVisualizer)Instantiate(augmentedImageVisualizerPrefab, anchor.transform);
        visualizer.Image = image;
        _visualizers.Add(image.DatabaseIndex, visualizer);

        //ARCore will keep understanding the world and update the anchors accordingly hence we need to attach our portal to the anchor
        visualizer.transform.parent = anchor.transform;
        return(visualizer);
    }
Exemplo n.º 5
0
        private void _TrackingMarker(AugmentedImage image)
        {
            AnchorPosition pos = _PosForName(image.Name);
            Anchor         anchor;

            if (!anchors.TryGetValue(pos, out anchor))
            {
                anchor = image.CreateAnchor(image.CenterPose);
                anchors.Add(pos, anchor);
                _AdaptModel(pos, anchor);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Function called when the manipulation is ended.
        /// </summary>
        /// <param name="gesture">The current gesture.</param>
        protected override void OnEndManipulation(TapGesture gesture)
        {
            if (gesture.WasCancelled)
            {
                return;
            }
            // If gesture is targeting an existing object we are done.
            if (gesture.TargetObject != null)
            {
                return;
            }

            if (clickCount < 1)
            {
                clickCount = clickCount + 1;
                //find an image to place an anchor
                int index = controller._tempAugmentedImages.FindIndex(x => x.Name == "demo2");
                image = controller._tempAugmentedImages[index];
                pose  = image.CenterPose;
                //instatntiate game objects
                gameObject0 = Instantiate(PawnPrefab[0], new Vector3(pose.position.x - 0.055f, pose.position.y, pose.position.z - 0.03f), new Quaternion(-0.707f, 0f, 0f, 0.707f));
                gameObject1 = Instantiate(PawnPrefab[1], new Vector3(pose.position.x, pose.position.y, pose.position.z - 0.03f), new Quaternion(0f, 1f, 0f, 0f));
                // Instantiate manipulators
                manipulator0 = Instantiate(ManipulatorPrefab, new Vector3(pose.position.x - 0.055f, pose.position.y, pose.position.z - 0.03f), pose.rotation);
                manipulator1 = Instantiate(ManipulatorPrefab, new Vector3(pose.position.x, pose.position.y, pose.position.z - 0.03f), pose.rotation);
                // Make game object a child of the manipulator.
                gameObject0.transform.parent = manipulator0.transform;
                gameObject1.transform.parent = manipulator1.transform;
                // Create an anchor to allow ARCore to track the image
                anchor0 = image.CreateAnchor(new Pose(new Vector3(pose.position.x - 0.055f, pose.position.y, pose.position.z - 0.03f), pose.rotation));
                anchor1 = image.CreateAnchor(new Pose(new Vector3(pose.position.x, pose.position.y, pose.position.z - 0.03f), pose.rotation));
                // Make manipulator a child of the anchor.
                manipulator0.transform.parent = anchor0.transform;
                manipulator1.transform.parent = anchor1.transform;
                // Select the placed object.
                manipulator0.GetComponent <Manipulator>().Select();
                manipulator1.GetComponent <Manipulator>().Select();
            }
        }
Exemplo n.º 7
0
    /// <summary>
    /// Add Visualiser and anchors for updated augmented images that are tracking and do not previously have a visualizer
    /// </summary>
    public void AddVisualiser(AugmentedImage _imageToAddTo)
    {
        // Create an anchor at centre of image to ensure that transformation is relative to real world
        Anchor anchor = _imageToAddTo.CreateAnchor(_imageToAddTo.CenterPose);
        // Create new visualiser and set as anchor's child ( so to keep the visualiser in that place )
        ARImageVisualiser visualizer = Instantiate(AugmentedImageVisualizerPrefab, anchor.transform) as ARImageVisualiser;

        // Set image of visualiser to be image that is tracked
        visualizer.m_image = _imageToAddTo;
        //m_prevIndex = _imageToAddTo.DatabaseIndex;
        // Add to Dictionary
        m_Visualizers.Add(_imageToAddTo.DatabaseIndex, visualizer);
    }
Exemplo n.º 8
0
    public void OnMarkerDiscovered(AugmentedImage image)
    {
        Debug.Log("OnMarkerDiscovered. image = " + image.Name);
        if (currentVideoData != null)
        {
            return;
        }

        Anchor     anchor     = image.CreateAnchor(image.CenterPose);
        MarkerData markerData = new MarkerData()
        {
            name = image.Name, imageIndex = image.DatabaseIndex, anchorTransform = anchor.transform
        };

        OnMarkerDiscovered(markerData);
    }
    private void AddVisluazier(AugmentedImage image)
    {
        // anchor is world position of our AR image so it can stay put in real world space when moving about
        var anchor = image.CreateAnchor(image.CenterPose);

        // create our visualized object
        var visualizer = Instantiate(augmentedImageVisualizer, anchor.transform);

        // set the image of the visualizer to the image we have tracked
        visualizer.Image = image;
        // add our visualizer to our list of visualizers
        visualizers.Add(image.DatabaseIndex, visualizer);



        bing.color = Color.green;
    }
Exemplo n.º 10
0
    private void Update()
    {
        if (mTargetImage != null)
        {
            if (mTargetImageAnchor == null)
            {
                mTargetImageAnchor = mTargetImage.CreateAnchor(mTargetImage.CenterPose);
            }

            if (mTargetImage.TrackingState == TrackingState.Tracking)
            {
                if (mTargetImageAnchor != null)
                {
                    gameObject.transform.SetPositionAndRotation(mTargetImageAnchor.transform.position, mTargetImageAnchor.transform.rotation);
                    gameObject.transform.localScale = new UnityEngine.Vector3(mTargetImage.ExtentX, 0.001f, mTargetImage.ExtentZ);
                }
            }
        }
    }
Exemplo n.º 11
0
        private void SetMainWindow(AugmentedImage image)
        {
            var pose = image.CenterPose;

            var model = CollectionManager.Instance.activeProduct.gameObject;

            model.AddComponent <MarkerVisualizer>();

            m_Visualizer       = (MarkerVisualizer)Instantiate(model.GetComponent <MarkerVisualizer>(), pose.position, pose.rotation);
            m_Visualizer.Image = image;

            var manipulator = Instantiate(manipulatorMarkerWindow, pose.position, pose.rotation);

            m_Visualizer.transform.parent = manipulator.transform;

            var anchor = image.CreateAnchor(pose);

            manipulator.transform.parent = anchor.transform;
            manipulator.GetComponent <Manipulator>().Select();
        }
Exemplo n.º 12
0
        /// <summary>
        /// The Unity Update method.
        /// </summary>

        public void Start()
        {
            anchor = Image.CreateAnchor(Image.CenterPose);
            float x = 0.2f;
            float y = 0.2f;
            float z = 0.2f;

            //Destroy(Sphere);
            for (int i = 0; i < 3; i++)
            {
                /*
                 * GameObject s = (GameObject)Instantiate(Sphere, anchor.transform);
                 * s.transform.localPosition =
                 *        (positionsList[i][0] * Vector3.right) + (positionsList[i][1] * Vector3.forward) +
                 *        (positionsList[i][2] * Vector3.down);
                 * s.SetActive(true);
                 */

                /*
                 * GameObject s2 = (GameObject)Instantiate(Sphere, anchor.transform);
                 * s2.transform.localPosition =
                 *        (x * Vector3.right) + (y * Vector3.forward) +
                 *        (z * Vector3.down);
                 * x += 0.1f;
                 * y += 0.1f;
                 * z += 0.1f;
                 * s2.SetActive(true);
                 * spheresList.Add(s2);
                 */
                AudioFire s2 = (AudioFire)Instantiate(AudioFirePrefab, anchor.transform);
                s2.gameObject.transform.localPosition =
                    (x * Vector3.right) + (y * Vector3.forward) +
                    (z * Vector3.down);
                x += 0.1f;
                y += 0.1f;
                z += 0.1f;
                s2.SetActive(true);
                spheresList.Add(s2.gameObject);
                fireList.Add(s2);
            }
        }