コード例 #1
0
        static AnimationHeader GetAnimationHeader(ByteChunk chunk)
        {
            if (chunk.BytesLeft == 0)
            {
                throw new Exception("Trying to load animation header with no data, chunk size = 0");
            }

            var header = new AnimationHeader();

            header.AnimationType      = chunk.ReadUInt32();
            header.Unknown0_alwaysOne = chunk.ReadUInt32();        // Always 1?
            header.FrameRate          = chunk.ReadSingle();
            var nameLength = chunk.ReadShort();

            header.SkeletonName        = chunk.ReadFixedLength(nameLength);
            header.Unknown1_alwaysZero = chunk.ReadUInt32();        // Always 0? padding?

            if (header.AnimationType == 7)
            {
                header.AnimationTotalPlayTimeInSec = chunk.ReadSingle(); // Play time
            }
            bool isSupportedAnimationFile = header.AnimationType == 5 || header.AnimationType == 6 || header.AnimationType == 7;

            if (!isSupportedAnimationFile)
            {
                throw new Exception($"Unsuported animation format: {header.AnimationType}");
            }

            return(header);
        }
コード例 #2
0
        public AnimationFragmentEntry(ByteChunk data)
        {
            _id   = data.ReadInt32();
            _slot = data.ReadInt32();

            Slot = AnimationSlotTypeHelper.GetFromId(_slot);

            AnimationFile     = data.ReadString();
            MetaDataFile      = data.ReadString();
            SoundMetaDataFile = data.ReadString();
            Skeleton          = data.ReadString();
            Blend             = data.ReadSingle();
            Weight            = data.ReadSingle();
            Unknown0          = data.ReadInt32();
            Unknown1          = data.ReadInt32();
            Unknown3          = data.ReadString();
            Unknown4          = data.ReadBool();
        }
コード例 #3
0
        static Frame ReadFrame(ByteChunk chunk, uint positions, uint rotations)
        {
            var frame = new Frame();

            for (int j = 0; j < positions; j++)
            {
                var vector = new RmvVector3(chunk.ReadSingle(), chunk.ReadSingle(), chunk.ReadSingle());
                frame.Transforms.Add(vector);
            }

            for (int j = 0; j < rotations; j++)
            {
                var maxValue = 1.0f / (float)short.MaxValue;
                var quat     = new short[4] {
                    chunk.ReadShort(), chunk.ReadShort(), chunk.ReadShort(), chunk.ReadShort()
                };

                var quaternion = new RmvVector4(quat[0] * maxValue, quat[1] * maxValue, quat[2] * maxValue, quat[3] * maxValue);
                frame.Quaternion.Add(quaternion);
            }
            return(frame);
        }