Beispiel #1
0
    private void setCurrentAnnotation(TrackedAnnotation a)
    {
        _currentAnnotation = a;
        var texture = new Texture2D(0, 0, TextureFormat.RGB24, false);

        texture.LoadImage(a.Image);
        PreviewImage.GetComponent <RawImage>().texture = texture;
        PreviewImage.SetActive(true);
        LargePreviewImage.GetComponent <RawImage>().texture = texture;
    }
Beispiel #2
0
    private void AnnotateButtonClick()
    {
        Debug.Log("attempting raycast");
        var          castPosition = FocusDot.transform.position;
        TrackableHit hit;

//		if (ARInterface.GetInterface().TryRaycast(castPosition.x, castPosition.y, ref anchorPoint))
        if (Frame.Raycast(castPosition.x, castPosition.y, TrackableHitFlags.FeaturePoint, out hit))
        {
            Debug.Log("raycast success");
//			var obj = GameObject.CreatePrimitive(PrimitiveType.Sphere);
//			obj.transform.localScale = new Vector3(0.03f, 0.03f, 0.03f);
//			obj.transform.position = anchorPoint.position;
//			obj.transform.rotation = anchorPoint.rotation;
//			anchors.Add(anchorPoint.id, obj.transform);

            var png = ArUtils.GetCameraImage(ARInterface.GetInterface());

            if (png != null)
            {
                if (ARInterface.GetInterface().TryGetPose(ref _pose))
                {
                    var anchor     = hit.Trackable.CreateAnchor(hit.Pose);
                    var annotation = new TrackedAnnotation(png, Camera.main.aspect, _pose, anchor);
                    _annotations.Add(annotation);
                    annotation.Show();

                    ObjToAnnotation.Add(annotation._obj, annotation);

                    setCurrentAnnotation(annotation);

//					SocketConnection.Instance.SendData("annotate", annotation.ToJson());
                }
            }
        }
        else
        {
            Debug.Log("raycast unsuccessful");
        }
    }