using System; using System.IO; using System.Collections.Generic; using NW4RTools; using OpenTK; using OpenTK.Graphics; using OpenTK.Graphics.OpenGL; namespace TestApp { class MainClass { public static void Main(string[] args) { string mdlPath = "/home/me/Games/Newer/ModelRev/"; //skawo(); //oldBehaviour(); //return; // Going to create a model! //string filename = "crapmap", resmdlname = "CrapMap"; string filename = "GoldwoodBase", resmdlname = "GoldwoodBase"; ResFile rf = new ResFile(); ObjImporter.ImportModel(mdlPath, File.OpenText(mdlPath + filename + ".obj"), rf, resmdlname); File.WriteAllBytes(mdlPath + filename + ".brres", BrresWriter.WriteFile(rf)); ResFile rf2 = BrresReader.LoadFile(File.ReadAllBytes(mdlPath + filename + ".brres")); using (var gw = new RenderWindow()) { gw.Title = filename; gw.SetModel(rf2, resmdlname); gw.Run(1, 1); } /*var texs = rf.GetGroup("Textures(NW4R)"); // wtf C#?! foreach (var kv in (IEnumerable>)texs) { kv.Value.BaseImage.Save(mdlPath + "images/" + kv.Key + ".png"); } //var objFile = File.Open(mdlPath + mdlName + ".obj", FileMode.OpenOrCreate); var objFile = File.Open(mdlPath + mdlName + ".dae", FileMode.OpenOrCreate); //var sw = new StreamWriter(objFile); //ObjWriter.WriteModel(sw, rf, mdlName); ColladaWriter.WriteModel(objFile, rf, mdlName + whatever); objFile.Close();*/ } private static void skawo() { string mdlPath = "/home/me/Games/Newer/ModelRev/"; string skawopath = "/home/me/Dropbox/NEWERsmbw/Nowy folder/obj/"; ResFile rf = new ResFile(); ObjImporter.ImportModel(skawopath, File.OpenText(skawopath + "edited.obj"), rf, "Skawo"); File.WriteAllBytes(skawopath + "skawo.brres", BrresWriter.WriteFile(rf)); ResFile rf2 = BrresReader.LoadFile(File.ReadAllBytes(skawopath + "skawo.brres")); using (var gw = new RenderWindow()) { gw.Title = "Skawo"; gw.SetModel(rf2, "Skawo"); gw.Run(1, 1); } } private static void oldBehaviour() { string mdlPath = "/home/me/Games/Newer/ModelRev/"; string mdlName = "CS_W1"; //string mdlName = "bgB_4502"; //string mdlName = "cobKoopaCastle"; //string mdlName = "waterPlate_W4boss"; //mdlName = "test_lift"; string whatever = (mdlName == "CS_W2" || mdlName == "CS_W3" || mdlName == "CS_W6") ? "a" : ""; byte[] file = File.ReadAllBytes(mdlPath + mdlName + ".brres"); ResFile rf = BrresReader.LoadFile(file); using (var gw = new RenderWindow()) { gw.Title = mdlName; gw.SetModel(rf, mdlName); gw.Run(1, 1); } //File.WriteAllBytes(mdlPath + mdlName + "_rewritten.brres", BrresWriter.WriteFile(rf)); } } }