示例#1
0
        public void CalculateWeights(IWeightsGenerator weightsGenerator, ISelection <int> selection, float filterTolerance)
        {
            Debug.Assert(spriteMeshData != null);

            Vector2[] controlPoints;
            Edge[]    bones;
            int[]     pins;

            GetControlPoints(out controlPoints, out bones, out pins);

            Vector2[] vertices = new Vector2[spriteMeshData.vertexCount];

            for (int i = 0; i < spriteMeshData.vertexCount; ++i)
            {
                vertices[i] = spriteMeshData.GetPosition(i);
            }

            BoneWeight[] boneWeights = weightsGenerator.Calculate(spriteMeshData.spriteName, vertices, spriteMeshData.indices.ToArray(), spriteMeshData.edges.ToArray(), controlPoints, bones, pins);

            Debug.Assert(boneWeights.Length == spriteMeshData.vertexCount);

            for (int i = 0; i < spriteMeshData.vertexCount; ++i)
            {
                if (selection == null || (selection.Count == 0 || selection.Contains(i)))
                {
                    EditableBoneWeight editableBoneWeight = EditableBoneWeightUtility.CreateFromBoneWeight(boneWeights[i]);

                    if (filterTolerance > 0f)
                    {
                        editableBoneWeight.FilterChannels(filterTolerance);
                        editableBoneWeight.Normalize();
                    }

                    spriteMeshData.SetWeight(i, editableBoneWeight);
                }
            }
        }
示例#2
0
 public Vertex2D(Vector2 position, BoneWeight weights)
 {
     m_Position           = position;
     m_EditableBoneWeight = EditableBoneWeightUtility.CreateFromBoneWeight(weights);
 }
示例#3
0
 public Vertex2D(Vector2 position)
 {
     m_Position           = position;
     m_EditableBoneWeight = EditableBoneWeightUtility.CreateFromBoneWeight(new BoneWeight());
 }