Ejemplo n.º 1
0
    private void CheckConsistency(ChannelOutputs channelOutputs)
    {
        var inputs = rigidBoneSystem.ReadInputs(channelOutputs);

        var boneTransformsA = boneSystem.GetBoneTransforms(channelOutputs);
        var boneTransformsB = rigidBoneSystem.GetBoneTransforms(inputs);

        for (int i = 0; i < boneSystem.Bones.Count; ++i)
        {
            var boneTransformA = boneTransformsA[i];
            var boneTransformB = boneTransformsB[i];

            var unposedCenterA = boneSystem.Bones[i].CenterPoint.GetValue(channelOutputs);
            var unposedCenterB = rigidBoneSystem.Bones[i].CenterPoint;

            foreach (var testVector in new Vector3[] { Vector3.Zero, Vector3.Right, Vector3.Up, Vector3.BackwardRH })
            {
                var transformedVectorA = boneTransformA.Transform(unposedCenterA + testVector);
                var transformedVectorB = boneTransformB.Transform(
                    unposedCenterB + boneTransformA.ScalingStage.Transform(testVector));
                float distance = Vector3.Distance(transformedVectorA, transformedVectorB);

                if (distance > 1e-3)
                {
                    throw new Exception("rigid and non-rigid bone transforms are inconsistent");
                }
            }
        }
    }
    public StagedSkinningTransform[] GetBoneTransforms(ChannelOutputs outputs)
    {
        var boneTransforms = boneSystem.GetBoneTransforms(outputs);

        if (childToParentBindPoseTransforms != null)
        {
            BoneSystem.PrependChildToParentBindPoseTransforms(childToParentBindPoseTransforms, boneTransforms);
        }
        return(boneTransforms);
    }
Ejemplo n.º 3
0
    public void Run()
    {
        var outputs = channelSystem.Evaluate(null, inputs);

        var stopwatch  = Stopwatch.StartNew();
        int trialCount = 0;

        while (true)
        {
            boneSystem.GetBoneTransforms(outputs);

            trialCount += 1;
            if (trialCount == 1000)
            {
                Console.WriteLine(stopwatch.Elapsed.TotalMilliseconds / trialCount);

                trialCount = 0;
                stopwatch.Restart();
            }
        }
    }