summaryrefslogtreecommitdiff
path: root/TestApp/Main.cs
blob: a5db889c601e1819de3e9f19cea0bb9805f959ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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/";

			/*//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);

			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");

			File.WriteAllBytes(mdlPath + "crapmap.brres", BrresWriter.WriteFile(rf));


			ResFile rf2 = BrresReader.LoadFile(File.ReadAllBytes(mdlPath + "crapmap.brres"));
			using (var gw = new RenderWindow()) {
				gw.Title = "crapmap";
				gw.SetModel(rf2, "CrapMap");
				gw.Run(1, 1);
			}

			/*using (var gw = new RenderWindow()) {
				gw.Title = mdlName;
				gw.SetModel(rf, mdlName);
				gw.Run(1, 1);
			}*/



			/*var texs = rf.GetGroup<Texture>("Textures(NW4R)");
			// wtf C#?!
			foreach (var kv in (IEnumerable<KeyValuePair<string,Texture>>)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();*/
		}
	}
}