From 7d7491feb41bc9724bf63bef545b996226406889 Mon Sep 17 00:00:00 2001 From: Treeki Date: Sun, 13 Feb 2011 16:22:11 +0100 Subject: really messy code for materials/textures which KINDA works --- NW4RTools/Texture.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'NW4RTools/Texture.cs') diff --git a/NW4RTools/Texture.cs b/NW4RTools/Texture.cs index 954852d..2de9ad8 100644 --- a/NW4RTools/Texture.cs +++ b/NW4RTools/Texture.cs @@ -137,6 +137,8 @@ namespace NW4RTools { case TextureFormat.RGB5A3: case TextureFormat.I4: case TextureFormat.I8: + case TextureFormat.IA4: + case TextureFormat.IA8: // I4 is stupid and breaks my parser. I'll keep some state here bool alreadyHaveI4Nybble = false; byte currentI4Byte = 0; @@ -194,6 +196,18 @@ namespace NW4RTools { } else if (format == TextureFormat.I8) { byte val = data.ReadByte(); *pPixel = 0xFF000000 | (uint)(val << 16) | (uint)(val << 8) | val; + + } else if (format == TextureFormat.IA4) { + byte val = data.ReadByte(); + uint i = (uint)(val >> 4); + uint a = (uint)((val & 0xF0) << 4); + *pPixel = (a << 24) | (i << 16) | (i << 8) | i; + + } else if (format == TextureFormat.IA8) { + byte i = data.ReadByte(); + byte a = data.ReadByte(); + *pPixel = (uint)(a << 24) | (uint)(i << 16) | (uint)(i << 8) | i; + } } } @@ -259,7 +273,9 @@ namespace NW4RTools { image.UnlockBits(bits); - + + image.RotateFlip(RotateFlipType.RotateNoneFlipY); // TODO: remove this, and fix texcoords properly + BaseImage = image; Format = format; } -- cgit v1.2.3