summaryrefslogtreecommitdiff
path: root/NW4RTools/BrresReader.cs
diff options
context:
space:
mode:
Diffstat (limited to 'NW4RTools/BrresReader.cs')
-rw-r--r--NW4RTools/BrresReader.cs43
1 files changed, 39 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();