Exemple #1
0
        public void TwoBonesOutsideMesh_ReturnsDefaultWeight()
        {
            SpriteBoneData spriteBone = m_SpriteMeshData.bones[0];

            spriteBone.position      += Vector2.right * 10f;
            spriteBone.endPosition   += Vector2.right * 10f;
            m_SpriteMeshData.bones[0] = spriteBone;

            spriteBone                = m_SpriteMeshData.bones[1];
            spriteBone.position      += Vector2.right * 10f;
            spriteBone.endPosition   += Vector2.right * 10f;
            m_SpriteMeshData.bones[1] = spriteBone;

            BoneWeight[] boneWeights = CalculateWeights();

            BoneWeight[] expected = new BoneWeight[] {
                BoundedBiharmonicWeightsGenerator.defaultWeight,
                BoundedBiharmonicWeightsGenerator.defaultWeight,
                BoundedBiharmonicWeightsGenerator.defaultWeight,
                BoundedBiharmonicWeightsGenerator.defaultWeight,
                BoundedBiharmonicWeightsGenerator.defaultWeight,
                BoundedBiharmonicWeightsGenerator.defaultWeight
            };

            Assert.AreEqual(m_SpriteMeshData.vertices.Count, boneWeights.Length, "Weights count don't match vertex count");

            for (int i = 0; i < boneWeights.Length; ++i)
            {
                AssertBoneWeightContainsChannels(expected[i], boneWeights[i]);
            }
        }
        public void TwoBonesOutsideMesh_ReturnsZeroInfluences()
        {
            SpriteBoneData spriteBone = m_SpriteMeshData.bones[0];

            spriteBone.position      += Vector2.right * 10f;
            m_SpriteMeshData.bones[0] = spriteBone;

            spriteBone                = m_SpriteMeshData.bones[1];
            spriteBone.position      += Vector2.right * 10f;
            m_SpriteMeshData.bones[1] = spriteBone;

            BoneWeight[] boneWeights = CalculateWeights();

            BoneWeight[] expected = new BoneWeight[] {
                new BoneWeight()
                {
                    boneIndex0 = 0,
                    boneIndex1 = 1,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 0f,
                    weight1    = 0f,
                    weight2    = 0f,
                    weight3    = 0f
                },
                new BoneWeight()
                {
                    boneIndex0 = 0,
                    boneIndex1 = 1,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 0f,
                    weight1    = 0f,
                    weight2    = 0f,
                    weight3    = 0f
                },
                new BoneWeight()
                {
                    boneIndex0 = 0,
                    boneIndex1 = 1,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 0f,
                    weight1    = 0f,
                    weight2    = 0f,
                    weight3    = 0f
                },
                new BoneWeight()
                {
                    boneIndex0 = 0,
                    boneIndex1 = 1,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 0f,
                    weight1    = 0f,
                    weight2    = 0f,
                    weight3    = 0f
                },
                new BoneWeight()
                {
                    boneIndex0 = 0,
                    boneIndex1 = 1,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 0f,
                    weight1    = 0f,
                    weight2    = 0f,
                    weight3    = 0f
                },
                new BoneWeight()
                {
                    boneIndex0 = 0,
                    boneIndex1 = 1,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 0f,
                    weight1    = 0f,
                    weight2    = 0f,
                    weight3    = 0f
                }
            };

            Assert.AreEqual(m_SpriteMeshData.vertices.Count, boneWeights.Length, "Weights count don't match vertex count");

            for (int i = 0; i < boneWeights.Length; ++i)
            {
                AssertBoneWeight(expected[i], boneWeights[i]);
            }
        }
        public void OneBonePartiallyOutsideMesh_CreatesInfluencesForBothBones()
        {
            SpriteBoneData spriteBone = m_SpriteMeshData.bones[0];

            spriteBone.position      += Vector2.left * 0.5f;
            m_SpriteMeshData.bones[0] = spriteBone;

            BoneWeight[] boneWeights = CalculateWeights();

            BoneWeight[] expected = new BoneWeight[] {
                new BoneWeight()
                {
                    boneIndex0 = 0,
                    boneIndex1 = 1,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 0.9719688f,
                    weight1    = 0.0280311815f,
                    weight2    = 0f,
                    weight3    = 0f
                },
                new BoneWeight()
                {
                    boneIndex0 = 0,
                    boneIndex1 = 1,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 0.908445239f,
                    weight1    = 0.09155474f,
                    weight2    = 0f,
                    weight3    = 0f
                },
                new BoneWeight()
                {
                    boneIndex0 = 1,
                    boneIndex1 = 0,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 0.684992f,
                    weight1    = 0.315007955f,
                    weight2    = 0f,
                    weight3    = 0f
                },
                new BoneWeight()
                {
                    boneIndex0 = 1,
                    boneIndex1 = 0,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 0.739078164f,
                    weight1    = 0.260921866f,
                    weight2    = 0f,
                    weight3    = 0f
                },
                new BoneWeight()
                {
                    boneIndex0 = 1,
                    boneIndex1 = 0,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 1f,
                    weight1    = 0f,
                    weight2    = 0f,
                    weight3    = 0f
                },
                new BoneWeight()
                {
                    boneIndex0 = 1,
                    boneIndex1 = 0,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 1f,
                    weight1    = 0f,
                    weight2    = 0f,
                    weight3    = 0f
                }
            };

            Assert.AreEqual(m_SpriteMeshData.vertices.Count, boneWeights.Length, "Weights count don't match vertex count");

            for (int i = 0; i < boneWeights.Length; ++i)
            {
                AssertBoneWeight(expected[i], boneWeights[i]);
            }
        }
Exemple #4
0
        public void OneBonePartiallyOutsideMesh_CreatesInfluencesForBothBones()
        {
            SpriteBoneData spriteBone = m_SpriteMeshData.bones[0];

            spriteBone.position      += Vector2.left * 0.5f;
            m_SpriteMeshData.bones[0] = spriteBone;

            BoneWeight[] boneWeights = CalculateWeights();

            BoneWeight[] expected = new BoneWeight[] {
                new BoneWeight()
                {
                    boneIndex0 = 0,
                    boneIndex1 = 1,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 0.9966453f,
                    weight1    = 0.00335471169f,
                    weight2    = 0f,
                    weight3    = 0f
                },
                new BoneWeight()
                {
                    boneIndex0 = 0,
                    boneIndex1 = 1,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 0.983102858f,
                    weight1    = 0.0168971363f,
                    weight2    = 0f,
                    weight3    = 0f
                },
                new BoneWeight()
                {
                    boneIndex0 = 1,
                    boneIndex1 = 0,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 0.5451388f,
                    weight1    = 0.454861224f,
                    weight2    = 0f,
                    weight3    = 0f
                },
                new BoneWeight()
                {
                    boneIndex0 = 1,
                    boneIndex1 = 0,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 0.5641289f,
                    weight1    = 0.435871124f,
                    weight2    = 0f,
                    weight3    = 0f
                },
                new BoneWeight()
                {
                    boneIndex0 = 1,
                    boneIndex1 = 0,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 1f,
                    weight1    = 0f,
                    weight2    = 0f,
                    weight3    = 0f
                },
                new BoneWeight()
                {
                    boneIndex0 = 1,
                    boneIndex1 = 0,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 1f,
                    weight1    = 0f,
                    weight2    = 0f,
                    weight3    = 0f
                }
            };

            Assert.AreEqual(m_SpriteMeshData.vertices.Count, boneWeights.Length, "Weights count don't match vertex count");

            for (int i = 0; i < boneWeights.Length; ++i)
            {
                AssertBoneWeightContainsChannels(expected[i], boneWeights[i]);
            }
        }
Exemple #5
0
        public void OneBoneOutsideMesh_CreatesInfluencesOfTheOtherBones()
        {
            SpriteBoneData spriteBone = m_SpriteMeshData.bones[0];

            spriteBone.position      += Vector2.right * 10f;
            spriteBone.endPosition   += Vector2.right * 10f;
            m_SpriteMeshData.bones[0] = spriteBone;

            BoneWeight[] boneWeights = CalculateWeights();

            BoneWeight[] expected = new BoneWeight[] {
                new BoneWeight()
                {
                    boneIndex0 = 1,
                    boneIndex1 = 0,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 1f,
                    weight1    = 0f,
                    weight2    = 0f,
                    weight3    = 0f
                },
                new BoneWeight()
                {
                    boneIndex0 = 1,
                    boneIndex1 = 0,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 1f,
                    weight1    = 0f,
                    weight2    = 0f,
                    weight3    = 0f
                },
                new BoneWeight()
                {
                    boneIndex0 = 1,
                    boneIndex1 = 0,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 1f,
                    weight1    = 0f,
                    weight2    = 0f,
                    weight3    = 0f
                },
                new BoneWeight()
                {
                    boneIndex0 = 1,
                    boneIndex1 = 0,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 1f,
                    weight1    = 0f,
                    weight2    = 0f,
                    weight3    = 0f
                },
                new BoneWeight()
                {
                    boneIndex0 = 1,
                    boneIndex1 = 0,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 1f,
                    weight1    = 0f,
                    weight2    = 0f,
                    weight3    = 0f
                },
                new BoneWeight()
                {
                    boneIndex0 = 1,
                    boneIndex1 = 0,
                    boneIndex2 = 0,
                    boneIndex3 = 0,
                    weight0    = 1f,
                    weight1    = 0f,
                    weight2    = 0f,
                    weight3    = 0f
                }
            };

            Assert.AreEqual(m_SpriteMeshData.vertices.Count, boneWeights.Length, "Weights count don't match vertex count");

            for (int i = 0; i < boneWeights.Length; ++i)
            {
                AssertBoneWeightContainsChannels(expected[i], boneWeights[i]);
            }
        }