summaryrefslogtreecommitdiff
path: root/NW4RTools/BrresReader.cs
diff options
context:
space:
mode:
Diffstat (limited to 'NW4RTools/BrresReader.cs')
-rw-r--r--NW4RTools/BrresReader.cs41
1 files changed, 36 insertions, 5 deletions
diff --git a/NW4RTools/BrresReader.cs b/NW4RTools/BrresReader.cs
index 518096d..db5d7c2 100644
--- a/NW4RTools/BrresReader.cs
+++ b/NW4RTools/BrresReader.cs
@@ -67,6 +67,9 @@ namespace NW4RTools {
case "Textures(NW4R)":
File.Add(name, ReadAndConvertDict<Texture>(ins, ConvertTextureResource));
break;
+ case "AnmTexSrt(NW4R)":
+ File.Add(name, ReadAndConvertDict<Models.Animation.TextureSRT>(ins, ConvertAnmTexSRTResource));
+ break;
default:
Debug.Send("Not implemented");
return;
@@ -101,13 +104,20 @@ namespace NW4RTools {
Int16 height = ins.ReadInt16();
TextureFormat format = (TextureFormat)ins.ReadUInt32();
- tex.MipMapCount = ins.ReadUInt32();
+ int mipmapCount = ins.ReadInt32();
tex.MinLOD = ins.ReadFloat();
tex.MaxLOD = ins.ReadFloat();
ins.Seek(startPos + dataOffset);
- OffsetMap.Add(ins.Position, String.Format("Texture Data for: {0} [{1}, {2}x{3}]", name, format, width, height));
- tex.ImportData(ins.ReadBytes(Texture.GetDataSize(width, height, format)), width, height, format);
+ OffsetMap.Add(ins.Position, String.Format("Texture Data for: {0} [{1}, {2}x{3}, {4} mipmaps]", name, format, width, height, mipmapCount));
+
+ // handle mipmaps
+ tex.Images = new System.Drawing.Bitmap[mipmapCount];
+ for (int i = 0; i < mipmapCount; i++) {
+ tex.ImportData(i, ins.ReadBytes(Texture.GetDataSize(width, height, format)), width, height, format);
+ width /= 2;
+ height /= 2;
+ }
return tex;
}
@@ -115,6 +125,22 @@ namespace NW4RTools {
+ private Models.Animation.TextureSRT ConvertAnmTexSRTResource(string name, InputStream ins) {
+ using (var c = Debug.Push(name)) {
+ var anim = new Models.Animation.TextureSRT();
+
+ int startPos = ins.Position;
+
+ OffsetMap.Add(startPos, "Texture SRT Animation: " + name);
+
+ // TODO
+
+ return anim;
+ }
+ }
+
+
+
private Model ConvertModelResource(string name, InputStream ins) {
using (var c = Debug.Push(name)) {
Model mdl = new Model();
@@ -167,6 +193,7 @@ namespace NW4RTools {
ins.Seek(infoStructPos + mtxDataOffset);
+ OffsetMap.Add(ins.Position, "Matrix ID to Node ID Data for: " + name);
UInt32 mtxDataCount = ins.ReadUInt32();
mdl.MatrixIDtoNodeID = new int[mtxDataCount];
@@ -450,6 +477,8 @@ namespace NW4RTools {
n.RawData = ins.ReadBytes(n.EntrySize * n.EntryCount);
n.Parse();
+ OffsetMap.Add(startPos + dataOffset, n.GetType().ToString() + " Data");
+
ins.Seek(structEndPos);
}
@@ -721,21 +750,23 @@ namespace NW4RTools {
int dlBase1 = ins.Position;
// 0x18
- UInt32 bufferSize1 = ins.ReadUInt32();
+ s.DLBufferSize1 = ins.ReadUInt32();
// 0x1C
UInt32 dataSize1 = ins.ReadUInt32();
// 0x20
Int32 offset1 = ins.ReadInt32();
s.DisplayList1 = ins.At(dlBase1 + offset1).ReadBytes((int)dataSize1);
+ OffsetMap.Add(dlBase1 + offset1, String.Format("Shape DL 1: {0} [Buffer Size: 0x{1:X}; Data Size: 0x{2:X}]", name, s.DLBufferSize1, dataSize1));
int dlBase2 = ins.Position;
// 0x24
- UInt32 bufferSize2 = ins.ReadUInt32();
+ s.DLBufferSize2 = ins.ReadUInt32();
// 0x28
UInt32 dataSize2 = ins.ReadUInt32();
// 0x2C
Int32 offset2 = ins.ReadInt32();
s.DisplayList2 = ins.At(dlBase2 + offset2).ReadBytes((int)dataSize2);
+ OffsetMap.Add(dlBase2 + offset2, String.Format("Shape DL 2: {0} [Buffer Size: 0x{1:X}; Data Size: 0x{2:X}]", name, s.DLBufferSize2, dataSize2));
// 0x30
s.DataFlags = ins.ReadUInt32();