Exemplo n.º 1
0
        public virtual void OnAnchorLocated(AnchorLocatedResult result)
        {
            Debug.Log(string.Format("PhysicalVisualizerManagerBase::OnAnchorLocated - Position: {0}, Rotation: {1}",
                                    string.Format("({0}, {1}, {2})", result.SpawnData.Position.x, result.SpawnData.Position.y, result.SpawnData.Position.z),
                                    string.Format("({0}, {1}, {2})", result.SpawnData.Rotation.x, result.SpawnData.Rotation.y, result.SpawnData.Rotation.z)));

            if (result.Anchor == null)
            {
                return;
            }

            GameObject sensor;

            if (_knownAnchors.ContainsKey(result.Anchor.id))
            {
                sensor = _knownAnchors[result.Anchor.id];

                //Update sensor location
                sensor.transform.position = result.SpawnData.Position;
#if WINDOWS_UWP
                sensor.transform.localRotation = result.SpawnData.Rotation * Quaternion.AngleAxis(90f, Vector3.right);
#else
                sensor.transform.localRotation = Quaternion.AngleAxis(90f, Vector3.right);
#endif
            }
            else
            {
                sensor = CreateSensorIndicator(result.SpawnData);
                _knownAnchors.Add(result.Anchor.id, sensor);

                _anchorManager.ApplyPhysicalVisualizerAnchor(sensor, result.CloudAnchor);

                SetupAnchor(sensor, result.Anchor.deviceId, result.CloudAnchor);
            }
        }
Exemplo n.º 2
0
        private void CloudManager_OnAnchorLocated(object sender, AnchorLocatedEventArgs args)
        {
            Debug.LogFormat("anchor recognized as a possible anchor {0} {1}", args.Identifier, args.Status);
            if (args.Status == LocateAnchorStatus.Located || args.Status == LocateAnchorStatus.AlreadyTracked)
            {
                if (!_cloudAnchors.Contains(args.Anchor))
                {
                    _cloudAnchors.Add(args.Anchor);
                }

                lock (_dispatchQueue)
                {
                    _dispatchQueue.Enqueue(new Action(() =>
                    {
                        var result         = new AnchorLocatedResult();
                        result.CloudAnchor = args.Anchor;
                        result.Anchor      = _anchors.FirstOrDefault(a => a.id == args.Identifier);

                        Pose anchorPose = Pose.identity;

#if UNITY_ANDROID || UNITY_IOS
                        anchorPose = args.Anchor.GetAnchorPose();
#endif
                        result.SpawnData = new SpawnData()
                        {
                            Position = anchorPose.position, Rotation = anchorPose.rotation
                        };

                        BroadcastMessage("OnAnchorLocated", result);
                    }));
                }
            }
        }
Exemplo n.º 3
0
        public virtual void OnAnchorLocated(AnchorLocatedResult result)
        {
            Debug.Log(string.Format("VirtualExplorerManagerBase::OnAnchorLocated - Position: {0}, Rotation: {1}",
                                    string.Format("({0}, {1}, {2})", result.SpawnData.Position.x, result.SpawnData.Position.y, result.SpawnData.Position.z),
                                    string.Format("({0}, {1}, {2})", result.SpawnData.Rotation.x, result.SpawnData.Rotation.y, result.SpawnData.Rotation.z)));

            gameObject.transform.position = result.SpawnData.Position;
            gameObject.transform.rotation = result.SpawnData.Rotation;

            _anchorManager.ApplyVirtualExplorerAnchor(gameObject);
        }