Exemple #1
0
            public static ShapeKeyData New(float weight, ShapeKeyMorphSO basisSO)
            {
                ShapeKeyData d = new ShapeKeyData();

                //int vcnt = m.vertexCount;

                d.basisSO = basisSO;

                Mesh m = basisSO.GetMesh();

                d.vertices = m.vertices;
                d.normals  = m.normals;
                d.tangents = m.tangents;

                d.weight = weight;

                return(d);
            }
Exemple #2
0
            public void UpdateDiffDataWithCurrentMesh()
            {
                ShapeKeyDataDiff basisData = basisSO.GetShapeKeyDataDiff(0);
                Mesh             m         = basisSO.GetMesh();

                int nonMatchV = 0;
                //int nonMatchN = 0;
                //int nonMatchT = 0;

                // v
                {
                    List <Vector3> basisVertices = basisData.vertices;
                    Vector3[]      meshVertices  = m.vertices;
                    Dbg.Assert(basisVertices.Count == meshVertices.Length, "ShapeKeyDataDiff.UpdateDiffDataWithCurrentMesh: length non match: basisVertices != meshVertices: {0}", m.name);
                    vertices.Clear();
                    indV.Clear();
                    for (int i = 0; i < basisVertices.Count; ++i)
                    {
                        Vector3 basisPos = basisVertices[i];
                        Vector3 meshPos  = meshVertices[i];
                        if (!(basisPos == meshPos))
                        {
                            vertices.Add(meshPos);
                            indV.Add(i);
                            ++nonMatchV;
                        }
                    }
                }

                //// n
                //{
                //    List<Vector3> basisNormals = basisData.normals;
                //    Vector3[] meshNormals = m.normals;
                //    Dbg.Assert(basisNormals.Count == meshNormals.Length, "ShapeKeyDataDiff.UpdateDiffDataWithCurrentMesh: length non match: basisNormal != meshNormals: {0}", m.name);
                //    normals.Clear();
                //    indN.Clear();
                //    for(int i=0; i<basisNormals.Count; ++i)
                //    {
                //        Vector3 basisN = basisNormals[i];
                //        Vector3 meshN = meshNormals[i];
                //        if( ! (basisN == meshN) )
                //        {
                //            normals.Add(meshN);
                //            indN.Add(i);
                //            ++nonMatchN;
                //        }
                //    }
                //}

                //// t
                //{
                //    List<Vector4> basisTangents = basisData.tangents;
                //    Vector4[] meshTangents = m.tangents;
                //    Dbg.Assert(basisTangents.Count == meshTangents.Length, "ShapeKeyDataDiff.UpdateDiffDataWithCurrentMesh: length non match: basisTangents != meshTangents: {0}", m.name);
                //    tangents.Clear();
                //    indT.Clear();
                //    for (int i = 0; i < basisTangents.Count; ++i)
                //    {
                //        Vector4 basisT = basisTangents[i];
                //        Vector4 meshT = meshTangents[i];
                //        if (!(basisT == meshT))
                //        {
                //            tangents.Add(meshT);
                //            indT.Add(i);
                //            ++nonMatchT;
                //        }
                //    }
                //}

                //Dbg.Log("ShapeKeyDataDiff.UpdateDiffDataWithCurrentMesh: V: {0}, N: {1}, T:{2}", nonMatchV, nonMatchN, nonMatchT);
            }