diff options
Diffstat (limited to '')
-rw-r--r-- | NW4RTools.sln | 2 | ||||
-rw-r--r-- | NW4RTools.userprefs | 36 | ||||
-rw-r--r-- | NW4RTools/BrresReader.cs | 14 | ||||
-rwxr-xr-x | NW4RTools/ObjImporter.cs | 39 |
4 files changed, 69 insertions, 22 deletions
diff --git a/NW4RTools.sln b/NW4RTools.sln index 953e643..15f8760 100644 --- a/NW4RTools.sln +++ b/NW4RTools.sln @@ -27,7 +27,7 @@ Global {A9C9FABD-0A5F-4DAB-979D-9F288F96866F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
- StartupItem = TestApp\TestApp.csproj
+ StartupItem = ConsoleApp\ConsoleApp.csproj
Policies = $0
$0.DotNetNamingPolicy = $1
$1.DirectoryNamespaceAssociation = None
diff --git a/NW4RTools.userprefs b/NW4RTools.userprefs index 0317cce..9ca70fc 100644 --- a/NW4RTools.userprefs +++ b/NW4RTools.userprefs @@ -1,13 +1,11 @@ <Properties> - <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" /> - <MonoDevelop.Ide.Workbench ActiveDocument="NW4RTools/BrresReader.cs"> + <MonoDevelop.Ide.Workspace ActiveConfiguration="Release" /> + <MonoDevelop.Ide.Workbench ActiveDocument="NW4RTools/ObjImporter.cs"> <Files> - <File FileName="NW4RTools/ObjImporter.cs" Line="278" Column="1" /> - <File FileName="NW4RTools/ObjExporter.cs" Line="105" Column="25" /> - <File FileName="NW4RTools/BrresReader.cs" Line="586" Column="31" /> + <File FileName="NW4RTools/ObjExporter.cs" Line="26" Column="23" /> + <File FileName="NW4RTools/BrresReader.cs" Line="33" Column="1" /> <File FileName="NW4RTools/BrresWriter.cs" Line="1262" Column="1" /> <File FileName="NW4RTools/Models/Model.cs" Line="29" Column="1" /> - <File FileName="TestApp/Main.cs" Line="15" Column="4" /> <File FileName="NW4RTools/Types.cs" Line="1" Column="1" /> <File FileName="NW4RTools/VertexSettings.cs" Line="184" Column="46" /> <File FileName="NW4RTools/Models/VertexData.cs" Line="238" Column="31" /> @@ -19,14 +17,38 @@ <File FileName="NW4RTools/DisplayListWriter.cs" Line="76" Column="21" /> <File FileName="NW4RTools/OutputStream.cs" Line="62" Column="32" /> <File FileName="NW4RTools/ColladaExporter.cs" Line="273" Column="7" /> - <File FileName="NW4RTools/ResFile.cs" Line="1" Column="1" /> + <File FileName="NW4RTools/ResFile.cs" Line="22" Column="11" /> <File FileName="NW4RTools/Models/Animation/CharacterAnim.cs" Line="5" Column="28" /> <File FileName="NW4RTools/Models/ByteCode.cs" Line="1" Column="1" /> <File FileName="NW4RTools/Models/Material.cs" Line="1" Column="1" /> + <File FileName="ConsoleApp/Main.cs" Line="16" Column="59" /> + <File FileName="ConsoleApp/Command.cs" Line="7" Column="30" /> + <File FileName="ConsoleApp/ResFileCommands.cs" Line="72" Column="28" /> + <File FileName="NW4RTools/Logger.cs" Line="44" Column="4" /> + <File FileName="NW4RTools/ObjImporter.cs" Line="367" Column="15" /> + <File FileName="ConsoleApp/ModelCommands.cs" Line="68" Column="56" /> + <File FileName="ConsoleApp/TextureCommands.cs" Line="53" Column="8" /> + <File FileName="TestApp/Main.cs" Line="48" Column="5" /> </Files> </MonoDevelop.Ide.Workbench> <MonoDevelop.Ide.DebuggingService.Breakpoints> <BreakpointStore /> </MonoDevelop.Ide.DebuggingService.Breakpoints> <MonoDevelop.Ide.DebuggingService.PinnedWatches /> + <MonoDevelop.Ide.ItemProperties.ConsoleApp> + <MonoDevelop.Ide.CustomExecutionModes> + <Data Name="texture export testing" Id="da90def4-6a8d-4f43-9ad5-04247beb0b89" ModeId="Default"> + <CommandData> + <Item Key="MonoDevelop.Ide.Execution.CustomArgsCustomizer"> + <Value Arguments="export-textures images" WorkingDirectory="/home/me/Games/Newer/ModelRev" ctype="CustomArgsExecutionModeData"> + <EnvironmentVariables /> + </Value> + </Item> + <Item Key="MonoDevelop.Ide.Execution.MonoExecutionCustomizer"> + <Value DebugMode="True" ctype="MonoExecutionParameters" /> + </Item> + </CommandData> + </Data> + </MonoDevelop.Ide.CustomExecutionModes> + </MonoDevelop.Ide.ItemProperties.ConsoleApp> </Properties>
\ No newline at end of file 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); |