public DDSPack(string inputFileName, Stream output) { using (var src = File.OpenRead(inputFileName)) { var model = new RW4Model(); model.New(); pack(src, model); model.Write(output); } }
public ModelPack(string inputFileName, Stream output) { var src_model = new OgreXmlReader(inputFileName); var model = new RW4Model(); model.New(); pack(src_model, model); model.Write(output); }
private void SaveRW4Model(DatabaseIndex index, RW4Model model) { //Save the new thing to a stream! ModifiedRW4File modifiedData = new ModifiedRW4File(); foreach (RW4Section section in model.Sections) { if (section.TypeCode == SectionTypeCodes.Texture) { SporeMaster.RenderWare4.Texture tex = section.obj as SporeMaster.RenderWare4.Texture; model.Sections[(int)tex.texData.section.Number].obj = tex.texData; } } RW4Section meshSection = model.Sections.Find(s => s.TypeCode == SectionTypeCodes.Mesh); if (meshSection != null) { SporeMaster.RenderWare4.RW4Mesh mesh = meshSection.obj as SporeMaster.RenderWare4.RW4Mesh; model.Sections[(int)mesh.vertices.section.Number].obj = mesh.vertices; model.Sections[(int)mesh.triangles.section.Number].obj = mesh.triangles; model.Sections[(int)mesh.vertices.vertices.section.Number].obj = mesh.vertices.vertices.section.obj; model.Sections[(int)mesh.triangles.triangles.section.Number].obj = mesh.triangles.triangles.section.obj; } //save back the model using (MemoryStream writer = new MemoryStream()) { model.Write(writer); modifiedData.RW4FileData = writer.ToArray(); index.ModifiedData = modifiedData; index.IsModified = true; index.Compressed = false; } }