Пример #1
0
        /// <summary>
        /// The Unity Update() method.
        /// </summary>
        public void Update()
        {
            {
                if (AutoBind)
                {
                    m_AugmentedFaceList.Clear();
                    Session.GetTrackables <AugmentedFace>(m_AugmentedFaceList, TrackableQueryFilter.All);
                    if (m_AugmentedFaceList.Count != 0)
                    {
                        m_AugmentedFace = m_AugmentedFaceList[0];
                    }
                }

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

            // Update game object position;
            transform.position = m_AugmentedFace.CenterPose.position;
            transform.rotation = m_AugmentedFace.CenterPose.rotation;

            UpdateMesh();
        }
Пример #2
0
        /// <summary>
        /// Factory method for creating and reusing Trackable references from native handles.
        /// </summary>
        /// <param name="nativeHandle">A native handle to a plane that has been acquired.  RELEASE
        /// WILL BE HANDLED BY THIS METHOD.</param>
        /// <returns>A reference to the Trackable. May return <c>null</c> on error or if Trackable
        /// is not handled.</returns>
        public Trackable TrackableFactory(IntPtr nativeHandle)
        {
            if (nativeHandle == IntPtr.Zero)
            {
                return(null);
            }

            Trackable result;

            if (_trackableDict.TryGetValue(nativeHandle, out result))
            {
                // Release aquired handle and return cached result.
                _nativeSession.TrackableApi.Release(nativeHandle);
                return(result);
            }

            // This block needs to construct classes marked Obsolete since those versions are always
            // the most derived type.
#pragma warning disable 618 // Obsolete warning
            ApiTrackableType trackableType = _nativeSession.TrackableApi.GetType(nativeHandle);
            if (trackableType == ApiTrackableType.Plane)
            {
                result = new TrackedPlane(nativeHandle, _nativeSession);
            }
            else if (trackableType == ApiTrackableType.Point)
            {
                result = new TrackedPoint(nativeHandle, _nativeSession);
            }
            else if (trackableType == ApiTrackableType.InstantPlacementPoint)
            {
                result = new InstantPlacementPoint(nativeHandle, _nativeSession);
            }
            else if (trackableType == ApiTrackableType.AugmentedImage)
            {
                result = new AugmentedImage(nativeHandle, _nativeSession);
            }
            else if (trackableType == ApiTrackableType.AugmentedFace)
            {
                result = new AugmentedFace(nativeHandle, _nativeSession);
            }
            else if (ExperimentManager.Instance.IsManagingTrackableType((int)trackableType))
            {
                result =
                    ExperimentManager.Instance.TrackableFactory((int)trackableType, nativeHandle);
            }
            else
            {
                Debug.LogWarning(
                    "TrackableFactory::No constructor for requested trackable type.");
            }
#pragma warning restore 618

            if (result != null)
            {
                _trackableDict.Add(nativeHandle, result);
            }

            return(result);
        }
Пример #3
0
        public void Update()
        {
            if (Application.isEditor)
            {
                return;
            }

            if (_augmentedFace == null)
            {
                List <AugmentedFace> tempList = new List <AugmentedFace>();
                Session.GetTrackables(tempList);
                _augmentedFace = tempList.FirstOrDefault();
            }

            UpdateFace();
        }
Пример #4
0
        public void Update()
        {
            if (!Application.isPlaying)
            {
                return;
            }

            if (AutoBind && m_AugmentedFace == null)
            {
                m_AugmentedFaceList.Clear();
                Session.GetTrackables <AugmentedFace>(m_AugmentedFaceList, TrackableQueryFilter.All);
                if (m_AugmentedFaceList.Count != 0)
                {
                    m_AugmentedFace = m_AugmentedFaceList[0];
                }
            }

            if (m_AugmentedFace == null)
            {
                return;
            }

            _UpdateRegions();
            string[] aThought = new string[7] {
                "Thoughts become things.", "Nothing can harm you as much as your own thoughts unguarded."
                , "What consumes your mind, controls your life.", "Your life is a reflection of your thoughts.",
                "Change starts in your thoughts.", "No thoughts", "Welcome!!TO the brave new world"
            };
            int ra = Random.Range(0, 5);

            if (flag)
            {
                ra = Random.Range(0, 5);
                //Thought.GetComponent<TextMesh>().text= aThought[ra].ToString();
                //ra.ToString();//aThought[ra];
            }
            else
            {
                Thought.GetComponent <TextMesh>().text = filterString(aThought[ra]);  //ra.ToString() + "fdzsfsdfdsgfgsdjkfjsdvfvkjsdvfjsdjfvjsdvjfvjsdvfjv";
            }
        }
        /// <summary>
        /// The Unity Update() method.
        /// </summary>
        public void Update()
        {
            if (!Application.isPlaying)
            {
                return;
            }

            if (AutoBind && m_AugmentedFace == null)
            {
                m_AugmentedFaceList.Clear();
                Session.GetTrackables <AugmentedFace>(m_AugmentedFaceList, TrackableQueryFilter.All);
                if (m_AugmentedFaceList.Count != 0)
                {
                    m_AugmentedFace = m_AugmentedFaceList[0];
                }
            }

            if (m_AugmentedFace == null)
            {
                return;
            }

            _UpdateRegions();
        }
        public void Initialiaze(Text debug_, FacePartInfo objectPartInfo_, AugmentedFace face_)
        {
            var px_ = objectPartInfo_.PositionOffset_.x * 1f / objectPartInfo_.ReferenceScale_.x;
            var py_ = objectPartInfo_.PositionOffset_.y * 1f / objectPartInfo_.ReferenceScale_.y;
            var pz_ = objectPartInfo_.PositionOffset_.z * 1f / objectPartInfo_.ReferenceScale_.z;

            transform.localPosition = new Vector3(px_, py_, pz_);
            transform.localRotation = objectPartInfo_.Rotation_;

            if (objectPartInfo_.Is2D_)
            {
                transform.localScale = objectPartInfo_.Scale_;

                var mf_ = GetComponent <MeshFilter>();
                mf_.mesh = new Mesh();

                var hW_ = objectPartInfo_.Dimension_.x * 0.5f * (1f / objectPartInfo_.ReferenceScale_.x);
                var hH_ = objectPartInfo_.Dimension_.y * 0.5f * (1f / objectPartInfo_.ReferenceScale_.y);

                mf_.mesh.SetVertices(new List <Vector3>()
                {
                    new Vector3(-hW_, -hH_),
                    new Vector3(-hW_, hH_),
                    new Vector3(hW_, hH_),
                    new Vector3(hW_, -hH_)
                });

                mf_.mesh.SetTriangles(new List <int>()
                {
                    0,
                    1,
                    3,
                    1,
                    2,
                    3,
                }, 0);

                mf_.mesh.SetNormals(new List <Vector3>()
                {
                    Vector3.forward,
                    Vector3.forward,
                    Vector3.forward,
                    Vector3.forward
                });

                mf_.mesh.SetUVs(0, new List <Vector2>()
                {
                    new Vector2(0f, 0f),
                    new Vector2(0f, 1f),
                    new Vector2(1f, 1f),
                    new Vector2(1f, 0f)
                });
            }
            else
            {
                var sx_ = objectPartInfo_.Scale_.x * 1f / objectPartInfo_.ReferenceScale_.x;
                var sy_ = objectPartInfo_.Scale_.y * 1f / objectPartInfo_.ReferenceScale_.y;
                var sz_ = objectPartInfo_.Scale_.z * 1f / objectPartInfo_.ReferenceScale_.z;

                transform.localScale = new Vector3(sx_, sy_, sz_);

                if (objectPartInfo_.MeshObjIndex_ < AppManager.Current_.Meshs_.Count)
                {
                    var mesh_ = AppManager.Current_.Meshs_[objectPartInfo_.MeshObjIndex_];
                    GetComponent <MeshFilter>().mesh = mesh_;
                }
            }

            var mr_ = GetComponent <MeshRenderer>();

            mr_.material.mainTexture = FacePartInfo.GetImage(objectPartInfo_.TexturePath_, objectPartInfo_.TextureWidth_, objectPartInfo_.TextureHeight);
        }