Beispiel #1
0
        /// <summary>
        /// Update mesh with a face mesh vertices, texture coordinates and indices.
        /// </summary>
        private void _UpdateMesh()
        {
            m_AugmentedFace.GetVertices(m_MeshVertices);
            m_AugmentedFace.GetNormals(m_MeshNormals);

            if (landmark != null && m_MeshVertices.Count != 0)
            {
                landmark.setFaceRotation(m_AugmentedFace.CenterPose.rotation);
                landmark.setFaceLandmark(m_MeshVertices);
            }

            if (!m_MeshInitialized)
            {
                m_AugmentedFace.GetTextureCoordinates(m_MeshUVs);
                m_AugmentedFace.GetTriangleIndices(m_MeshIndices);

                // Only update mesh indices and uvs once as they don't change every frame.
                m_MeshInitialized = true;
            }

            m_Mesh.Clear();
            m_Mesh.SetVertices(m_MeshVertices);
            m_Mesh.SetNormals(m_MeshNormals);
            m_Mesh.SetTriangles(m_MeshIndices, 0);
            m_Mesh.SetUVs(0, m_MeshUVs);

            m_Mesh.RecalculateBounds();
        }
        /// <summary>
        /// Update mesh with a face mesh vertices, texture coordinates and indices.
        /// </summary>
        private void _UpdateMesh()
        {
            m_AugmentedFace.GetVertices(m_MeshVertices);
            float threshold = 1.15f;

            m_AugmentedFace.GetNormals(m_MeshNormals);
            float p = (m_MeshNormals[42].x + m_MeshNormals[191].x + m_MeshNormals[183].x) / 3;
            float py = (m_MeshNormals[42].y + m_MeshNormals[191].y + m_MeshNormals[183].y) / 3;
            float ay = (m_MeshNormals[271].y + m_MeshNormals[415].y + m_MeshNormals[407].y) / 3;

            float avgY = (((ay - m_MeshNormals[16].y) + (py - m_MeshNormals[16].y)) / 2) * -1;
            if (avgY > threshold)
            {
                debugText.text = ("smiling" + avgY + threshold);
            }
            else
            {
                debugText.text = ("Not smiling" + avgY + threshold);
            }

            //debugText.text = ("Vertex Position is: " + m_MeshNormals[11].x); //left side of mouth
            //   debugText2.text = ("Vertex Position is: " + m_MeshNormals[271].x + m_MeshNormals[415].x + m_MeshNormals[407].x); // right side of mouth

            //      debugText.text = ("Vertex Position is: " + m_MeshNormals[42].y + m_MeshNormals[191].y + m_MeshNormals[183].y);
            //     debugText2.text = ("Vertex Position is: " + m_MeshNormals[271].y + m_MeshNormals[415].y + m_MeshNormals[407].y);

            //    debugText.text = ("Vertex Position is: " + m_MeshNormals[42].z + m_MeshNormals[191].z + m_MeshNormals[183].z);
            //   debugText2.text = ("Vertex Position is: " + m_MeshNormals[271].z + m_MeshNormals[415].z + m_MeshNormals[407].z);
            //  debugText3.text = ("Vertex Position is: " + (py - m_MeshNormals[16].y));


            debugText2.text = ("Vertex Position is: " + ((((ay - m_MeshNormals[16].y) + (py - m_MeshNormals[16].y)) / 2) * -1));



            if (!m_MeshInitialized)
            {
                m_AugmentedFace.GetTextureCoordinates(m_MeshUVs);
                m_AugmentedFace.GetTriangleIndices(m_MeshIndices);

                // Only update mesh indices and uvs once as they don't change every frame.
                m_MeshInitialized = true;
            }

            m_Mesh.Clear();
            m_Mesh.SetVertices(m_MeshVertices);
            m_Mesh.SetNormals(m_MeshNormals);
            m_Mesh.SetTriangles(m_MeshIndices, 0);
            m_Mesh.SetUVs(0, m_MeshUVs);
            // pos = (m_MeshVertices.);

            m_Mesh.RecalculateBounds();



        }
        /// <summary>
        /// Update mesh with a face mesh vertices, texture coordinates and indices.
        /// </summary>
        private void UpdateMesh()
        {
            m_AugmentedFace.GetVertices(m_MeshVertices);
            m_AugmentedFace.GetNormals(m_MeshNormals);

            if (!m_MeshInitialized)
            {
                m_AugmentedFace.GetTextureCoordinates(m_MeshUVs);
                m_AugmentedFace.GetTriangleIndices(m_MeshIndices);

                // Only update mesh indices and uvs once as they don't change every frame.
                m_MeshInitialized = true;
            }

            DetectHeadShaking();
            Filter.gameObject.SetActive(_filterSwitch);
        }
        /// <summary>
        /// Update mesh with a face mesh vertices, texture coordinates and indices.
        /// </summary>
        private void _UpdateMesh()
        {
            m_AugmentedFace.GetVertices(m_MeshVertices);
            m_AugmentedFace.GetNormals(m_MeshNormals);

            if (!m_MeshInitialized)
            {
                m_AugmentedFace.GetTextureCoordinates(m_MeshUVs);
                m_AugmentedFace.GetTriangleIndices(m_MeshIndices);

                // Only update mesh indices and uvs once as they don't change every frame.
                m_MeshInitialized = true;
            }

            m_Mesh.Clear();
            m_Mesh.SetVertices(m_MeshVertices);
            m_Mesh.SetNormals(m_MeshNormals);
            m_Mesh.SetTriangles(m_MeshIndices, 0);
            m_Mesh.SetUVs(0, m_MeshUVs);

            m_Mesh.RecalculateBounds();
        }