コード例 #1
0
        public void LerpBoneWeight_AllIndicesDifferent()
        {
            BoneWeight first = new BoneWeight();

            first.boneIndex0 = 0;
            first.boneIndex1 = 1;
            first.boneIndex2 = 2;
            first.boneIndex3 = 3;
            first.weight0    = 0.1f;
            first.weight1    = 0.2f;
            first.weight2    = 0.3f;
            first.weight3    = 0.4f;

            BoneWeight second = new BoneWeight();

            second.boneIndex0 = 4;
            second.boneIndex1 = 5;
            second.boneIndex2 = 6;
            second.boneIndex3 = 7;
            second.weight0    = 0.4f;
            second.weight1    = 0.3f;
            second.weight2    = 0.2f;
            second.weight3    = 0.1f;

            BoneWeight result = EditableBoneWeightUtility.Lerp(first, second, 0f);

            Assert.IsTrue(ContainsChannel(result, 3, 0.4f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 2, 0.3f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 1, 0.2f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 0, 0.1f), "Does not contain expected weights");

            result = EditableBoneWeightUtility.Lerp(first, second, 0.2f);

            Assert.IsTrue(ContainsChannel(result, 3, 0.319999993f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 2, 0.24000001f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 1, 0.159999996f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 4, 0.0800000057f), "Does not contain expected weights");

            result = EditableBoneWeightUtility.Lerp(first, second, 0.5f);

            Assert.IsTrue(ContainsChannel(result, 4, 0.200000003f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 3, 0.200000003f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 2, 0.150000006f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 5, 0.150000006f), "Does not contain expected weights");

            result = EditableBoneWeightUtility.Lerp(first, second, 0.8f);

            Assert.IsTrue(ContainsChannel(result, 4, 0.320000023f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 5, 0.24000001f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 6, 0.160000011f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 7, 0.0800000057f), "Does not contain expected weights");

            result = EditableBoneWeightUtility.Lerp(first, second, 1f);

            Assert.IsTrue(ContainsChannel(result, 4, 0.4f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 5, 0.3f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 6, 0.2f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 7, 0.1f), "Does not contain expected weights");
        }
コード例 #2
0
        public void LerpBoneWeight_SomeIndicesInCommon()
        {
            BoneWeight first = new BoneWeight();

            first.boneIndex0 = 0;
            first.boneIndex1 = 1;
            first.boneIndex2 = 2;
            first.boneIndex3 = 3;
            first.weight0    = 0.1f;
            first.weight1    = 0.2f;
            first.weight2    = 0.3f;
            first.weight3    = 0.4f;

            BoneWeight second = new BoneWeight();

            second.boneIndex0 = 0;
            second.boneIndex1 = 4;
            second.boneIndex2 = 2;
            second.boneIndex3 = 5;
            second.weight0    = 0.4f;
            second.weight1    = 0.3f;
            second.weight2    = 0.2f;
            second.weight3    = 0.1f;

            BoneWeight result = EditableBoneWeightUtility.Lerp(first, second, 0f);

            Assert.IsTrue(ContainsChannel(result, 3, 0.4f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 2, 0.3f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 1, 0.2f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 0, 0.1f), "Does not contain expected weights");

            result = EditableBoneWeightUtility.Lerp(first, second, 0.2f);

            Assert.IsTrue(ContainsChannel(result, 3, 0.319999993f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 2, 0.279999971f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 1, 0.159999996f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 0, 0.159999996f), "Does not contain expected weights");

            result = EditableBoneWeightUtility.Lerp(first, second, 0.5f);

            Assert.IsTrue(ContainsChannel(result, 0, 0.25000003f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 2, 0.249999985f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 3, 0.200000003f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 4, 0.150000006f), "Does not contain expected weights");

            result = EditableBoneWeightUtility.Lerp(first, second, 0.8f);

            Assert.IsTrue(ContainsChannel(result, 0, 0.340000033f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 4, 0.239999995f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 2, 0.219999999f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 5, 0.0799999982f), "Does not contain expected weights");

            result = EditableBoneWeightUtility.Lerp(first, second, 1f);

            Assert.IsTrue(ContainsChannel(result, 0, 0.4f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 4, 0.3f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 2, 0.2f), "Does not contain expected weights");
            Assert.IsTrue(ContainsChannel(result, 5, 0.1f), "Does not contain expected weights");
        }
コード例 #3
0
        public void LerpBoneWeight_AllIndicesDifferent()
        {
            var first = new BoneWeight()
            {
                boneIndex0 = 0,
                boneIndex1 = 1,
                boneIndex2 = 2,
                boneIndex3 = 3,
                weight0    = 0.1f,
                weight1    = 0.2f,
                weight2    = 0.3f,
                weight3    = 0.4f
            };

            var second = new BoneWeight()
            {
                boneIndex0 = 4,
                boneIndex1 = 5,
                boneIndex2 = 6,
                boneIndex3 = 7,
                weight0    = 0.4f,
                weight1    = 0.3f,
                weight2    = 0.2f,
                weight3    = 0.1f
            };

            var result = EditableBoneWeightUtility.Lerp(first, second, 0f);

            var expected = new BoneWeight()
            {
                boneIndex0 = 3,
                boneIndex1 = 2,
                boneIndex2 = 1,
                boneIndex3 = 0,
                weight0    = 0.4f,
                weight1    = 0.3f,
                weight2    = 0.2f,
                weight3    = 0.1f
            };

            AssertBoneWeightContainsChannels(expected, result);

            result = EditableBoneWeightUtility.Lerp(first, second, 0.2f);

            expected = new BoneWeight()
            {
                boneIndex0 = 3,
                boneIndex1 = 2,
                boneIndex2 = 1,
                boneIndex3 = 4,
                weight0    = 0.319999993f,
                weight1    = 0.24000001f,
                weight2    = 0.159999996f,
                weight3    = 0.0800000057f
            };

            AssertBoneWeightContainsChannels(expected, result);

            result = EditableBoneWeightUtility.Lerp(first, second, 0.5f);

            expected = new BoneWeight()
            {
                boneIndex0 = 4,
                boneIndex1 = 3,
                boneIndex2 = 2,
                boneIndex3 = 5,
                weight0    = 0.200000003f,
                weight1    = 0.200000003f,
                weight2    = 0.150000006f,
                weight3    = 0.150000006f
            };

            AssertBoneWeightContainsChannels(expected, result);

            result = EditableBoneWeightUtility.Lerp(first, second, 0.8f);

            expected = new BoneWeight()
            {
                boneIndex0 = 4,
                boneIndex1 = 5,
                boneIndex2 = 6,
                boneIndex3 = 7,
                weight0    = 0.320000023f,
                weight1    = 0.24000001f,
                weight2    = 0.160000011f,
                weight3    = 0.0800000057f
            };

            AssertBoneWeightContainsChannels(expected, result);

            result = EditableBoneWeightUtility.Lerp(first, second, 1f);

            expected = new BoneWeight()
            {
                boneIndex0 = 4,
                boneIndex1 = 5,
                boneIndex2 = 6,
                boneIndex3 = 7,
                weight0    = 0.4f,
                weight1    = 0.3f,
                weight2    = 0.2f,
                weight3    = 0.1f
            };

            AssertBoneWeightContainsChannels(expected, result);
        }
コード例 #4
0
        public void LerpBoneWeight_SomeIndicesInCommon()
        {
            var first = new BoneWeight()
            {
                boneIndex0 = 0,
                boneIndex1 = 1,
                boneIndex2 = 2,
                boneIndex3 = 3,
                weight0    = 0.1f,
                weight1    = 0.2f,
                weight2    = 0.3f,
                weight3    = 0.4f
            };

            var second = new BoneWeight()
            {
                boneIndex0 = 0,
                boneIndex1 = 4,
                boneIndex2 = 2,
                boneIndex3 = 5,
                weight0    = 0.4f,
                weight1    = 0.3f,
                weight2    = 0.2f,
                weight3    = 0.1f
            };

            var result = EditableBoneWeightUtility.Lerp(first, second, 0f);

            var expected = new BoneWeight()
            {
                boneIndex0 = 3,
                boneIndex1 = 2,
                boneIndex2 = 1,
                boneIndex3 = 0,
                weight0    = 0.4f,
                weight1    = 0.3f,
                weight2    = 0.2f,
                weight3    = 0.1f
            };

            AssertBoneWeightContainsChannels(expected, result);

            result = EditableBoneWeightUtility.Lerp(first, second, 0.2f);

            expected = new BoneWeight()
            {
                boneIndex0 = 3,
                boneIndex1 = 2,
                boneIndex2 = 1,
                boneIndex3 = 0,
                weight0    = 0.320000023f,
                weight1    = 0.280000001f,
                weight2    = 0.160000011f,
                weight3    = 0.160000011f
            };

            AssertBoneWeightContainsChannels(expected, result);

            result = EditableBoneWeightUtility.Lerp(first, second, 0.5f);

            expected = new BoneWeight()
            {
                boneIndex0 = 0,
                boneIndex1 = 2,
                boneIndex2 = 3,
                boneIndex3 = 4,
                weight0    = 0.25000003f,
                weight1    = 0.249999985f,
                weight2    = 0.200000003f,
                weight3    = 0.150000006f
            };

            AssertBoneWeightContainsChannels(expected, result);

            result = EditableBoneWeightUtility.Lerp(first, second, 0.8f);

            expected = new BoneWeight()
            {
                boneIndex0 = 0,
                boneIndex1 = 4,
                boneIndex2 = 2,
                boneIndex3 = 5,
                weight0    = 0.340000033f,
                weight1    = 0.239999995f,
                weight2    = 0.219999999f,
                weight3    = 0.0799999982f
            };

            AssertBoneWeightContainsChannels(expected, result);

            result = EditableBoneWeightUtility.Lerp(first, second, 1f);

            Assert.AreEqual(0, result.boneIndex0, "Incorrect boneIndex");
            Assert.AreEqual(4, result.boneIndex1, "Incorrect boneIndex");
            Assert.AreEqual(2, result.boneIndex2, "Incorrect boneIndex");
            Assert.AreEqual(5, result.boneIndex3, "Incorrect boneIndex");
            Assert.AreEqual(0.4f, result.weight0, "Incorrect boneWeight");
            Assert.AreEqual(0.3f, result.weight1, "Incorrect boneWeight");
            Assert.AreEqual(0.2f, result.weight2, "Incorrect boneWeight");
            Assert.AreEqual(0.1f, result.weight3, "Incorrect boneWeight");

            expected = new BoneWeight()
            {
                boneIndex0 = 0,
                boneIndex1 = 4,
                boneIndex2 = 2,
                boneIndex3 = 5,
                weight0    = 0.4f,
                weight1    = 0.3f,
                weight2    = 0.2f,
                weight3    = 0.1f
            };

            AssertBoneWeightContainsChannels(expected, result);
        }
コード例 #5
0
        public void LerpBoneWeight_AllIndicesInCommon()
        {
            var first = new BoneWeight()
            {
                boneIndex0 = 0,
                boneIndex1 = 1,
                boneIndex2 = 2,
                boneIndex3 = 3,
                weight0    = 0.1f,
                weight1    = 0.2f,
                weight2    = 0.3f,
                weight3    = 0.4f
            };

            var second = new BoneWeight()
            {
                boneIndex0 = 0,
                boneIndex1 = 1,
                boneIndex2 = 2,
                boneIndex3 = 3,
                weight0    = 0.4f,
                weight1    = 0.3f,
                weight2    = 0.2f,
                weight3    = 0.1f
            };

            var result = EditableBoneWeightUtility.Lerp(first, second, 0f);

            var expected = new BoneWeight()
            {
                boneIndex0 = 3,
                boneIndex1 = 2,
                boneIndex2 = 1,
                boneIndex3 = 0,
                weight0    = 0.4f,
                weight1    = 0.3f,
                weight2    = 0.2f,
                weight3    = 0.1f
            };

            AssertBoneWeightContainsChannels(expected, result);

            result = EditableBoneWeightUtility.Lerp(first, second, 0.2f);

            expected = new BoneWeight()
            {
                boneIndex0 = 3,
                boneIndex1 = 2,
                boneIndex2 = 1,
                boneIndex3 = 0,
                weight0    = 0.340000033f,
                weight1    = 0.279999942f,
                weight2    = 0.219999984f,
                weight3    = 0.159999982f
            };

            AssertBoneWeightContainsChannels(expected, result);

            result = EditableBoneWeightUtility.Lerp(first, second, 0.5f);

            expected = new BoneWeight()
            {
                boneIndex0 = 0,
                boneIndex1 = 2,
                boneIndex2 = 3,
                boneIndex3 = 1,
                weight0    = 0.25000003f,
                weight1    = 0.25f,
                weight2    = 0.25f,
                weight3    = 0.249999985f
            };

            AssertBoneWeightContainsChannels(expected, result);

            result = EditableBoneWeightUtility.Lerp(first, second, 0.8f);

            expected = new BoneWeight()
            {
                boneIndex0 = 0,
                boneIndex1 = 1,
                boneIndex2 = 2,
                boneIndex3 = 3,
                weight0    = 0.340000033f,
                weight1    = 0.279999971f,
                weight2    = 0.220000014f,
                weight3    = 0.159999996f
            };

            AssertBoneWeightContainsChannels(expected, result);

            result = EditableBoneWeightUtility.Lerp(first, second, 1f);

            expected = new BoneWeight()
            {
                boneIndex0 = 0,
                boneIndex1 = 1,
                boneIndex2 = 2,
                boneIndex3 = 3,
                weight0    = 0.4f,
                weight1    = 0.3f,
                weight2    = 0.2f,
                weight3    = 0.1f
            };

            AssertBoneWeightContainsChannels(expected, result);
        }