public override void Serialize(WritableSection section) { WriteVector3(section, Position); WriteInfluences(section, BoneWeights); WriteInfluences(section, BoneIndices); WriteVector2(section, TextureCoordinates0); }
public override void Serialize(WritableSection section) { WriteVector3(section, Position); WriteVector3(section, Normal); WriteVector3(section, Tangent); WriteVector2(section, TextureCoordinates0); }
public override void Serialize(WritableSection section) { WriteVector3(section, Position); WriteInfluences(section, BoneWeights); WriteInfluences(section, BoneIndices); WriteVector3(section, Normal); WriteVector3(section, Tangent); }
public void Write(GR2Writer writer, WritableSection section, MemberDefinition member, object obj) { var items = obj as List <UInt16>; for (int i = 0; i < items.Count; i++) { section.Writer.Write(items[i]); } }
internal void WriteSectionRelocations(WritableSection section) { section.Header.numRelocations = (UInt32)section.Fixups.Count; section.Header.relocationsOffset = (UInt32)MainStream.Position; foreach (var fixup in section.Fixups) { Writer.Write(fixup.Key); WriteSectionReference(GR2.ObjectOffsets[fixup.Value]); } }
internal void WriteSectionMixedMarshallingRelocations(WritableSection section) { section.Header.numMixedMarshallingData = (UInt32)section.MixedMarshalling.Count; section.Header.mixedMarshallingDataOffset = (UInt32)MainStream.Position; foreach (var marshal in section.MixedMarshalling) { Writer.Write(marshal.Count); Writer.Write(GR2.ObjectOffsets[marshal.Obj].Offset); WriteSectionReference(GR2.ObjectOffsets[marshal.Type]); } }
protected void WriteHalfVector4(WritableSection section, Vector4 v) { section.Writer.Write(HalfHelpers.SingleToHalf(v.X)); section.Writer.Write(HalfHelpers.SingleToHalf(v.Y)); section.Writer.Write(HalfHelpers.SingleToHalf(v.Z)); section.Writer.Write(HalfHelpers.SingleToHalf(v.W)); }
public byte[] Write(object root) { using (this.Writer = new BinaryWriter(Stream)) { this.Magic = InitMagic(); WriteMagic(Magic); this.Header = InitHeader(); WriteHeader(Header); for (int i = 0; i < Header.numSections; i++) { var section = new WritableSection((SectionType)i, this); WriteSectionHeader(section.Header); Sections.Add(section); } Magic.headersSize = (UInt32)Stream.Position; CurrentSection = Sections[(int)SectionType.Main]; CurrentSection.WriteStruct(root); while (ArrayWrites.Count > 0 || StructWrites.Count > 0 || StringWrites.Count > 0) { FlushPendingWrites(); } foreach (var defn in Types.Values) { Sections[(int)SectionType.Discardable].WriteStructDefinition(defn); } // We need to do this again to flush strings written by WriteMemberDefinition() FlushPendingWrites(); FinalizeOffsets(); foreach (var section in Sections) { section.Header.first16bit = (UInt32)section.MainStream.Length; section.Header.first8bit = (UInt32)section.MainStream.Length; section.Finish(); } var relocSection = Sections[(int)SectionType.Discardable]; foreach (var section in Sections) { relocSection.WriteSectionRelocations(section); relocSection.WriteSectionMixedMarshallingRelocations(section); } foreach (var section in Sections) { // Pad section size to a multiple of 4 while (section.MainStream.Position % 4 > 0) section.Writer.Write((Byte)0); section.MainStream.Flush(); section.Header.offsetInFile = (UInt32)Stream.Position; section.Header.uncompressedSize = (UInt32)section.MainStream.Length; section.Header.compressedSize = (UInt32)section.MainStream.Length; Writer.Write(section.MainStream.ToArray()); } foreach (var section in Sections) { section.Header.relocationsOffset += relocSection.Header.offsetInFile; section.Header.mixedMarshallingDataOffset += relocSection.Header.offsetInFile; } var rootStruct = LookupStructDefinition(root.GetType()); Header.rootType = ObjectOffsets[rootStruct]; Header.rootNode = new SectionReference(SectionType.Main, 0); Header.fileSize = (UInt32)Stream.Length; Stream.Seek(Magic.MagicSize + Header.HeaderSize, SeekOrigin.Begin); foreach (var section in Sections) { WriteSectionHeader(section.Header); } Header.crc = Header.CalculateCRC(Stream); Stream.Seek(0, SeekOrigin.Begin); WriteMagic(Magic); WriteHeader(Header); return Stream.ToArray(); } }
public override void Serialize(WritableSection section) { WriteVector3(section, Position); }
public void Write(GR2Writer writer, WritableSection section, MemberDefinition member, object obj) { (obj as Vertex).Serialize(section); }
public abstract void Serialize(WritableSection section);
public void Write(GR2Writer writer, WritableSection section, MemberDefinition member, object obj) { var items = obj as List<UInt16>; for (int i = 0; i < items.Count; i++) section.Writer.Write(items[i]); }
protected void WriteVector4(WritableSection section, Vector4 v) { section.Writer.Write(v.X); section.Writer.Write(v.Y); section.Writer.Write(v.Z); section.Writer.Write(v.W); }
protected void WriteHalfVector3As4(WritableSection section, Vector3 v) { section.Writer.Write(HalfHelpers.SingleToHalf(v.X)); section.Writer.Write(HalfHelpers.SingleToHalf(v.Y)); section.Writer.Write(HalfHelpers.SingleToHalf(v.Z)); section.Writer.Write((ushort)0); }
protected void WriteVector2(WritableSection section, Vector2 v) { section.Writer.Write(v.X); section.Writer.Write(v.Y); }
public byte[] Write(object root) { using (this.Writer = new BinaryWriter(Stream)) { this.Magic = InitMagic(); WriteMagic(Magic); this.Header = InitHeader(); WriteHeader(Header); for (int i = 0; i < Header.numSections; i++) { var section = new WritableSection((SectionType)i, this); WriteSectionHeader(section.Header); Sections.Add(section); } Magic.headersSize = (UInt32)Stream.Position; CurrentSection = Sections[(int)SectionType.Main]; CurrentSection.WriteStruct(root); while (ArrayWrites.Count > 0 || StructWrites.Count > 0 || StringWrites.Count > 0) { FlushPendingWrites(); } foreach (var defn in Types.Values) { Sections[(int)SectionType.Discardable].WriteStructDefinition(defn); } // We need to do this again to flush strings written by WriteMemberDefinition() FlushPendingWrites(); FinalizeOffsets(); foreach (var section in Sections) { section.Header.first16bit = (UInt32)section.MainStream.Length; section.Header.first8bit = (UInt32)section.MainStream.Length; section.Finish(); } var relocSection = Sections[(int)SectionType.Discardable]; foreach (var section in Sections) { relocSection.WriteSectionRelocations(section); } foreach (var section in Sections) { relocSection.WriteSectionMixedMarshallingRelocations(section); } foreach (var section in Sections) { // Pad section size to a multiple of the section alignment while ((section.MainStream.Position % section.Header.alignment) > 0) { section.Writer.Write((Byte)0); } section.MainStream.Flush(); section.Header.offsetInFile = (UInt32)Stream.Position; section.Header.uncompressedSize = (UInt32)section.MainStream.Length; section.Header.compressedSize = (UInt32)section.MainStream.Length; Writer.Write(section.MainStream.ToArray()); } foreach (var section in Sections) { section.Header.relocationsOffset += relocSection.Header.offsetInFile; section.Header.mixedMarshallingDataOffset += relocSection.Header.offsetInFile; } var rootStruct = LookupStructDefinition(root.GetType(), root); Header.rootType = ObjectOffsets[rootStruct]; Header.rootNode = new SectionReference(SectionType.Main, 0); Header.fileSize = (UInt32)Stream.Length; Stream.Seek(Magic.MagicSize + Header.Size(), SeekOrigin.Begin); foreach (var section in Sections) { WriteSectionHeader(section.Header); } Header.crc = Header.CalculateCRC(Stream); Stream.Seek(0, SeekOrigin.Begin); WriteMagic(Magic); WriteHeader(Header); return(Stream.ToArray()); } }
protected void WriteInfluences(WritableSection section, BoneWeight v) { section.Writer.Write(v.A); section.Writer.Write(v.B); section.Writer.Write(v.C); section.Writer.Write(v.D); }
public override void Serialize(WritableSection section) { WriteVector3(section, Position); WriteVector3(section, Normal); WriteVector3(section, Tangent); }