From c9bfbf84244c8aa4e26ece994ef6b93386c708e3 Mon Sep 17 00:00:00 2001 From: Treeki Date: Sun, 23 Sep 2012 17:43:33 +0200 Subject: tons of junk I'll clean up eventually --- NW4RTools/ObjImporter.cs | 53 ++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 26 deletions(-) (limited to 'NW4RTools/ObjImporter.cs') diff --git a/NW4RTools/ObjImporter.cs b/NW4RTools/ObjImporter.cs index 384fb66..cdc9fcd 100755 --- a/NW4RTools/ObjImporter.cs +++ b/NW4RTools/ObjImporter.cs @@ -2,6 +2,7 @@ using System; using System.IO; using System.Collections; using System.Collections.Generic; +using System.Globalization; using NW4RTools.Models; namespace NW4RTools { @@ -271,7 +272,7 @@ namespace NW4RTools { var output = new float[count]; for (int i = 0; i < count; i++) { - output[i] = float.Parse(src[i + index]); + output[i] = float.Parse(src[i + index], CultureInfo.InvariantCulture); } return output; @@ -293,13 +294,13 @@ namespace NW4RTools { if (line.Length == 0 || line[0] == '#') continue; - var parsed = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); - - switch (parsed[0]) { - case "newmtl": - // Create a new material and initialise everything - // Default settings taken from Test_Lift material - currentMaterial = new Material(); + var parsed = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + + switch (parsed[0]) { + case "newmtl": + // Create a new material and initialise everything + // Default settings taken from Test_Lift material + currentMaterial = new Material(); currentMaterial.ChanCtrls[0] = new ChanCtrl(); currentMaterial.ChanCtrls[0].Flags = 0x3F; @@ -315,20 +316,20 @@ namespace NW4RTools { currentMaterial.ChanCtrls[1].FlagC = 0; currentMaterial.ChanCtrls[1].FlagA = 0; - if (Lightmap == ObjImporter.LightmapType.None) { - currentMaterial.TexCoordGenCount = 1; - currentMaterial.ChanCount = 1; - currentMaterial.TevStageCount = 2; - currentMaterial.IndStageCount = 0; - - // This might need changing - currentMaterial.CullMode = 2; + if (Lightmap == ObjImporter.LightmapType.None) { + currentMaterial.TexCoordGenCount = 1; + currentMaterial.ChanCount = 1; + currentMaterial.TevStageCount = 2; + currentMaterial.IndStageCount = 0; + + // This might need changing + currentMaterial.CullMode = 2; currentMaterial.LightSetID = 1; - currentMaterial.SRTSettings[0] = new SRTSettingInfo(); - - // Default display lists, taken from test_lift + currentMaterial.SRTSettings[0] = new SRTSettingInfo(); + + // Default display lists, taken from test_lift var pixDL = new DisplayListWriter(); pixDL.LoadBPReg(0xF31EFF80); pixDL.LoadBPReg(0x40000017); @@ -469,10 +470,10 @@ namespace NW4RTools { Shader thisShader = CreateShader(); CurrentModel.Shaders.Add(parsed[1], thisShader); - currentMaterial.ShaderRef = thisShader; - - break; - + currentMaterial.ShaderRef = thisShader; + + break; + case "map_Kd": var rawTexName = string.Join(" ", parsed, 1, parsed.Length - 1); // TODO: fix this to use the mtllib path @@ -512,9 +513,9 @@ namespace NW4RTools { currentMaterial.TextureInfos.Add(lm01); currentMaterial.TextureInfos.Add(lm02); } - - break; - + + break; + } } -- cgit v1.2.3