private static void ReplaceF1Test() { var modelPack = new ModelPack(); var model = new Model(); model.Nodes.Add(new Node { Name = "model" }); modelPack.Models.Add(model); modelPack.Replace("f1test.fbx"); var lb = new LBFileSystem(); lb.Load(@"D:\Modding\DDS3\Nocturne\_HostRoot\dds3data\fld\f\f037\_f037_027.LB"); var f1Handle = lb.GetHandle("F1"); FieldScene f1; using (var stream = lb.OpenFile(f1Handle)) f1 = new FieldScene(stream, true); f1.Objects.RemoveAll(x => x.ResourceType == FieldObjectResourceType.Model); f1.Objects.Clear(); f1.Objects.Add(new FieldObject() { Id = 0, Name = "model", Transform = new FieldObjectTransform(), Resource = modelPack.Models[0] }); ExportObj(f1); lb.AddFile(f1Handle, f1.Save(), true, ConflictPolicy.Replace); if (modelPack.TexturePack != null) { var tbHandle = lb.GetHandle("TBN"); lb.AddFile(tbHandle, modelPack.TexturePack.Save(), true, ConflictPolicy.Replace); } lb.Save(@"D:\Modding\DDS3\Nocturne\_HostRoot\dds3data\fld\f\f037\f037_027.LB"); }
private static void ConvertAssimpModel() { switch (Options.OutputFormat) { case OutputFormat.PB: { if (Options.PackedModel.ReplaceInput == null) { throw new Exception("You must specify a PB replacement input for conversion to PB"); } var modelPack = new ModelPack(); if (Options.PackedModel.ReplaceInput != null) { modelPack.Load(Options.PackedModel.ReplaceInput); } if (!Options.Assimp.TreatInputAsAnimation) { modelPack.Replace(Options.Input, Options.TmxScale, Options.Model.EnableMaterialOverlays, Options.Model.WeightedMeshType, Options.Model.UnweightedMeshType, Options.Model.MeshWeightLimit, Options.Model.BatchVertexLimit); } else { var newMotion = AssimpMotionImporter.Instance.Import(Options.Input, new AssimpMotionImporter.Config { NodeIndexResolver = n => modelPack.Models[Options.PackedModel.ReplaceMotionModelIndex].Nodes.FindIndex(x => x.Name == n) }); if (Options.PackedModel.ReplaceMotionIndex < 0 || (Options.PackedModel.ReplaceMotionIndex + 1) > modelPack.MotionPacks[Options.PackedModel.ReplaceMotionPackIndex].Motions.Count) { modelPack.MotionPacks[Options.PackedModel.ReplaceMotionPackIndex].Motions[Options.PackedModel.ReplaceMotionIndex] = newMotion; } } modelPack.Save(Options.Output); } break; case OutputFormat.F1: { var modelPack = new ModelPack(); var model = new Model(); model.Nodes.Add(new Node { Name = "model" }); modelPack.Models.Add(model); modelPack.Replace(Options.Input, Options.TmxScale, Options.Model.EnableMaterialOverlays, Options.Model.WeightedMeshType, Options.Model.UnweightedMeshType, Options.Model.MeshWeightLimit, Options.Model.BatchVertexLimit); var lb = new LBFileSystem(); lb.Load(Options.Field.LbReplaceInput); var f1Handle = lb.GetHandle("F1"); FieldScene f1; using (var stream = lb.OpenFile(f1Handle)) f1 = new FieldScene(stream, true); f1.Objects.RemoveAll(x => x.ResourceType == FieldObjectResourceType.Model); f1.Objects.Clear(); f1.Objects.Add(new FieldObject() { Id = 0, Name = "model", Transform = new FieldObjectTransform(), Resource = modelPack.Models[0] }); lb.AddFile(f1Handle, f1.Save(), true, ConflictPolicy.Replace); if (modelPack.TexturePack != null) { var tbHandle = lb.GetHandle("TBN"); lb.AddFile(tbHandle, modelPack.TexturePack.Save(), true, ConflictPolicy.Replace); } lb.Save(Options.Output); } break; default: throw new Exception("Unsupported output format"); } }