//Utility private int GetTexturePartSize(TexturePart texture) { int size = 112; if (texture.TextureIndex != null) { for (int i = 0; i < texture.TextureIndex.Count(); i++) { size += 4; } } return(size); }
private TexturePart ParseTexturePart(int TextureOffset, int _mainEntryOffset, int _textureEntryOffset) { TexturePart newTexture = new TexturePart(); int TexturePointer = BitConverter.ToInt32(rawBytes, BitConverter.ToInt32(rawBytes, TextureOffset + 20) + _mainEntryOffset) + _mainEntryOffset; newTexture.I_00 = rawBytes[TextureOffset + 0]; newTexture.I_01 = rawBytes[TextureOffset + 1]; newTexture.I_02 = rawBytes[TextureOffset + 2]; newTexture.I_03 = rawBytes[TextureOffset + 3]; newTexture.I_08 = BitConverter.ToInt32(rawBytes, TextureOffset + 8); newTexture.I_12 = BitConverter.ToInt32(rawBytes, TextureOffset + 12); newTexture.I_16 = BitConverter.ToUInt16(rawBytes, TextureOffset + 16); newTexture.F_04 = BitConverter.ToSingle(rawBytes, TextureOffset + 4); newTexture.F_24 = BitConverter.ToSingle(rawBytes, TextureOffset + 24); newTexture.F_28 = BitConverter.ToSingle(rawBytes, TextureOffset + 28); newTexture.F_32 = BitConverter.ToSingle(rawBytes, TextureOffset + 32); newTexture.F_36 = BitConverter.ToSingle(rawBytes, TextureOffset + 36); newTexture.F_40 = BitConverter.ToSingle(rawBytes, TextureOffset + 40); newTexture.F_44 = BitConverter.ToSingle(rawBytes, TextureOffset + 44); newTexture.F_48 = BitConverter.ToSingle(rawBytes, TextureOffset + 48); newTexture.F_52 = BitConverter.ToSingle(rawBytes, TextureOffset + 52); newTexture.F_56 = BitConverter.ToSingle(rawBytes, TextureOffset + 56); newTexture.F_60 = BitConverter.ToSingle(rawBytes, TextureOffset + 60); newTexture.F_64 = BitConverter.ToSingle(rawBytes, TextureOffset + 64); newTexture.F_68 = BitConverter.ToSingle(rawBytes, TextureOffset + 68); newTexture.F_72 = BitConverter.ToSingle(rawBytes, TextureOffset + 72); newTexture.F_76 = BitConverter.ToSingle(rawBytes, TextureOffset + 76); newTexture.F_80 = BitConverter.ToSingle(rawBytes, TextureOffset + 80); newTexture.F_84 = BitConverter.ToSingle(rawBytes, TextureOffset + 84); newTexture.F_88 = BitConverter.ToSingle(rawBytes, TextureOffset + 88); newTexture.F_92 = BitConverter.ToSingle(rawBytes, TextureOffset + 92); newTexture.F_96 = BitConverter.ToSingle(rawBytes, TextureOffset + 96); newTexture.F_100 = BitConverter.ToSingle(rawBytes, TextureOffset + 100); newTexture.F_104 = BitConverter.ToSingle(rawBytes, TextureOffset + 104); newTexture.F_108 = BitConverter.ToSingle(rawBytes, TextureOffset + 108); if (TexturePointer != 0) { int _tempOffset = _textureEntryOffset; newTexture.TextureIndex = new ObservableCollection <int>(); for (int e = 0; e < BitConverter.ToInt16(rawBytes, TextureOffset + 18); e++) { for (int a = 0; a < totalTextureEntries; a++) { if (TexturePointer == _tempOffset) { newTexture.TextureIndex.Add(a); break; } else { if (empFile.Version == VersionEnum.SDBH) { _tempOffset += 36; } else { _tempOffset += 28; } } } } } return(newTexture); }
/// <summary> /// Automates setting specific textures, preventing accidental reference exceptions. /// </summary> /// <param name="whenRotated">Orientation of desired texture.</param> /// <param name="part">Which part of that texture is being set.</param> /// <param name="path">Path to physical texture file.</param> public void setRotatedTexture(Rotation whenRotated, TexturePart part, string path) { switch (whenRotated) { case Rotation.zero: if (this.Default == null) { this.Default = new SpecificTexture(this.Name, this.NAMESPACE); } switch (part) { case TexturePart.albedo: this.Default.AlbedoPath = path; break; case TexturePart.emissive: this.Default.EmissivePath = path; break; case TexturePart.height: this.Default.HeightPath = path; break; case TexturePart.normal: this.Default.NormalPath = path; break; default: break; } break; case Rotation.counter90d: if (this.counter90d == null) { this.counter90d = new SpecificTexture(this.Name + "z+", this.NAMESPACE); } switch (part) { case TexturePart.albedo: this.counter90d.AlbedoPath = path; break; case TexturePart.emissive: this.counter90d.EmissivePath = path; break; case TexturePart.height: this.counter90d.HeightPath = path; break; case TexturePart.normal: this.counter90d.NormalPath = path; break; default: break; } break; case Rotation.counter180d: if (this.counter180d == null) { this.counter180d = new SpecificTexture(this.Name + "x-", this.NAMESPACE); } switch (part) { case TexturePart.albedo: this.counter180d.AlbedoPath = path; break; case TexturePart.emissive: this.counter180d.EmissivePath = path; break; case TexturePart.height: this.counter180d.HeightPath = path; break; case TexturePart.normal: this.counter180d.NormalPath = path; break; default: break; } break; case Rotation.counter270d: if (this.counter270d == null) { this.counter270d = new SpecificTexture(this.Name + "z-", this.NAMESPACE); } switch (part) { case TexturePart.albedo: this.counter270d.AlbedoPath = path; break; case TexturePart.emissive: this.counter270d.EmissivePath = path; break; case TexturePart.height: this.counter270d.HeightPath = path; break; case TexturePart.normal: this.counter270d.NormalPath = path; break; default: break; } break; } }