diff options
| author | Treeki <treeki@gmail.com> | 2011-02-13 16:22:11 +0100 | 
|---|---|---|
| committer | Treeki <treeki@gmail.com> | 2011-02-13 16:22:11 +0100 | 
| commit | 7d7491feb41bc9724bf63bef545b996226406889 (patch) | |
| tree | 21e4ca70d88a1fb8071d8882c3babc4f9fb6646f /NW4RTools/Texture.cs | |
| parent | 426ad45876649595e2d4e9669ff1cf8c250fb163 (diff) | |
| download | nw4rtools-7d7491feb41bc9724bf63bef545b996226406889.tar.gz nw4rtools-7d7491feb41bc9724bf63bef545b996226406889.zip | |
really messy code for materials/textures which KINDA works
Diffstat (limited to 'NW4RTools/Texture.cs')
| -rw-r--r-- | NW4RTools/Texture.cs | 18 | 
1 files changed, 17 insertions, 1 deletions
| 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;  		} | 
