Ejemplo n.º 1
0
        private void ReadMaterialTextures()
        {
            var chunk     = Data.GetChunkByName("MOMT");
            var nameChunk = Data.GetChunkByName("MOTX");

            if (chunk == null || nameChunk == null)
            {
                return;
            }

            const int materialSize   = 64;
            var       countMaterials = (int)(chunk.Length / materialSize);

            Materials = new List <WorldModelMaterialTexture>(countMaterials);
            for (int i = 0; i < countMaterials; i++)
            {
                var stream = chunk.GetStream();
                stream.Seek(materialSize * i, SeekOrigin.Current);
                var material   = WorldModelMaterialTexture.Read(stream);
                var nameStream = nameChunk.GetStream();
                if (material.Texture1 >= nameChunk.Length)
                {
                    continue;
                }
                nameStream.Seek(material.Texture1, SeekOrigin.Current);
                material.Texture1Name = nameStream.ReadCString();
                Materials.Add(material);
            }
        }
Ejemplo n.º 2
0
        public static WorldModelMaterialTexture Read(Stream s)
        {
            var r   = new BinaryReader(s);
            var ret = new WorldModelMaterialTexture();

            ret.MaterialId  = r.ReadUInt32();
            ret.Shader      = r.ReadUInt32();
            ret.BlendMode   = r.ReadUInt32();
            ret.Texture1    = r.ReadUInt32();
            ret.Color1      = r.ReadUInt32();
            ret.Flags1      = r.ReadUInt32();
            ret.Texture2    = r.ReadUInt32();
            ret.Color2      = r.ReadUInt32();
            ret.Flags2      = r.ReadUInt32();
            ret.Texture3    = r.ReadUInt32();
            ret.Color3      = r.ReadUInt32();
            ret.Flags3      = r.ReadUInt32();
            ret.Diffcolor1  = r.ReadSingle();
            ret.Diffcolor2  = r.ReadSingle();
            ret.Diffcolor3  = r.ReadSingle();
            ret.RunTimeData = r.ReadUInt32();
            return(ret);
        }