static public int constructor(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.Pose    o;
         UnityEngine.Vector3 a1;
         checkType(l, 2, out a1);
         UnityEngine.Quaternion a2;
         checkType(l, 3, out a2);
         o = new UnityEngine.Pose(a1, a2);
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
示例#2
0
        private void StartTracking(NodeHandle node)
        {
            if (_factory == null)
            {
                Debug.LogError("Factory is null");
                return;
            }

            if (_factory.nodeGetStatus(node) != NodeStatus.Idle)
            {
                Debug.LogError("Wrong node status");
                return;
            }

            if (Environment == null || Environment.Environment == null)
            {
                Debug.LogError("Environment is null");
                return;
            }

            _trackingLibrary = Antilatency.Alt.Tracking.Library.load();

            _placement = GetPlacement();

            _trackingTask = _trackingLibrary.createTracking(_factory, node, Environment.Environment);
            _trackingNode = node;

            TrackingTaskStateChanged.Invoke(true);
        }
        public GoogleARCore.AsyncTask <CloudAnchorResult> CreateCloudAnchor(
            UnityEngine.Pose pose, int ttlDays)
        {
            Action <CloudAnchorResult> onComplete;

            GoogleARCore.AsyncTask <CloudAnchorResult> task;
            if (!CreateCloudAnchorResultAsyncTask(out onComplete, out task))
            {
                return(task);
            }

            // Create an native Pose and Anchor.
            var    poseHandle        = LifecycleManager.Instance.NativeSession.PoseApi.Create(pose);
            IntPtr arkitAnchorHandle = IntPtr.Zero;

            ExternApi.ARKitAnchor_create(poseHandle, ref arkitAnchorHandle);

            CreateCloudAnchor(onComplete, arkitAnchorHandle, ttlDays);

            // Clean up handles for the Pose and ARKitAnchor.
            LifecycleManager.Instance.NativeSession.PoseApi.Destroy(poseHandle);
            ExternApi.ARKitAnchor_release(arkitAnchorHandle);

            return(task);
        }
 static public int constructor(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         UnityEngine.Pose o;
         if (argc == 3)
         {
             UnityEngine.Vector3 a1;
             checkType(l, 2, out a1);
             UnityEngine.Quaternion a2;
             checkType(l, 3, out a2);
             o = new UnityEngine.Pose(a1, a2);
             pushValue(l, true);
             pushValue(l, o);
             return(2);
         }
         else if (argc <= 2)
         {
             o = new UnityEngine.Pose();
             pushValue(l, true);
             pushValue(l, o);
             return(2);
         }
         return(error(l, "New object failed."));
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#5
0
        ///<summary>Get value of a particular trait by name</summary>
        public bool TryGetTrait(string traitName, out UnityEngine.Pose value)
        {
            if (!m_PoseTraits.TryGetValue(traitName, out value))
            {
                value = default;
                return(false);
            }

            return(true);
        }
示例#6
0
    /// <summary>
    /// Immediately creates local anchor after detected marker intersects detected plane beneath it.
    /// Cloud anchor is created afterwards, but it takes some time. When it is finished, scene will be attached to it.
    /// Called if user clicks on the calibration cube displayed over detected marker.
    /// </summary>
    /// <param name="tf"></param>
    public void CreateAnchor(Transform tf)
    {
#if (UNITY_ANDROID || UNITY_IOS) && AR_ON
        ARPlane          plane   = null;
        UnityEngine.Pose hitPose = new UnityEngine.Pose();

        // try to raycast straight down to intersect closest plane
        List <ARRaycastHit> raycastHits = new List <ARRaycastHit>();
        if (ARRaycastManager.Raycast(new Ray(tf.position, Vector3.down), raycastHits, TrackableType.PlaneWithinPolygon))
        {
            hitPose = raycastHits[0].pose;
            TrackableId hitPlaneId = raycastHits[0].trackableId;
            plane = ARPlaneManager.GetPlane(hitPlaneId);
        }

        // remove all old local anchors, if there are some (in case we are recalibrating)
        RemoveLocalWorldAnchor();
        RemoveCloudWorldAnchor();

        // set temporary world anchor
        //WorldAnchorLocal = ARAnchorManager.AttachAnchor(plane,
        //    new Pose(hitPose.position, Quaternion.FromToRotation(tf.up, plane.normal) * tf.rotation));

        //WorldAnchorLocal = ARAnchorManager.AddAnchor(new UnityEngine.Pose(hitPose != new UnityEngine.Pose() ? hitPose.position : tf.position,
        //    plane != null ? Quaternion.FromToRotation(tf.up, plane.normal) * tf.rotation : tf.rotation));

        WorldAnchorLocal = ARAnchorManager.AddAnchor(new UnityEngine.Pose(tf.position,
                                                                          plane != null ? Quaternion.FromToRotation(tf.up, plane.normal) * tf.rotation : tf.rotation));

        // immediately attach scene to local anchor (after cloud anchor is created, scene will be attached to it)
        AttachScene(WorldAnchorLocal.gameObject);

        // Create cloud anchor
        if (Settings.Instance.UseCloudAnchors)
        {
            WorldAnchorCloud = ARAnchorManager.HostCloudAnchor(WorldAnchorLocal);
            StartCoroutine(HostCloudAnchor());
        }
        else
        {
            Calibrated        = true;
            UsingCloudAnchors = false;
            OnARCalibrated?.Invoke(this, new CalibrationEventArgs(true, WorldAnchorLocal.gameObject));
            Notifications.Instance.ShowNotification("Calibration successful", "");
            worldAnchorVis = null;
            ActivateCalibrationElements((bool)MainSettingsMenu.Instance.CalibrationElements.GetValue());
        }

        GameManager.Instance.SceneSetActive(true);
        ActivateTrackableMarkers(false);
#endif
    }
示例#7
0
        public override PoseDataFlags GetPoseFromProvider(out UnityEngine.Pose output)
        {
            var receiver = ARKitReceiver.Instance;

            if (receiver == null)
            {
                output = default(UnityEngine.Pose);
                return(PoseDataFlags.NoData);
            }

            output = receiver.TrackedPose;
            return(PoseDataFlags.Position | PoseDataFlags.Rotation);
        }
示例#8
0
 static public int ctor_s(IntPtr l)
 {
     try {
         UnityEngine.Pose o;
         o = new UnityEngine.Pose();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
        public GoogleARCore.AsyncTask <CloudAnchorResult> CreateCloudAnchor(UnityEngine.Pose pose)
        {
            Action <CloudAnchorResult> onComplete;
            var task = new GoogleARCore.AsyncTask <CloudAnchorResult>(out onComplete);

            if (LifecycleManager.Instance.NativeSession == null)
            {
                onComplete(new CloudAnchorResult()
                {
                    Response = CloudServiceResponse.ErrorNotSupportedByConfiguration,
                    Anchor   = null,
                });

                return(task);
            }

            var    poseHandle        = LifecycleManager.Instance.NativeSession.PoseApi.Create(pose);
            IntPtr arkitAnchorHandle = IntPtr.Zero;

            ExternApi.ARKitAnchor_create(poseHandle, ref arkitAnchorHandle);

            IntPtr cloudAnchorHandle = IntPtr.Zero;
            var    status            = LifecycleManager.Instance.NativeSession.SessionApi
                                       .CreateCloudAnchor(arkitAnchorHandle, out cloudAnchorHandle);

            LifecycleManager.Instance.NativeSession.PoseApi.Destroy(poseHandle);
            ExternApi.ARKitAnchor_release(arkitAnchorHandle);

            if (status != ApiArStatus.Success)
            {
                onComplete(new CloudAnchorResult()
                {
                    Response = status.ToCloudServiceResponse(),
                    Anchor   = null,
                });

                return(task);
            }

            var request = new CloudAnchorRequest()
            {
                IsComplete     = false,
                NativeSession  = LifecycleManager.Instance.NativeSession,
                AnchorHandle   = cloudAnchorHandle,
                OnTaskComplete = onComplete,
            };

            _UpdateCloudAnchorRequest(request, true);
            return(task);
        }
示例#10
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.Pose    o;
         UnityEngine.Vector3 a1;
         checkType(l, 2, out a1);
         UnityEngine.Quaternion a2;
         checkType(l, 3, out a2);
         o = new UnityEngine.Pose(a1, a2);
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#11
0
        /// <summary>
        /// Start tracking task on node.
        /// </summary>
        /// <param name="node">Node to start tracking task.</param>
        protected void StartTracking(NodeHandle node)
        {
            var network = GetNativeNetwork();

            if (network == null)
            {
                return;
            }

            if (network.nodeGetStatus(node) != NodeStatus.Idle)
            {
                Debug.LogError("Wrong node status");
                return;
            }

            if (Environment == null)
            {
                Debug.LogError("Environment is null");
                return;
            }

            var nativeEnvironment = Environment.GetEnvironment();

            if (nativeEnvironment == null)
            {
                Debug.LogError("Native environment is null");
                return;
            }

            _placement = GetPlacement();

            using (var cotaskConstructor = _trackingLibrary.createTrackingCotaskConstructor()) {
                _trackingCotask = cotaskConstructor.startTask(network, node, nativeEnvironment);

                if (_trackingCotask == null)
                {
                    StopTracking();
                    Debug.LogWarning("Failed to start tracking task on node " + node.value);
                    return;
                }

                _trackingNode = node;
                TrackingTaskStateChanged.Invoke(true);
            }
        }
示例#12
0
 public ApiPoseData(UnityEngine.Pose unityPose)
 {
     ConversionHelper.UnityPoseToApiPose(unityPose, out this);
 }
示例#13
0
 void Awake()
 {
     awakePose = new UnityEngine.Pose(transform.position, transform.rotation);
 }
示例#14
0
 public bool Equals(UnityEngine.Pose o)
 {
     return(position.Equals(o.position) &&
            rotation.Equals(o.rotation));
 }