From 7d391e33a0b3d9793c95fce832abb2c6d9002186 Mon Sep 17 00:00:00 2001 From: Treeki Date: Tue, 8 Mar 2011 05:17:56 +0100 Subject: late night commit! obj importer is basic but working. also, tidied up DL stuff --- TestApp/Main.cs | 73 ++++++++++++++++++++++++++---------- TestApp/RenderWindow.cs | 20 +++++++++- TestApp/TestApp.pidb | Bin 4240 -> 4427 bytes TestApp/bin/Debug/NW4RTools.dll | Bin 232960 -> 233472 bytes TestApp/bin/Debug/NW4RTools.dll.mdb | Bin 112922 -> 112974 bytes TestApp/bin/Debug/TestApp.exe | Bin 5632 -> 7168 bytes TestApp/bin/Debug/TestApp.exe.mdb | Bin 979 -> 1243 bytes 7 files changed, 71 insertions(+), 22 deletions(-) (limited to 'TestApp') diff --git a/TestApp/Main.cs b/TestApp/Main.cs index a5db889..fbaa7dc 100644 --- a/TestApp/Main.cs +++ b/TestApp/Main.cs @@ -11,39 +11,30 @@ namespace TestApp { public static void Main(string[] args) { 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"; + //skawo(); + //oldBehaviour(); + //return; - string whatever = (mdlName == "CS_W2" || mdlName == "CS_W3" || mdlName == "CS_W6") ? "a" : ""; - byte[] file = File.ReadAllBytes(mdlPath + mdlName + ".brres"); - ResFile rf = BrresReader.LoadFile(file); + // Going to create a model! + //string filename = "crapmap", resmdlname = "CrapMap"; + string filename = "GoldwoodBase", resmdlname = "GoldwoodBase"; - File.WriteAllBytes(mdlPath + mdlName + "_rewritten.brres", BrresWriter.WriteFile(rf));*/ - // Going to create a model! ResFile rf = new ResFile(); - ObjImporter.ImportModel(mdlPath, File.OpenText(mdlPath + "crapmap.obj"), rf, "CrapMap"); + ObjImporter.ImportModel(mdlPath, File.OpenText(mdlPath + filename + ".obj"), rf, resmdlname); - File.WriteAllBytes(mdlPath + "crapmap.brres", BrresWriter.WriteFile(rf)); + File.WriteAllBytes(mdlPath + filename + ".brres", BrresWriter.WriteFile(rf)); - ResFile rf2 = BrresReader.LoadFile(File.ReadAllBytes(mdlPath + "crapmap.brres")); + ResFile rf2 = BrresReader.LoadFile(File.ReadAllBytes(mdlPath + filename + ".brres")); using (var gw = new RenderWindow()) { - gw.Title = "crapmap"; - gw.SetModel(rf2, "CrapMap"); + gw.Title = filename; + gw.SetModel(rf2, resmdlname); gw.Run(1, 1); } - /*using (var gw = new RenderWindow()) { - gw.Title = mdlName; - gw.SetModel(rf, mdlName); - gw.Run(1, 1); - }*/ @@ -60,6 +51,48 @@ namespace TestApp { 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)); + + } } } diff --git a/TestApp/RenderWindow.cs b/TestApp/RenderWindow.cs index 2f29d0f..6013724 100644 --- a/TestApp/RenderWindow.cs +++ b/TestApp/RenderWindow.cs @@ -27,6 +27,22 @@ namespace TestApp { GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); + GL.Disable(EnableCap.CullFace); + + GL.Enable(EnableCap.Lighting); + + GL.ShadeModel(ShadingModel.Smooth); + + GL.Light(LightName.Light0, LightParameter.Position, new Vector4(0, 500, 1000, 0)); + GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Specular, new Color4(1, 1, 1, 1)); + GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Shininess, 50); + GL.Enable(EnableCap.Light0); + + GL.Light(LightName.Light1, LightParameter.Position, new Vector4(1000, 500, 0, 0)); + GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Specular, new Color4(1, 1, 1, 1)); + GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Shininess, 50); + GL.Enable(EnableCap.Light1); + m_glModel.Prepare(Context); } @@ -45,8 +61,8 @@ namespace TestApp { GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); - //Matrix4 modelview = Matrix4.LookAt(new Vector3(1000, 600, 1000), new Vector3(1000, 0, 0), Vector3.UnitY); - Matrix4 modelview = Matrix4.LookAt(new Vector3(0, 2, 4), new Vector3(0, 0, 0), Vector3.UnitY); + Matrix4 modelview = Matrix4.LookAt(new Vector3(1000, 400, 1000), new Vector3(1000, 0, 0), Vector3.UnitY); + //Matrix4 modelview = Matrix4.LookAt(new Vector3(-3, 2, 3), new Vector3(0, 0, 0), Vector3.UnitY); GL.MatrixMode(MatrixMode.Modelview); GL.LoadMatrix(ref modelview); diff --git a/TestApp/TestApp.pidb b/TestApp/TestApp.pidb index bbc694a..e8df7af 100644 Binary files a/TestApp/TestApp.pidb and b/TestApp/TestApp.pidb differ diff --git a/TestApp/bin/Debug/NW4RTools.dll b/TestApp/bin/Debug/NW4RTools.dll index e4c2ea1..40356de 100755 Binary files a/TestApp/bin/Debug/NW4RTools.dll and b/TestApp/bin/Debug/NW4RTools.dll differ diff --git a/TestApp/bin/Debug/NW4RTools.dll.mdb b/TestApp/bin/Debug/NW4RTools.dll.mdb index 62014b8..92742d0 100644 Binary files a/TestApp/bin/Debug/NW4RTools.dll.mdb and b/TestApp/bin/Debug/NW4RTools.dll.mdb differ diff --git a/TestApp/bin/Debug/TestApp.exe b/TestApp/bin/Debug/TestApp.exe index a5251b0..5b808e0 100755 Binary files a/TestApp/bin/Debug/TestApp.exe and b/TestApp/bin/Debug/TestApp.exe differ diff --git a/TestApp/bin/Debug/TestApp.exe.mdb b/TestApp/bin/Debug/TestApp.exe.mdb index 7508ce0..8ec2779 100644 Binary files a/TestApp/bin/Debug/TestApp.exe.mdb and b/TestApp/bin/Debug/TestApp.exe.mdb differ -- cgit v1.2.3