Beispiel #1
0
        /// <summary>
        /// Called by MARS when the SynthesizedObject is initialized
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();
            if (MarsTrackableId.InvalidId == m_Marker.id)
            {
                m_Marker.id = MarsTrackableId.Create();
            }

            m_IdSource      = GetComponent <SynthesizedMarkerId>();
            m_PoseSource    = GetComponent <SynthesizedPose>();
            m_ExtentsSource = GetComponent <SynthesizedBounds2D>();

            if (!Guid.TryParse(m_IdSource.GetTraitData(), out var guid))
            {
                Debug.LogWarning($"The Synthesized Marker guid on '{name}' is missing or improperly formed.  " +
                                 "Image Marker Proxies may not match in simulation.");
                guid = Guid.Empty;
            }

            m_Marker.markerId = guid;
            m_Marker.texture  = m_IdSource.Texture;

            GetData();

            // We cannot guarantee that the synthetic marker has been set so use the renderer scale as initial size
            m_IdSource.UpdateMarkerSizeWithLocalScale();
        }
Beispiel #2
0
        /// <summary>
        /// Called by MARS when the SynthesizedObject is initialized
        /// </summary>
        public override void Initialize()
        {
            CopyToRuntimePlane();

            m_PoseSource      = GetComponent <SynthesizedPose>();
            m_AlignmentSource = GetComponent <SynthesizedAlignment>();
            m_ExtentsSource   = GetComponent <SynthesizedBounds2D>();
        }
Beispiel #3
0
        /// <summary>
        /// Called by Unity when the object is enabled
        /// </summary>
        protected override void OnEnable()
        {
            base.OnEnable();

            if (m_ExtentsSource == null)
            {
                m_ExtentsSource = GetComponent <SynthesizedBounds2D>();
            }
        }
Beispiel #4
0
        /// <summary>
        /// Set the data for the MRPlane backing this SynthesizedPlane
        /// </summary>
        /// <param name="vertices">The vertices for the boundary polygon</param>
        /// <param name="center">The position of the center of the plane</param>
        /// <param name="extents">The extents of the boundary polygon</param>
        public void SetMRPlaneData(List <Vector3> vertices, Vector3 center, Vector2 extents)
        {
            if (m_ExtentsSource == null)
            {
                m_ExtentsSource = GetComponent <SynthesizedBounds2D>();
            }

            m_ExtentsSource.baseBounds = extents;
            m_Plane.center             = center;

            m_Plane.vertices.Clear();
            m_Plane.indices.Clear();
            m_Plane.normals.Clear();
            m_Plane.textureCoordinates.Clear();

            m_Plane.vertices.AddRange(vertices);
            PlaneUtils.TriangulatePlaneFromVertices(m_Plane.pose, m_Plane.vertices, m_Plane.indices, m_Plane.normals, m_Plane.textureCoordinates);

            SetMeshData();
            CopyToRuntimePlane();

            m_MRPlaneGenerated = false;
        }