public virtual void Deserialize(BinaryReader input) { var magic = input.ReadUInt32(); if (magic != _Signature) { throw new FormatException(); } this._Version = input.ReadUInt32(); var tileFlags = input.ReadUInt32(); this._TileU = (tileFlags & 2) != 0; this._TileV = (tileFlags & 1) != 0; this._UOffset = input.ReadSingle(); this._VOffset = input.ReadSingle(); this._UScale = input.ReadSingle(); this._VScale = input.ReadSingle(); this._Alpha = input.ReadSingle(); var alphaBlendMode0 = input.ReadByte(); var alphaBlendMode1 = input.ReadUInt32(); var alphaBlendMode2 = input.ReadUInt32(); this._AlphaBlendMode = ConvertAlphaBlendMode(alphaBlendMode0, alphaBlendMode1, alphaBlendMode2); this._AlphaTestRef = input.ReadByte(); this._AlphaTest = input.ReadBoolean(); this._ZBufferWrite = input.ReadBoolean(); this._ZBufferTest = input.ReadBoolean(); this._ScreenSpaceReflections = input.ReadBoolean(); this._WetnessControlScreenSpaceReflections = input.ReadBoolean(); this._Decal = input.ReadBoolean(); this._TwoSided = input.ReadBoolean(); this._DecalNoFade = input.ReadBoolean(); this._NonOccluder = input.ReadBoolean(); this._Refraction = input.ReadBoolean(); this._RefractionFalloff = input.ReadBoolean(); this._RefractionPower = input.ReadSingle(); this._EnvironmentMapping = input.ReadBoolean(); this._EnvironmentMappingMaskScale = input.ReadSingle(); this._GrayscaleToPaletteColor = input.ReadBoolean(); }
public virtual void Deserialize(Stream input) { var magic = input.ReadValueU32(Endian.Little); if (magic != _Signature && magic.Swap() != _Signature) { throw new FormatException(); } var endian = magic == _Signature ? Endian.Little : Endian.Big; this._Endian = endian; this._Version = input.ReadValueU32(endian); var tileFlags = input.ReadValueU32(endian); this._TileU = (tileFlags & 2) != 0; this._TileV = (tileFlags & 1) != 0; this._UOffset = input.ReadValueF32(endian); this._VOffset = input.ReadValueF32(endian); this._UScale = input.ReadValueF32(endian); this._VScale = input.ReadValueF32(endian); this._Alpha = input.ReadValueF32(endian); var alphaBlendMode0 = input.ReadValueU8(); var alphaBlendMode1 = input.ReadValueU32(endian); var alphaBlendMode2 = input.ReadValueU32(endian); this._AlphaBlendMode = ConvertAlphaBlendMode(alphaBlendMode0, alphaBlendMode1, alphaBlendMode2); this._AlphaTestRef = input.ReadValueU8(); this._AlphaTest = input.ReadValueB8(); this._ZBufferWrite = input.ReadValueB8(); this._ZBufferTest = input.ReadValueB8(); this._ScreenSpaceReflections = input.ReadValueB8(); this._WetnessControlScreenSpaceReflections = input.ReadValueB8(); this._Decal = input.ReadValueB8(); this._TwoSided = input.ReadValueB8(); this._DecalNoFade = input.ReadValueB8(); this._NonOccluder = input.ReadValueB8(); this._Refraction = input.ReadValueB8(); this._RefractionFalloff = input.ReadValueB8(); this._RefractionPower = input.ReadValueF32(endian); this._EnvironmentMapping = input.ReadValueB8(); this._EnvironmentMappingMaskScale = input.ReadValueF32(endian); this._GrayscaleToPaletteColor = input.ReadValueB8(); }
private static void ConvertAlphaBlendMode(AlphaBlendModeType type, ref byte a, ref uint b, ref uint c) { if (type == AlphaBlendModeType.Unknown) { a = 0; b = 6; c = 7; } else if (type == AlphaBlendModeType.None) { a = 0; b = 0; c = 0; } else if (type == AlphaBlendModeType.Standard) { a = 1; b = 6; c = 7; } else if (type == AlphaBlendModeType.Additive) { a = 1; b = 6; c = 0; } else if (type == AlphaBlendModeType.Multiplicative) { a = 1; b = 4; c = 1; } else { throw new NotSupportedException(); } }
private static void ConvertAlphaBlendMode(AlphaBlendModeType type, ref byte a, ref uint b, ref uint c) { if (type == AlphaBlendModeType.Unknown) { a = 0; b = 6; c = 7; } else if (type == AlphaBlendModeType.None) { a = 0; b = 0; c = 0; } else if (type == AlphaBlendModeType.Standard) { a = 1; b = 6; c = 7; } else if (type == AlphaBlendModeType.Additive) { a = 1; b = 6; c = 0; } else if (type == AlphaBlendModeType.Multiplicative) { a = 1; b = 4; c = 1; } else throw new NotSupportedException(); }