summaryrefslogtreecommitdiff
path: root/NW4RTools
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--NW4RTools/BrresReader.cs33
-rw-r--r--NW4RTools/Models/Material.cs1
-rw-r--r--NW4RTools/Models/Shader.cs5
-rwxr-xr-xNW4RTools/bin/Debug/NW4RTools.dllbin28672 -> 29184 bytes
-rw-r--r--NW4RTools/bin/Debug/NW4RTools.dll.mdbbin10087 -> 10124 bytes
5 files changed, 32 insertions, 7 deletions
diff --git a/NW4RTools/BrresReader.cs b/NW4RTools/BrresReader.cs
index 36634d0..cd9452d 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"))
@@ -155,15 +155,18 @@ namespace NW4RTools {
mdl.VtxClrData = ReadAndConvertDict<VertexClrData>(ins.At(startPos + vtxClrOffset), ConvertVtxClrData);
using (var c2 = Debug.Push("Vertex TexCoord Data"))
mdl.VtxTexCoordData = ReadAndConvertDict<VertexTexCoordData>(ins.At(startPos + texCoordOffset), ConvertVtxTexCoordData);
- */
+ //*/
- // Load materials
- using (var c2 = Debug.Push("Materials"))
- mdl.Materials = ReadAndConvertDict<Material>(ins.At(startPos + materialOffset), ConvertModelMaterial);
+ // Load materials and associated structs
+ // Material classes refer to Shaders using an offset, so this is used to fix those up
+ ShaderOffsetRefs = new Dictionary<int, Shader>();
using (var c2 = Debug.Push("Shaders"))
mdl.Shaders = ReadAndConvertDict<Shader>(ins.At(startPos + shaderOffset), ConvertModelShader);
+ using (var c2 = Debug.Push("Materials"))
+ mdl.Materials = ReadAndConvertDict<Material>(ins.At(startPos + materialOffset), ConvertModelMaterial);
+
return mdl;
}
}
@@ -412,9 +415,8 @@ 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();
+ m.ShaderRef = ShaderOffsetRefs[startPos + shaderOffset];
//Debug.Send("Shader offset for {0}: {1:X} [dest {2:X}]", name, shaderOffset, startPos + shaderOffset);
UInt32 boundTexCount = ins.ReadUInt32();
@@ -556,6 +558,8 @@ namespace NW4RTools {
+ private Dictionary<int, Models.Shader> ShaderOffsetRefs;
+
private Models.Shader ConvertModelShader(string name, InputStream ins) {
var s = new Models.Shader();
@@ -569,6 +573,21 @@ namespace NW4RTools {
// if I'm making sense or not. Too tired to look it up, it's 4:51am...
OffsetMap[ins.Position] = "Shader: " + name;
+ UInt32 size = ins.ReadUInt32();
+ Int32 mdlOffset = ins.ReadInt32();
+
+ s.Index = ins.ReadUInt32();
+ s.TevStageCount = ins.ReadByte();
+ ins.Skip(3);
+
+ s.Unk1 = ins.ReadUInt32();
+ s.Unk2 = ins.ReadUInt32();
+ ins.Skip(8);
+
+ s.DisplayList = ins.ReadBytes(0x1E0);
+
+ ShaderOffsetRefs[startPos] = s;
+
return s;
}
diff --git a/NW4RTools/Models/Material.cs b/NW4RTools/Models/Material.cs
index 8ece6ad..8ca5082 100644
--- a/NW4RTools/Models/Material.cs
+++ b/NW4RTools/Models/Material.cs
@@ -55,6 +55,7 @@ namespace NW4RTools.Models {
// Other
public List<BoundTextureInfo> BoundTextures;
+ public Shader ShaderRef;
// Display Lists
public byte[] PixDL;
diff --git a/NW4RTools/Models/Shader.cs b/NW4RTools/Models/Shader.cs
index 42586da..767470e 100644
--- a/NW4RTools/Models/Shader.cs
+++ b/NW4RTools/Models/Shader.cs
@@ -3,6 +3,11 @@ using System.Collections.Generic;
namespace NW4RTools.Models {
public class Shader {
+ public UInt32 Index;
+ public byte TevStageCount;
+ public UInt32 Unk1, Unk2; // TODO: figure these out
+ public byte[] DisplayList;
+
public Shader() {
}
}
diff --git a/NW4RTools/bin/Debug/NW4RTools.dll b/NW4RTools/bin/Debug/NW4RTools.dll
index fcfb2a6..dc75f55 100755
--- a/NW4RTools/bin/Debug/NW4RTools.dll
+++ b/NW4RTools/bin/Debug/NW4RTools.dll
Binary files differ
diff --git a/NW4RTools/bin/Debug/NW4RTools.dll.mdb b/NW4RTools/bin/Debug/NW4RTools.dll.mdb
index 7d4ac90..00c8b7b 100644
--- a/NW4RTools/bin/Debug/NW4RTools.dll.mdb
+++ b/NW4RTools/bin/Debug/NW4RTools.dll.mdb
Binary files differ