コード例 #1
0
        public void Read(Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream))
            {
                var version = io.ReadUInt32();
                Name = io.ReadLongPascalString();
                Duration = io.ReadFloat();
                Distance = io.ReadFloat();
                IsMoving = io.ReadByte();

                var translationCount = io.ReadUInt32();
                Translations = new Vector3[translationCount];
                for (var i = 0; i < translationCount; i++){
                    Translations[i] = new Vector3 {
                        X = io.ReadFloat(),
                        Y = io.ReadFloat(),
                        Z = io.ReadFloat()
                    };
                }

                var rotationCount = io.ReadUInt32();
                Rotations = new Vector4[rotationCount];
                for (var i = 0; i < rotationCount; i++){
                    Rotations[i] = new Vector4 {
                        X = io.ReadFloat(),
                        Y = -io.ReadFloat(),
                        Z = -io.ReadFloat(),
                        W = io.ReadFloat()
                    };
                }

                var motionCount = io.ReadUInt32();
                Motions = new AnimationMotion[motionCount];
                for (var i = 0; i < motionCount; i++){
                    var motion = new AnimationMotion();
                    var unknown = io.ReadUInt32();
                    motion.BoneName = io.ReadPascalString();
                    motion.FrameCount = io.ReadUInt32();
                    motion.Duration = io.ReadFloat();
                    motion.HasTranslation = (io.ReadByte() == 1);
                    motion.HasRotation = (io.ReadByte() == 1);
                    motion.FirstTranslationIndex = io.ReadUInt32();
                    motion.FirstRotationIndex = io.ReadUInt32();

                    var hasPropsList = io.ReadByte() == 1;
                    if (hasPropsList)
                    {
                        var propListCount = io.ReadUInt32();
                        var props = new PropertyList[propListCount];
                        for (var x = 0; x < propListCount; x++){
                            props[x] = ReadPropertyList(io);
                        }
                        motion.Properties = props;
                    }

                    var hasTimeProps = io.ReadByte() == 1;
                    if (hasTimeProps)
                    {
                        var timePropsListCount = io.ReadUInt32();
                        var timePropsList = new TimePropertyList[timePropsListCount];

                        for (var x = 0; x < timePropsListCount; x++)
                        {
                            var list = new TimePropertyList();
                            var timePropsCount = io.ReadUInt32();
                            list.Items = new TimePropertyListItem[timePropsCount];
                            for (var y = 0; y < timePropsCount; y++)
                            {
                                var id = io.ReadUInt32();
                                list.Items[y] = new TimePropertyListItem {
                                    ID = id,
                                    Properties = ReadPropertyList(io)
                                };
                            }
                            timePropsList[x] = list;
                        }
                        motion.TimeProperties = timePropsList;
                    }

                    Motions[i] = motion;
                }
            }
        }
コード例 #2
0
        public void Read(Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream))
            {
                var version = io.ReadUInt32();
                Name     = io.ReadLongPascalString();
                Duration = io.ReadFloat();
                Distance = io.ReadFloat();
                IsMoving = io.ReadByte();

                var translationCount = io.ReadUInt32();
                Translations = new Vector3[translationCount];
                for (var i = 0; i < translationCount; i++)
                {
                    Translations[i] = new Vector3 {
                        X = io.ReadFloat(),
                        Y = io.ReadFloat(),
                        Z = io.ReadFloat()
                    };
                }

                var rotationCount = io.ReadUInt32();
                Rotations = new Vector4[rotationCount];
                for (var i = 0; i < rotationCount; i++)
                {
                    Rotations[i] = new Vector4 {
                        X = io.ReadFloat(),
                        Y = -io.ReadFloat(),
                        Z = -io.ReadFloat(),
                        W = io.ReadFloat()
                    };
                }

                var motionCount = io.ReadUInt32();
                Motions = new AnimationMotion[motionCount];
                for (var i = 0; i < motionCount; i++)
                {
                    var motion  = new AnimationMotion();
                    var unknown = io.ReadUInt32();
                    motion.BoneName              = io.ReadPascalString();
                    motion.FrameCount            = io.ReadUInt32();
                    motion.Duration              = io.ReadFloat();
                    motion.HasTranslation        = (io.ReadByte() == 1);
                    motion.HasRotation           = (io.ReadByte() == 1);
                    motion.FirstTranslationIndex = io.ReadUInt32();
                    motion.FirstRotationIndex    = io.ReadUInt32();

                    var hasPropsList = io.ReadByte() == 1;
                    if (hasPropsList)
                    {
                        var propListCount = io.ReadUInt32();
                        var props         = new PropertyList[propListCount];
                        for (var x = 0; x < propListCount; x++)
                        {
                            props[x] = ReadPropertyList(io);
                        }
                        motion.Properties = props;
                    }

                    var hasTimeProps = io.ReadByte() == 1;
                    if (hasTimeProps)
                    {
                        var timePropsListCount = io.ReadUInt32();
                        var timePropsList      = new TimePropertyList[timePropsListCount];

                        for (var x = 0; x < timePropsListCount; x++)
                        {
                            var list           = new TimePropertyList();
                            var timePropsCount = io.ReadUInt32();
                            list.Items = new TimePropertyListItem[timePropsCount];
                            for (var y = 0; y < timePropsCount; y++)
                            {
                                var id = io.ReadUInt32();
                                list.Items[y] = new TimePropertyListItem {
                                    ID         = id,
                                    Properties = ReadPropertyList(io)
                                };
                            }
                            timePropsList[x] = list;
                        }
                        motion.TimeProperties = timePropsList;
                    }

                    Motions[i] = motion;
                }
            }
        }