public GcmfMaterial(ObjMtlMaterial mtl, Dictionary <Bitmap, int> modelTextureMapping) : this() { Flags = 0x7D4; // TODOXXX if (mtl.DiffuseTextureMap != null) { if (!BitmapComparision.ContainsBitmap(modelTextureMapping, mtl.DiffuseTextureMap)) { throw new InvalidOperationException("Diffuse texture map not found in modelTextureMapping."); } TextureIdx = Convert.ToUInt16(BitmapComparision.GetKeyFromBitmap(modelTextureMapping, mtl.DiffuseTextureMap)); } }
public GcmfMaterial(ObjMtlMaterial mtl, Dictionary <Bitmap, int> modelTextureMapping, string presetFolder) : this() { Flags = 0x7D4; // TODOXXX if (mtl.DiffuseTextureMap != null) { if (!BitmapComparision.ContainsBitmap(modelTextureMapping, mtl.DiffuseTextureMap)) { throw new InvalidOperationException("Diffuse texture map not found in modelTextureMapping."); } TextureIdx = Convert.ToUInt16(BitmapComparision.GetKeyFromBitmap(modelTextureMapping, mtl.DiffuseTextureMap)); } Match materialPreset = Regex.Match(mtl.Name, @"(?<=MAT_)[^\]]*"); if (presetFolder != null && materialPreset.Success) { string[] lines = System.IO.File.ReadAllLines(String.Format("{0}\\{1}.txt", presetFolder, materialPreset.Value)); for (int i = 0; i < lines.Length; i++) { string[] line = lines[i].Split(); if (line.Length == 2) { switch (line[0]) { case "FLAGS": Flags = Convert.ToUInt32(line[1], 16); break; case "TEXTURE_INDEX": TextureIdx = Convert.ToUInt16(line[1], 16); break; case "UNKNOWN_6": Unk6 = Convert.ToByte(line[1], 16); break; case "ANISOTROPY": AnisotropyLevel = Convert.ToByte(line[1], 16); break; case "UNKNOWN_C": UnkC = Convert.ToUInt16(line[1], 16); break; case "UNKNOWN_10": Unk10 = Convert.ToUInt32(line[1], 16); break; default: throw new InvalidOperationException(String.Format("Material preset {0} contains an invalid entry.", materialPreset.Value)); } } else { throw new InvalidOperationException(String.Format("Material preset {0} is not valid.", materialPreset.Value)); } } } }