diff options
author | Treeki <treeki@gmail.com> | 2011-03-26 05:14:59 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2011-03-26 05:14:59 +0100 |
commit | cff0bbcdf339ec99b9a1311605fb16f6378b3fb4 (patch) | |
tree | e921928236eef23869ddf4d27faa01f14e457594 /NW4RTools | |
parent | e00b60edda34f50baaa0a21cf2bae4fcad1609a4 (diff) | |
download | nw4rtools-cff0bbcdf339ec99b9a1311605fb16f6378b3fb4.tar.gz nw4rtools-cff0bbcdf339ec99b9a1311605fb16f6378b3fb4.zip |
the Wii killing bug is hopefully gone for good! also, a few other improvements
Diffstat (limited to 'NW4RTools')
-rw-r--r-- | NW4RTools/BrresReader.cs | 14 | ||||
-rwxr-xr-x | NW4RTools/ObjImporter.cs | 39 |
2 files changed, 39 insertions, 14 deletions
diff --git a/NW4RTools/BrresReader.cs b/NW4RTools/BrresReader.cs index aa54437..8b9fcb1 100644 --- a/NW4RTools/BrresReader.cs +++ b/NW4RTools/BrresReader.cs @@ -10,10 +10,18 @@ namespace NW4RTools { return LoadFile(data, true); } + public static ResFile LoadFile(byte[] data, out SortedDictionary<int, string> offsetMap) { + return LoadFile(data, true, out offsetMap); + } + public static ResFile LoadFile(byte[] data, bool debug) { return new BrresReader(debug).Load(new InputStream(data, ByteEndian.BigEndian)); } + public static ResFile LoadFile(byte[] data, bool debug, out SortedDictionary<int, string> offsetMap) { + return new BrresReader(debug).Load(new InputStream(data, ByteEndian.BigEndian), out offsetMap); + } + private class RawStreamResDict : ResDict<InputStream> { @@ -35,6 +43,11 @@ namespace NW4RTools { } public ResFile Load(InputStream ins) { + SortedDictionary<int, string> trashThis; + return Load(ins, out trashThis); + } + + public ResFile Load(InputStream ins, out SortedDictionary<int, string> offsetMap) { File = new ResFile(); // Read BRRES header @@ -63,6 +76,7 @@ namespace NW4RTools { } } + offsetMap = OffsetMap; return File; } diff --git a/NW4RTools/ObjImporter.cs b/NW4RTools/ObjImporter.cs index f00d0f6..93666b1 100755 --- a/NW4RTools/ObjImporter.cs +++ b/NW4RTools/ObjImporter.cs @@ -103,28 +103,32 @@ namespace NW4RTools { // At the end of the .obj parsing, all the shapes will be converted and written. - if (Lightmap != LightmapType.None && !texGroup.ContainsKey(LightmapName1)) { - var lm01 = new Texture(); - var lm02 = new Texture(); + if (Lightmap != LightmapType.None) { + if (!texGroup.ContainsKey(LightmapName1)) { + var lm01 = new Texture(); - lm01.Images = new System.Drawing.Bitmap[1]; - lm01.Images[0] = new System.Drawing.Bitmap(Path.Combine(BasePath, string.Format("images/{0}.png", LightmapName1))); + lm01.Images = new System.Drawing.Bitmap[1]; + lm01.Images[0] = new System.Drawing.Bitmap(Path.Combine(BasePath, string.Format("images/{0}.png", LightmapName1))); - lm01.Format = TextureFormat.I8; + lm01.Format = TextureFormat.I8; + texGroup.Add(LightmapName1, lm01); + } - lm02.Images = new System.Drawing.Bitmap[1]; - lm02.Images[0] = new System.Drawing.Bitmap(Path.Combine(BasePath, string.Format("images/{0}.png", LightmapName2))); + if (!texGroup.ContainsKey(LightmapName2)) { + var lm02 = new Texture(); - lm02.Format = TextureFormat.I8; + lm02.Images = new System.Drawing.Bitmap[1]; + lm02.Images[0] = new System.Drawing.Bitmap(Path.Combine(BasePath, string.Format("images/{0}.png", LightmapName2))); - texGroup.Add(LightmapName1, lm01); - texGroup.Add(LightmapName2, lm02); + lm02.Format = TextureFormat.I8; + texGroup.Add(LightmapName2, lm02); + } } CurrentModel = new Model(); - modelGroup.Add(modelName, CurrentModel); + modelGroup[modelName] = CurrentModel; // Before we start reading the OBJ file, prepare the model CurrentModel.ScaleMode = Model.ScaleModeType.Standard; @@ -780,10 +784,17 @@ namespace NW4RTools { // I might need to create XFMEM_VTXSPECS... // test_lift uses 0x14. According to Dolphin's src, this means: // numcolors = 0, numnormals = 1 (just normal), numtextures = 1. Makes sense. - // If lightmaps, then use: numcolors = 1, numnormals = 1, numtextures = 3 + // If lightmaps, then use: numcolors = 1, numnormals = 1, numtextures = 1 + + // NOTE: Dolphin's source names that as "numtextures" -- but in reality it defines + // the number of texture coords that are sent in the vertex data, NOT textures! + // This little bug was the source of tons of trouble on real consoles, since + // previously I was using 3 (one regular texture; two lightmaps). + // Lightmap texcoords are auto generated, so we now use 1 here. + byte vtxSpecs; if (usingLightmaps) - vtxSpecs = 1 | (1 << 2) | (3 << 4); + vtxSpecs = 1 | (1 << 2) | (1 << 4); else vtxSpecs = 0 | (1 << 2) | (1 << 4); |