public void Read(Stream stream) { using (BrgBinaryReader reader = new BrgBinaryReader(new LittleEndianBitConverter(), stream)) { uint magic = reader.ReadUInt32(); if (magic != 1280463949) { throw new Exception("This is not a MTRL file!"); } uint nameLength = reader.ReadUInt32(); for (int i = 0; i < 5; ++i) { this.unk[i] = reader.ReadUInt32(); } this.Diffuse = reader.ReadColor3D(); this.Ambient = reader.ReadColor3D(); this.Specular = reader.ReadColor3D(); this.Emissive = reader.ReadColor3D(); this.SpecularLevel = reader.ReadSingle(); this.Alpha = reader.ReadSingle(); this.Id = reader.ReadInt32(); this.SelfIlluminating = reader.ReadByte(); this.ClampU = reader.ReadByte(); this.ClampV = reader.ReadByte(); this.LightSpecular = reader.ReadByte(); this.AffectsAmbient = reader.ReadByte(); this.AffectsDiffuse = reader.ReadByte(); this.AffectsSpecular = reader.ReadByte(); this.Updateable = reader.ReadByte(); this.AlphaMode = reader.ReadInt32(); // Seems to be very often 10, wave has a 2 here, phoenix has 6 this.AmbientIntensity = reader.ReadInt32(); this.DiffuseIntensity = reader.ReadInt32(); this.SpecularIntensity = reader.ReadInt32(); this.EmissiveIntensity = reader.ReadInt32(); this.ColorTransform = reader.ReadInt32(); // Val of 4 seems to be PC this.TextureTransform = reader.ReadInt32(); this.TextureFactor = reader.ReadInt32(); // Has something to do with Cube Map this.MultiTextureMode = reader.ReadInt32(); // Has something to do with Cube Map this.TexGenMode0 = reader.ReadInt32(); this.TexGenMode1 = reader.ReadInt32(); // Has something to do with Cube Map this.TexCoordSet0 = reader.ReadInt32(); this.TexCoordSet1 = reader.ReadInt32(); this.TexCoordSet2 = reader.ReadInt32(); this.TexCoordSet3 = reader.ReadInt32(); this.TexCoordSet4 = reader.ReadInt32(); this.TexCoordSet5 = reader.ReadInt32(); this.TexCoordSet6 = reader.ReadInt32(); this.TexCoordSet7 = reader.ReadInt32(); for (int i = 0; i < 3; ++i) { this.unk2[i] = reader.ReadTexel(); } for (int i = 0; i < 3; ++i) { this.unk3[i] = reader.ReadTexel(); } for (int i = 0; i < 4; ++i) { this.unk4[i] = reader.ReadInt32(); } if (nameLength > 0) { this.Texture = reader.ReadString(); } } }