Ejemplo n.º 1
0
        public NewHavokAnimation(NewAnimSkeleton skeleton, HKX.HKADefaultAnimatedReferenceFrame refFrame, HKX.HKAAnimationBinding binding)
        {
            Skeleton = skeleton;
            if (refFrame != null)
            {
                RootMotionFrames = new Vector4[refFrame.ReferenceFrameSamples.Size];
                for (int i = 0; i < refFrame.ReferenceFrameSamples.Size; i++)
                {
                    RootMotionFrames[i] = new Vector4(
                        refFrame.ReferenceFrameSamples[i].Vector.X,
                        refFrame.ReferenceFrameSamples[i].Vector.Y,
                        refFrame.ReferenceFrameSamples[i].Vector.Z,
                        refFrame.ReferenceFrameSamples[i].Vector.W);
                }
                RootMotionUp      = new Vector4(refFrame.Up.X, refFrame.Up.Y, refFrame.Up.Z, refFrame.Up.W);
                RootMotionForward = new Vector4(refFrame.Forward.X, refFrame.Forward.Y, refFrame.Forward.Z, refFrame.Forward.W);
            }

            lock (_lock_boneMatrixStuff)
            {
                blendableTransforms = new List <NewBlendableTransform>();
                for (int i = 0; i < skeleton.HkxSkeleton.Count; i++)
                {
                    blendableTransforms.Add(NewBlendableTransform.Identity);
                }
            }

            BlendHint = binding.BlendHint;
        }
        public NewHavokAnimation_SplineCompressed(NewAnimSkeleton skeleton, HKX.HKADefaultAnimatedReferenceFrame refFrame, HKX.HKAAnimationBinding binding, HKX.HKASplineCompressedAnimation anim)
            : base(skeleton, refFrame, binding)
        {
            Duration   = anim.Duration;// Math.Max(anim.Duration, anim.FrameDuration * anim.FrameCount);
            FrameCount = anim.FrameCount;

            FrameDuration = anim.FrameDuration;

            BlockCount        = anim.BlockCount;
            NumFramesPerBlock = anim.FramesPerBlock - 1;

            HkxBoneIndexToTransformTrackMap = new int[skeleton.HkxSkeleton.Count];
            TransformTrackIndexToHkxBoneMap = new int[binding.TransformTrackToBoneIndices.Size];

            for (int i = 0; i < binding.TransformTrackToBoneIndices.Size; i++)
            {
                TransformTrackIndexToHkxBoneMap[i] = -1;
            }

            for (int i = 0; i < skeleton.HkxSkeleton.Count; i++)
            {
                HkxBoneIndexToTransformTrackMap[i] = -1;
            }

            for (int i = 0; i < binding.TransformTrackToBoneIndices.Size; i++)
            {
                short boneIndex = binding.TransformTrackToBoneIndices[i].data;
                if (boneIndex >= 0)
                {
                    HkxBoneIndexToTransformTrackMap[boneIndex] = i;
                }
                TransformTrackIndexToHkxBoneMap[i] = boneIndex;
            }

            Tracks = Havok.SplineCompressedAnimation.ReadSplineCompressedAnimByteBlock(
                isBigEndian: false, anim.GetData(), anim.TransformTrackCount, anim.BlockCount);
        }