Esempio n. 1
0
        /// <summary>
        /// Attempts to create a new anchor that is attached to an existing <see cref="ARPlane"/>.
        /// </summary>
        /// <param name="plane">The <see cref="ARPlane"/> to which to attach.</param>
        /// <param name="pose">The initial <c>Pose</c>, in Unity world space, of the anchor.</param>
        /// <returns>A new <see cref="ARAnchor"/> if successful, otherwise <c>null</c>.</returns>
        public ARAnchor AttachAnchor(ARPlane plane, Pose pose)
        {
            if (!enabled)
            {
                throw new InvalidOperationException("Cannot create a anchor from a disabled anchor manager.");
            }

            if (subsystem == null)
            {
                throw new InvalidOperationException("Anchor manager has no subsystem. Enable the manager first.");
            }

            if (plane == null)
            {
                throw new ArgumentNullException("plane");
            }

            var      sessionRelativePose = sessionOrigin.trackablesParent.InverseTransformPose(pose);
            XRAnchor sessionRelativeData;

            if (subsystem.TryAttachAnchor(plane.trackableId, sessionRelativePose, out sessionRelativeData))
            {
                return(CreateTrackableImmediate(sessionRelativeData));
            }

            return(null);
        }
        /// <summary>
        /// Constructor for plane changed events.
        /// This is normally only used by the <see cref="ARPlane"/> component for <see cref="ARPlane.boundaryChanged"/> events.
        /// </summary>
        /// <param name="plane">The <see cref="ARPlane"/> that triggered the event.</param>
        /// <exception cref="System.ArgumentNullException">Thrown if <paramref name="plane"/> is `null`.</exception>
        public ARPlaneBoundaryChangedEventArgs(ARPlane plane)
        {
            if (plane == null)
            {
                throw new ArgumentNullException(nameof(plane));
            }

            this.plane = plane;
        }
        /// <summary>
        /// Constructor invoked by the <see cref="ARPlaneManager"/> which triggered the event.
        /// </summary>
        /// <param name="plane">The <see cref="ARPlane"/> component that was updated.</param>
        public ARPlaneUpdatedEventArgs(ARPlane plane)
        {
            if (plane == null)
            {
                throw new ArgumentNullException("plane");
            }

            this.plane = plane;
        }
        void RemovePlane(ARPlane plane)
        {
            if (planeRemoved != null)
            {
                planeRemoved(new ARPlaneRemovedEventArgs(plane));
            }

            plane.OnRemove();
            m_Planes.Remove(plane.boundedPlane.Id);
        }
        /// <summary>
        /// Constructor for plane changed events.
        /// This is normally only used by the <see cref="ARPlane"/> component for <see cref="ARPlane.boundaryChanged"/> events.
        /// </summary>
        /// <param name="plane">The <see cref="ARPlane"/> that triggered the event.</param>
        /// <param name="center">The center of the plane, in plane-relative space.</param>
        /// <param name="normal">The normal of the plane, in plane-relative space.</param>
        /// <param name="convexBoundary">The convex boundary points, in plane-relative space. This may not be <c>null</c>.</param>
        public ARPlaneBoundaryChangedEventArgs(ARPlane plane, Vector3 center, Vector3 normal, List <Vector3> convexBoundary)
        {
            if (convexBoundary == null)
            {
                throw new ArgumentNullException("convexBoundary");
            }

            this.plane          = plane;
            this.center         = center;
            this.normal         = normal;
            this.convexBoundary = convexBoundary;
        }
        /// <summary>
        /// Attempts to create a new reference point that is attached to an existing <see cref="ARPlane"/>.
        /// </summary>
        /// <param name="plane">The <see cref="ARPlane"/> to which to attach.</param>
        /// <param name="pose">The initial <c>Pose</c>, in Unity world space, of the reference point.</param>
        /// <returns>A new <see cref="ARReferencePoint"/> if successful, or <c>null</c> if not.</returns>
        public ARReferencePoint TryAttachReferencePoint(ARPlane plane, Pose pose)
        {
            var referencePointSubsystem = ARSubsystemManager.referencePointSubsystem;

            if (referencePointSubsystem == null)
            {
                return(null);
            }

            if (plane == null)
            {
                throw new ArgumentNullException("plane");
            }

            var sessionRelativePose = m_SessionOrigin.trackablesParent.InverseTransformPose(pose);
            var newId = referencePointSubsystem.AttachReferencePoint(plane.boundedPlane.Id, sessionRelativePose);

            if (newId == TrackableId.InvalidId)
            {
                return(null);
            }

            return(CreateReferencePointComponent(newId, sessionRelativePose));
        }
Esempio n. 7
0
 void OnUpdated(ARPlane plane)
 {
     UpdateVisibility();
 }
 /// <summary>
 /// Attempts to create a new reference point that is attached to an existing <see cref="ARPlane"/>.
 /// </summary>
 /// <param name="plane">The <see cref="ARPlane"/> to which to attach.</param>
 /// <param name="position">The initial position, in Unity world space, of the reference point.</param>
 /// <param name="rotation">The initial rotation, in Unity world space, of the reference point.</param>
 /// <returns>A new <see cref="ARReferencePoint"/> if successful, or <c>null</c> if not.</returns>
 public ARReferencePoint TryAttachReferencePoint(ARPlane plane, Vector3 position, Quaternion rotation)
 {
     return(TryAttachReferencePoint(plane, new Pose(position, rotation)));
 }