public void WriteBCF(BCFWriteProxy io) { io.WritePascalString(Name); io.WriteInt32(Type); io.WriteInt32(Zero); io.WriteUInt32((uint)Bindings.Length); foreach (var binding in Bindings) { io.WritePascalString(binding.RealBinding.Bone); io.WritePascalString(binding.RealBinding.MeshName); io.WriteInt32(binding.RealBinding.CensorFlagBits); io.WriteInt32(binding.RealBinding.Zero); } }
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 bmf) { if (bmf) { io.WritePascalString(SkinName); io.WritePascalString(TextureName); } else { io.WriteInt32(2); //version } var boneNames = new HashSet <string>(BoneBindings.Select(x => x.BoneName)).ToList(); io.WriteInt32(boneNames.Count); foreach (var name in boneNames) { io.WritePascalString(name); } io.WriteInt32(NumPrimitives); foreach (var index in IndexBuffer) { io.WriteInt32(index); } io.WriteInt32(BoneBindings.Length); foreach (var binding in BoneBindings) { io.WriteInt32(boneNames.IndexOf(binding.BoneName)); io.WriteInt32(binding.FirstRealVertex); io.WriteInt32(binding.RealVertexCount); io.WriteInt32(binding.FirstBlendVertex); io.WriteInt32(binding.BlendVertexCount); } io.WriteInt32(VertexBuffer.Length); io.SetGrouping(2); foreach (var vert in VertexBuffer) { io.WriteFloat(vert.TextureCoordinate.X); io.WriteFloat(vert.TextureCoordinate.Y); } io.SetGrouping(1); /** Blend data **/ io.WriteInt32(BlendVerts.Length); foreach (var bv in BlendData) { var binary = true; if (binary) { io.WriteInt32((int)(bv.Weight * 0x8000)); io.WriteInt32(bv.OtherVertex); } else { io.WriteInt32(bv.OtherVertex); io.WriteInt32((int)(bv.Weight * 0x8000)); } } io.WriteInt32(VertexBuffer.Length); //realVertexCount2 io.SetGrouping(3); foreach (var vert in VertexBuffer) { io.WriteFloat(-vert.Position.X); io.WriteFloat(vert.Position.Y); io.WriteFloat(vert.Position.Z); io.WriteFloat(-vert.Normal.X); io.WriteFloat(vert.Normal.Y); io.WriteFloat(vert.Normal.Z); } var i = 0; foreach (var bv in BlendVerts) { io.WriteFloat(-bv.X); io.WriteFloat(bv.Y); io.WriteFloat(bv.Z); var norm = BlendNormals[i++]; io.WriteFloat(-norm.X); io.WriteFloat(norm.Y); io.WriteFloat(norm.Z); } io.SetGrouping(1); }
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); } } } }