public void Save(Stream output) { this.offSize.offset = (uint)output.Position; MadScience.StreamHelpers.WriteStringASCII(output, this.magic); MadScience.StreamHelpers.WriteValueU32(output, 0); MadScience.StreamHelpers.WriteValueU32(output, 0); // We'll come back here later... MadScience.StreamHelpers.WriteValueU32(output, (uint)entries.Count); int startTailOffset = 16 + (entries.Count * 16); int addOffset = 0; for (int i = 0; i < entries.Count; i++) { MadScience.StreamHelpers.WriteValueU32(output, entries[i].fieldTypeHash); MadScience.StreamHelpers.WriteValueU32(output, entries[i].dataType); MadScience.StreamHelpers.WriteValueU32(output, entries[i].dataCount); MadScience.StreamHelpers.WriteValueU32(output, (uint)(startTailOffset + addOffset)); Console.WriteLine(startTailOffset + addOffset); addOffset += (int)entries[i].dataCount * 4; } long followOffset = output.Position; for (int i = 0; i < entries.Count; i++) { switch (entries[i].dataType) { case 1: for (int j = 0; j < entries[i].dataCount; j++) { MadScience.StreamHelpers.WriteValueF32(output, entries[i].floats[j]); } break; case 2: case 4: for (int j = 0; j < entries[i].dataCount; j++) { MadScience.StreamHelpers.WriteValueU32(output, entries[i].dwords[j]); } break; } } this.offSize.size = (uint)output.Position - this.offSize.offset; long followSize = output.Position - followOffset; output.Seek(this.offSize.offset + 8, SeekOrigin.Begin); StreamHelpers.WriteValueU32(output, (uint)followSize); // Seek back to the end output.Seek(this.offSize.offset + this.offSize.size, SeekOrigin.Begin); }
public void Save(Stream output) { StreamHelpers.WriteValueU32(output, 1); StreamHelpers.WriteValueU32(output, (uint)this.entries.Count); foreach (var kvp in this.entries) { StreamHelpers.WriteValueU64(output, kvp.Key); StreamHelpers.WriteValueU32(output, (uint)kvp.Value.Length); StreamHelpers.WriteStringASCII(output, kvp.Value); } }
public void Save(Stream output) { long startOfChunk = output.Position; this.offsize.offset = (uint)startOfChunk; StreamHelpers.WriteStringASCII(output, this.magic); StreamHelpers.WriteValueU32(output, this.version); StreamHelpers.WriteValueU32(output, (uint)this.Routes.Count); StreamHelpers.WriteValueU32(output, (uint)this.Containers.Count); StreamHelpers.WriteValueU32(output, (uint)this.Effects.Count); StreamHelpers.WriteValueU32(output, (uint)this.IKTargets.Count); StreamHelpers.WriteValueU32(output, this.count5); for (int i = 0; i < this.Routes.Count; i++) { StreamHelpers.WriteValueU32(output, this.Routes[i].slotName); } for (int i = 0; i < this.Routes.Count; i++) { StreamHelpers.WriteValueU32(output, this.Routes[i].boneName); } for (int i = 0; i < this.Routes.Count; i++) { this.Routes[i].matrix.Save(output); } if (this.Routes.Count > 0) { StreamHelpers.WriteValueU32(output, 0); } // Containers for (int i = 0; i < this.Containers.Count; i++) { StreamHelpers.WriteValueU32(output, this.Containers[i].slotName); } for (int i = 0; i < this.Containers.Count; i++) { StreamHelpers.WriteValueU32(output, this.Containers[i].boneName); } for (int i = 0; i < this.Containers.Count; i++) { StreamHelpers.WriteValueU32(output, this.Containers[i].flags); } for (int i = 0; i < this.Containers.Count; i++) { this.Containers[i].matrix.Save(output); } if (this.Containers.Count > 0) { StreamHelpers.WriteValueU32(output, 0); } // Effects for (int i = 0; i < this.Effects.Count; i++) { StreamHelpers.WriteValueU32(output, this.Effects[i].slotName); } for (int i = 0; i < this.Effects.Count; i++) { StreamHelpers.WriteValueU32(output, this.Effects[i].boneName); } for (int i = 0; i < this.Effects.Count; i++) { this.Effects[i].matrix.Save(output); } if (this.Effects.Count > 0) { StreamHelpers.WriteValueU32(output, 0); } // IK Targets for (int i = 0; i < this.IKTargets.Count; i++) { StreamHelpers.WriteValueU32(output, this.IKTargets[i].slotName); } for (int i = 0; i < this.IKTargets.Count; i++) { StreamHelpers.WriteValueU32(output, this.IKTargets[i].boneName); } for (int i = 0; i < this.IKTargets.Count; i++) { this.IKTargets[i].matrix.Save(output); } if (this.IKTargets.Count > 0) { StreamHelpers.WriteValueU32(output, 0); } long chunkSize = output.Position - startOfChunk; this.offsize.size = (uint)chunkSize; }
public void Save(Stream output) { StreamHelpers.WriteValueU32(output, this.dataType); StreamHelpers.WriteValueU32(output, this.subType); StreamHelpers.WriteValueU8(output, this.bytesPerElement); }
public void Save(Stream output) { this.offSize.offset = (uint)output.Position; StreamHelpers.WriteStringASCII(output, this.magic); StreamHelpers.WriteValueU32(output, this.version); StreamHelpers.WriteValueU32(output, 0); StreamHelpers.WriteValueU32(output, 0); StreamHelpers.WriteValueU32(output, this.embeddedId); if (this.embeddedId != 0) { StreamHelpers.WriteValueU32(output, 0); this.mtnfChunk.Save(output); output.Seek(this.mtnfChunk.offSize.offset - 4, SeekOrigin.Begin); StreamHelpers.WriteValueU32(output, this.mtnfChunk.offSize.size); output.Seek(this.mtnfChunk.offSize.offset + this.mtnfChunk.offSize.size, SeekOrigin.Begin); } StreamHelpers.WriteValueU32(output, this.unk1); StreamHelpers.WriteValueU32(output, this.unk2); StreamHelpers.WriteValueU32(output, (uint)this.vertices.Count); StreamHelpers.WriteValueU32(output, (uint)this.vertexFormats.Count); for (int i = 0; i < this.vertexFormats.Count; i++) { this.vertexFormats[i].Save(output); } for (int i = 0; i < this.vertices.Count; i++) { for (int j = 0; j < this.vertexFormats.Count; j++) { SimGeomVertexFormat vf = this.vertexFormats[j]; switch (vf.dataType) { case 1: this.vertices[i].Save(output); break; case 2: this.normals[i].Save(output); break; case 3: this.uvs[i].Save(output); break; case 4: StreamHelpers.WriteValueU32(output, this.bones[i]); break; case 5: this.weights[i].Save(output); break; case 6: this.tangentNormals[i].Save(output); break; case 7: StreamHelpers.WriteValueU32(output, this.tagVals[i]); break; case 10: StreamHelpers.WriteValueU32(output, this.vertexIds[i]); break; } } } StreamHelpers.WriteValueU32(output, this.faceFormatItemCount); StreamHelpers.WriteValueU8(output, this.faceFormatBytesPerFacePoint); StreamHelpers.WriteValueU32(output, (uint)(this.faces.Count * 3)); for (int i = 0; i < this.faces.Count; i++) { switch (this.faceFormatBytesPerFacePoint) { case 2: this.faces[i].Save(output); break; } } StreamHelpers.WriteValueU32(output, this.flags); StreamHelpers.WriteValueU32(output, (uint)this.boneHashes.Count); for (int i = 0; i < this.boneHashes.Count; i++) { StreamHelpers.WriteValueU32(output, this.boneHashes[i]); } this.keytable.offset = (uint)(output.Position - this.offSize.offset) - 12; this.keytable.size = 0; this.keytable.Save(output); this.offSize.size = (uint)(output.Position - this.offSize.offset); output.Seek(this.offSize.offset + 8, SeekOrigin.Begin); StreamHelpers.WriteValueU32(output, this.keytable.offset); StreamHelpers.WriteValueU32(output, this.keytable.size); output.Seek(this.offSize.offset + this.offSize.size, SeekOrigin.Begin); }