private void WriteBone(Bone bone, BCFWriteProxy io, bool bcf) { if (!bcf) { io.WriteInt32(bone.Unknown); } io.WritePascalString(bone.Name); io.WritePascalString(bone.ParentName); if (!bcf) { io.WriteByte(1); //has props } io.WriteInt32(bone.Properties.Count); foreach (var property in bone.Properties) { io.WriteInt32(property.KeyPairs.Count); foreach (var pair in property.KeyPairs) { io.WritePascalString(pair.Key); io.WritePascalString(pair.Value); } } io.SetGrouping(3); io.WriteFloat(-bone.Translation.X); io.WriteFloat(bone.Translation.Y); io.WriteFloat(bone.Translation.Z); io.SetGrouping(4); io.WriteFloat(bone.Rotation.X); io.WriteFloat(-bone.Rotation.Y); io.WriteFloat(-bone.Rotation.Z); io.WriteFloat(-bone.Rotation.W); io.SetGrouping(1); io.WriteInt32(bone.CanTranslate); io.WriteInt32(bone.CanRotate); io.WriteInt32(bone.CanBlend); io.WriteFloat(bone.WiggleValue); io.WriteFloat(bone.WigglePower); }
public void Write(BCFWriteProxy io, bool bcf) { if (bcf) { io.WritePascalString(Name); io.WritePascalString(XSkillName); } else { io.WriteUInt32(2); io.WriteLongPascalString(Name); } io.WriteFloat(Duration); io.WriteFloat(Distance); if (bcf) { io.WriteInt32(IsMoving); } else { io.WriteByte(IsMoving); } io.WriteUInt32(TranslationCount); io.SetGrouping(3); if (!bcf) { for (var i = 0; i < TranslationCount; i++) { var trans = Translations[i]; io.WriteFloat(-trans.X); io.WriteFloat(trans.Y); io.WriteFloat(trans.Z); } } io.SetGrouping(1); io.WriteUInt32(RotationCount); io.SetGrouping(4); if (!bcf) { for (var i = 0; i < RotationCount; i++) { var rot = Rotations[i]; io.WriteFloat(rot.X); io.WriteFloat(-rot.Y); io.WriteFloat(-rot.Z); io.WriteFloat(-rot.W); } } io.SetGrouping(1); io.WriteUInt32((uint)Motions.Length); foreach (var motion in Motions) { if (!bcf) { io.WriteUInt32(0); //unknown } io.WritePascalString(motion.BoneName); io.WriteUInt32(motion.FrameCount); io.WriteFloat(motion.Duration); if (bcf) { io.WriteInt32(motion.HasTranslation ? 1 : 0); io.WriteInt32(motion.HasRotation ? 1 : 0); } else { io.WriteByte((byte)(motion.HasTranslation ? 1 : 0)); io.WriteByte((byte)(motion.HasRotation ? 1 : 0)); } io.WriteUInt32(motion.FirstTranslationIndex); io.WriteUInt32(motion.FirstRotationIndex); if (!bcf) { io.WriteByte(1); //has props } //write props list var props = motion.Properties; io.WriteUInt32((uint)props.Length); foreach (var prop in props) { //write property list WritePropertyList(prop, io, bcf); } if (!bcf) { io.WriteByte(1); //has time props } //write time props list var timePropsList = motion.TimeProperties; io.WriteUInt32((uint)timePropsList.Length); foreach (var list in timePropsList) { io.WriteUInt32((uint)list.Items.Length); foreach (var item in list.Items) { io.WriteInt32(item.ID); WritePropertyList(item.Properties, io, bcf); } } } }