示例#1
0
        private void ApplyBoneMatricesInternal(SkeletonAnimRigNode node, MeshEntity entity, Matrix4x4[] boneMatrices, float timeStamp, Matrix4x4 parentTransform)
        {
            string    name          = node.Name;
            Matrix4x4 nodeTransform = node.LocalTransform;

            SkeletonAnimChannel animChannel = GetMeshAnimBone(name);

            if (animChannel != null)
            {
                nodeTransform = animChannel.GetMatrixAtTimestamp(timeStamp);
            }

            Matrix4x4 globalTransform = nodeTransform * parentTransform;

            MeshBone bone = BoneIndexFromEntity(entity, name);

            if (bone != null)
            {
                boneMatrices[bone.BoneIndex] = bone.OffsetMatrix * globalTransform;
            }

            if (node.Children == null)
            {
                return;
            }
            for (var i = 0; i < node.Children.Length; i++)
            {
                SkeletonAnimRigNode child = node.Children[i];
                ApplyBoneMatricesInternal(child, entity, boneMatrices, timeStamp, globalTransform);
            }
        }
示例#2
0
        private SkeletonAnimChannel GetMeshAnimBone(string name)
        {
            for (var i = 0; i < AnimChannels.Length; i++)
            {
                SkeletonAnimChannel channels = AnimChannels[i];
                if (channels.Name == name)
                {
                    return(channels);
                }
            }

            return(null);
        }