Пример #1
0
        ///TODO: Fix this crap
        /// <summary>
        /// Reads a material for the given surface and its associated images
        /// </summary>
        public static WavefrontOBJ.Material ReadMaterial(int address)
        {
            // Read Material
            var material = (Material)((uint)address);
            // Create new OBJ Image
            var _path       = console.ReadString(console.ReadUInt32((uint)address)).Replace("*", "");
            var objMaterial = new WavefrontOBJ.Material(Path.GetFileNameWithoutExtension(_path));

            // Loop over images
            for (byte i = 0; i < material.ImageCount; i++)
            {
                // Read Material Image
                var materialImage =
                    (MaterialImage32B)((uint)material.ImageTablePointer +
                                       i * Marshal
                                       .SizeOf <MaterialImage32B>()
                                       );
                // Check for color map for now
                if (materialImage.SemanticHash != 0xA0AB1041)
                {
                    continue;
                }
                var str = console.ReadString((uint)materialImage.ImagePointer + 0x1C) + ".png";
                objMaterial.DiffuseMap = "_images\\\\" + str;
            }

            // Done
            return(objMaterial);
        }
Пример #2
0
        /// <summary>
        /// Reads a material for the given surface and its associated images
        /// </summary>
        public static WavefrontOBJ.Material ReadMaterial(ProcessReader reader, long address)
        {
            // Read Material
            var material = reader.ReadStruct <Material>(address);
            // Create new OBJ Image
            var objMaterial = new WavefrontOBJ.Material(Path.GetFileNameWithoutExtension(reader.ReadNullTerminatedString(reader.ReadInt32(address)).Replace("*", "")));

            // Loop over images
            for (byte i = 0; i < material.ImageCount; i++)
            {
                // Read Material Image
                var materialImage = reader.ReadStruct <MaterialImage32B>(material.ImageTablePointer + i * Marshal.SizeOf <MaterialImage32B>());
                // Check for color map for now
                if (materialImage.SemanticHash == 0xA0AB1041)
                {
                    objMaterial.DiffuseMap = reader.ReadNullTerminatedString(reader.ReadInt32(materialImage.ImagePointer + 0x1C));
                }
                else if (materialImage.SemanticHash == 0x59D30D0F)
                {
                    objMaterial.NormalMap = reader.ReadNullTerminatedString(reader.ReadInt32(materialImage.ImagePointer + 0x1C));
                }
                else if (materialImage.SemanticHash == 0x34ECCCB3)
                {
                    objMaterial.SpecularMap = reader.ReadNullTerminatedString(reader.ReadInt32(materialImage.ImagePointer + 0x1C));
                }
            }
            // Done
            return(objMaterial);
        }
Пример #3
0
        /// <summary>
        /// Reads a material for the given surface and its associated images
        /// </summary>
        public static WavefrontOBJ.Material ReadMaterial(ProcessReader reader, long address)
        {
            // Read Material
            var material = reader.ReadStruct <Material>(address);
            // Create new OBJ Image
            var objMaterial = new WavefrontOBJ.Material(Path.GetFileNameWithoutExtension(reader.ReadNullTerminatedString(reader.ReadInt64(address)).Replace("*", "")));

            // Loop over images
            for (byte i = 0; i < material.ImageCount; i++)
            {
                // Read Material Image
                var materialImage = reader.ReadStruct <MaterialImage64A>(material.ImageTablePointer + i * Marshal.SizeOf <MaterialImage64A>());
                // Check for color map for now
                if (materialImage.SemanticHash == 0xA0AB1041)
                {
                    objMaterial.DiffuseMap = "_images\\\\" + reader.ReadNullTerminatedString(reader.ReadInt64(materialImage.ImagePointer + 96)) + ".png";
                }
            }
            // Done
            return(objMaterial);
        }