diff options
Diffstat (limited to '')
-rw-r--r-- | NW4RTools/BrresReader.cs | 43 | ||||
-rw-r--r-- | NW4RTools/Models/Model.cs | 1 | ||||
-rw-r--r-- | NW4RTools/Models/Shader.cs | 10 | ||||
-rw-r--r-- | NW4RTools/NW4RTools.csproj | 1 | ||||
-rwxr-xr-x | NW4RTools/bin/Debug/NW4RTools.dll | bin | 28160 -> 28672 bytes | |||
-rw-r--r-- | NW4RTools/bin/Debug/NW4RTools.dll.mdb | bin | 9806 -> 10083 bytes | |||
-rwxr-xr-x | TestApp/bin/Debug/NW4RTools.dll | bin | 28160 -> 28672 bytes | |||
-rw-r--r-- | TestApp/bin/Debug/NW4RTools.dll.mdb | bin | 9806 -> 10083 bytes | |||
-rwxr-xr-x | TestApp/bin/Debug/TestApp.exe | bin | 3584 -> 3584 bytes | |||
-rw-r--r-- | TestApp/bin/Debug/TestApp.exe.mdb | bin | 416 -> 416 bytes |
10 files changed, 51 insertions, 4 deletions
diff --git a/NW4RTools/BrresReader.cs b/NW4RTools/BrresReader.cs index 4c63926..70463d6 100644 --- a/NW4RTools/BrresReader.cs +++ b/NW4RTools/BrresReader.cs @@ -146,7 +146,7 @@ namespace NW4RTools { // Load vertex data // COMMENTED OUT TO MAKE DEUBG OUTPUT CLEARER FOR NOW - /* + /* using (var c2 = Debug.Push("Vertex Position Data")) mdl.VtxPosData = ReadAndConvertDict<VertexPosData>(ins.At(startPos + vtxPosOffset), ConvertVtxPosData); using (var c2 = Debug.Push("Vertex Normal Data")) @@ -158,9 +158,12 @@ namespace NW4RTools { */ // Load materials - using (var c2 = Debug.Push("Materials")) + using (var c2 = Debug.Push("Materials")) mdl.Materials = ReadAndConvertDict<Material>(ins.At(startPos + materialOffset), ConvertModelMaterial); + using (var c2 = Debug.Push("Shaders")) + mdl.Shaders = ReadAndConvertDict<Shader>(ins.At(startPos + shaderOffset), ConvertModelShader); + return mdl; } } @@ -409,12 +412,23 @@ namespace NW4RTools { ins.Skip(1); // Other stuff + // Shader offset points to an entry in the Shaders group, must fix this up later + // like I did with Node classes Int32 shaderOffset = ins.ReadInt32(); + //Debug.Send("Shader offset for {0}: {1:X} [dest {2:X}]", name, shaderOffset, startPos + shaderOffset); + UInt32 boundTexCount = ins.ReadUInt32(); Int32 boundTexOffset = ins.ReadInt32(); + Int32 furOffset = ins.ReadInt32(); + Debug.Send("Fur offset for {0}: {1:X} [dest {2:X}]", name, furOffset, startPos + furOffset); + Int32 unkOffset = ins.ReadInt32(); + Debug.Send("Unknown offset for {0}: {1:X} [dest {2:X}]", name, unkOffset, startPos + unkOffset); + + // Need to implement DLs... Int32 dlOffset = ins.ReadInt32(); + Debug.Send("DL offset for {0}: {1:X} [dest {2:X}]", name, dlOffset, startPos + dlOffset); // ResTexObj int ResTexObjPos = ins.Position; @@ -493,11 +507,14 @@ namespace NW4RTools { } // Bound Textures + if (boundTexOffset != 0) + OffsetMap.Add(startPos + boundTexOffset, "Material Bound Textures: " + name); + ins.Seek(startPos + boundTexOffset); m.BoundTextures = new List<BoundTextureInfo>((int)boundTexCount); for (int i = 0; i < boundTexCount; i++) { - Debug.Send("Reading {0} bound texture at {1:X}", i, ins.Position); + //Debug.Send("Reading {0} bound texture at {1:X}", i, ins.Position); int bPos = ins.Position; var bTex = new BoundTextureInfo(); @@ -508,7 +525,7 @@ namespace NW4RTools { Int32 palOffs = ins.ReadInt32(); bTex.PaletteName = palOffs == 0 ? null : ins.At(bPos + palOffs - 4).ReadName(); - Debug.Send("<{0}> <{1}>", bTex.TextureName, bTex.PaletteName); + //Debug.Send("<{0}> <{1}>", bTex.TextureName, bTex.PaletteName); // placeholder pointers, don't need these ins.Skip(8); @@ -531,6 +548,24 @@ namespace NW4RTools { + private Models.Shader ConvertModelShader(string name, InputStream ins) { + var s = new Models.Shader(); + + //Debug.Send("{0} @ {1:X}", name, ins.Position); + int startPos = ins.Position; + + // Note: duplicate shader entries seem to be common, so OffsetMap.Add can't be used + // Looks like Nintendo's converter checks for them when writing and optimises them + // into one entry. That'll sure be fun to implement here... probably requiring + // messing around with IEqualityComparer or whatever it's called. I don't even know + // if I'm making sense or not. Too tired to look it up, it's 4:51am... + OffsetMap[ins.Position] = "Shader: " + name; + + return s; + } + + + private RawStreamResDict ReadDict(InputStream ins) { RawStreamResDict output = new RawStreamResDict(); diff --git a/NW4RTools/Models/Model.cs b/NW4RTools/Models/Model.cs index 8fa576e..d1c170b 100644 --- a/NW4RTools/Models/Model.cs +++ b/NW4RTools/Models/Model.cs @@ -16,6 +16,7 @@ namespace NW4RTools.Models { public ResDict<VertexClrData> VtxClrData; public ResDict<VertexTexCoordData> VtxTexCoordData; public ResDict<Material> Materials; + public ResDict<Shader> Shaders; /*public ResDict Bytecode, Nodes, VtxPosData, VtsNrmData, VtxClrData, VtxTexCoordData; public ResDict VtxFurVecData, VtxFurPosData, Materials, Shaders, Shapes; diff --git a/NW4RTools/Models/Shader.cs b/NW4RTools/Models/Shader.cs new file mode 100644 index 0000000..42586da --- /dev/null +++ b/NW4RTools/Models/Shader.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; + +namespace NW4RTools.Models { + public class Shader { + public Shader() { + } + } +} + diff --git a/NW4RTools/NW4RTools.csproj b/NW4RTools/NW4RTools.csproj index f8f89e8..9050c94 100644 --- a/NW4RTools/NW4RTools.csproj +++ b/NW4RTools/NW4RTools.csproj @@ -47,6 +47,7 @@ <Compile Include="Util\OrderedDictionary.cs" /> <Compile Include="Models\VertexData.cs" /> <Compile Include="Models\Material.cs" /> + <Compile Include="Models\Shader.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <ItemGroup> diff --git a/NW4RTools/bin/Debug/NW4RTools.dll b/NW4RTools/bin/Debug/NW4RTools.dll Binary files differindex 7e28e2a..1d9a2ad 100755 --- a/NW4RTools/bin/Debug/NW4RTools.dll +++ b/NW4RTools/bin/Debug/NW4RTools.dll diff --git a/NW4RTools/bin/Debug/NW4RTools.dll.mdb b/NW4RTools/bin/Debug/NW4RTools.dll.mdb Binary files differindex 8183184..e3698a2 100644 --- a/NW4RTools/bin/Debug/NW4RTools.dll.mdb +++ b/NW4RTools/bin/Debug/NW4RTools.dll.mdb diff --git a/TestApp/bin/Debug/NW4RTools.dll b/TestApp/bin/Debug/NW4RTools.dll Binary files differindex 7e28e2a..1d9a2ad 100755 --- a/TestApp/bin/Debug/NW4RTools.dll +++ b/TestApp/bin/Debug/NW4RTools.dll diff --git a/TestApp/bin/Debug/NW4RTools.dll.mdb b/TestApp/bin/Debug/NW4RTools.dll.mdb Binary files differindex 8183184..e3698a2 100644 --- a/TestApp/bin/Debug/NW4RTools.dll.mdb +++ b/TestApp/bin/Debug/NW4RTools.dll.mdb diff --git a/TestApp/bin/Debug/TestApp.exe b/TestApp/bin/Debug/TestApp.exe Binary files differindex 1e59f00..045ad0c 100755 --- a/TestApp/bin/Debug/TestApp.exe +++ b/TestApp/bin/Debug/TestApp.exe diff --git a/TestApp/bin/Debug/TestApp.exe.mdb b/TestApp/bin/Debug/TestApp.exe.mdb Binary files differindex 174701f..348a92a 100644 --- a/TestApp/bin/Debug/TestApp.exe.mdb +++ b/TestApp/bin/Debug/TestApp.exe.mdb |