示例#1
0
        public void ReadBCF(BCFReadProxy io)
        {
            Name = io.ReadPascalString();
            var type = io.ReadInt32();
            var zero = io.ReadInt32();

            var numBindings = io.ReadUInt32();

            Bindings = new AppearanceBinding[numBindings];

            for (var i = 0; i < numBindings; i++)
            {
                //bindings are included verbatim here.
                var bnd = new Binding();
                bnd.Bone     = io.ReadPascalString();
                bnd.MeshName = io.ReadPascalString();
                io.ReadInt32();
                io.ReadInt32();

                Bindings[i] = new AppearanceBinding
                {
                    RealBinding = bnd
                };
            }
        }
示例#2
0
        /// <summary>
        /// Reads a skeleton from a stream.
        /// </summary>
        /// <param name="stream">A Stream instance holding a skeleton.</param>
        public void Read(BCFReadProxy io, bool bcf)
        {
            if (!bcf)
            {
                var version = io.ReadUInt32();
            }
            Name = io.ReadPascalString();

            var boneCount = io.ReadInt16();

            Bones = new Bone[boneCount];
            for (var i = 0; i < boneCount; i++)
            {
                Bone bone = ReadBone(io, bcf);
                if (bone == null)
                {
                    i--;
                    continue;
                }
                bone.Index = i;
                Bones[i]   = bone;
            }

            /** Construct tree **/
            foreach (var bone in Bones)
            {
                bone.Children = Bones.Where(x => x.ParentName == bone.Name).ToArray();
            }
            RootBone = Bones.FirstOrDefault(x => x.ParentName == "NULL");
            ComputeBonePositions(RootBone, Matrix.Identity);
        }
示例#3
0
        /// <summary>
        /// Reads a property list from a stream.
        /// </summary>
        /// <param name="io">IOBuffer instance used to read an animation.</param>
        /// <returns>A PropertyList instance.</returns>
        private PropertyList ReadPropertyList(BCFReadProxy io, bool shortPairs)
        {
            var propsCount = (shortPairs) ? 1 : io.ReadUInt32();
            var result     = new PropertyListItem[propsCount];

            for (var y = 0; y < propsCount; y++)
            {
                var item       = new PropertyListItem();
                var pairsCount = io.ReadUInt32();
                for (var z = 0; z < pairsCount; z++)
                {
                    item.KeyPairs.Add(new KeyValuePair <string, string>(
                                          io.ReadPascalString(),
                                          io.ReadPascalString()
                                          ));
                }
                result[y] = item;
            }

            return(new PropertyList {
                Items = result
            });
        }
示例#4
0
        /// <summary>
        /// Reads an animation from a stream.
        /// </summary>
        /// <param name="stream">The Stream instance to read from.</param>
        public void Read(BCFReadProxy io, bool bcf)
        {
            if (!bcf)
            {
                var version = io.ReadUInt32();
            }

            if (bcf)
            {
                Name       = io.ReadPascalString();
                XSkillName = io.ReadPascalString();
            }
            else
            {
                Name = io.ReadLongPascalString();
            }
            Duration = io.ReadFloat();
            Distance = io.ReadFloat();
            IsMoving = (bcf)?((byte)io.ReadInt32()):io.ReadByte();

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

            RotationCount = io.ReadUInt32();
            if (!bcf)
            {
                Rotations = new Quaternion[RotationCount];
                for (var i = 0; i < RotationCount; i++)
                {
                    Rotations[i] = new Quaternion
                    {
                        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();
                if (!bcf)
                {
                    var unknown = io.ReadUInt32();
                }
                motion.BoneName              = io.ReadPascalString();
                motion.FrameCount            = io.ReadUInt32();
                motion.Duration              = io.ReadFloat();
                motion.HasTranslation        = (((bcf) ? io.ReadInt32() : io.ReadByte()) == 1);
                motion.HasRotation           = (((bcf) ? io.ReadInt32() : io.ReadByte()) == 1);
                motion.FirstTranslationIndex = io.ReadUInt32();
                motion.FirstRotationIndex    = io.ReadUInt32();

                var hasPropsList = bcf || 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, bcf);
                    }
                    motion.Properties = props;
                }

                var hasTimeProps = bcf || 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, bcf)
                            };
                        }
                        timePropsList[x] = list;
                    }
                    motion.TimeProperties = timePropsList;
                }

                Motions[i] = motion;
            }
        }