//-----------------------------------------------D3DTX TO DDS-----------------------------------------------
        //-----------------------------------------------D3DTX TO DDS-----------------------------------------------
        //-----------------------------------------------D3DTX TO DDS-----------------------------------------------

        /// <summary>
        /// Application function for converting D3DTX to DDS
        /// </summary>
        public static void App_Convert_D3DTX_Mode()
        {
            //-----------------GET TEXTURE FOLDER PATH-----------------
            ConsoleFunctions.SetConsoleColor(ConsoleColor.DarkGray, ConsoleColor.White);
            Console.WriteLine("Enter the folder path with the D3DTX textures.");

            //texture folder path (containing the path to the textures to be converted)
            string textureFolderPath = GetFolderPathFromUser();

            //-----------------GET RESULT FOLDER PATH-----------------
            ConsoleFunctions.SetConsoleColor(ConsoleColor.DarkGray, ConsoleColor.White);
            Console.WriteLine("Enter the resulting path where converted DDS textures will be stored.");

            //result folder path (will contain the converted textures)
            string resultFolderPath = GetFolderPathFromUser();

            //-----------------START CONVERSION-----------------
            //notify the user we are starting
            ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Green);
            Console.WriteLine("Conversion Starting...");

            //we got our paths, so lets begin
            Convert_D3DTX_Bulk(textureFolderPath, resultFolderPath);

            //once the process is finished, it will come back here and we will notify the user that we are done
            ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Green);
            Console.WriteLine("Conversion Finished.");
            Console.ResetColor();
        }
        public static string GetFolderPathFromUser()
        {
            string folderPath = "";

            //run a loop until the path is valid
            while (true)
            {
                //get path from user
                ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.White);
                folderPath = Console.ReadLine();

                //check if the path is valid
                if (Directory.Exists(folderPath) == false)
                {
                    //notify the user and this loop will run again
                    ConsoleFunctions.SetConsoleColor(ConsoleColor.Red, ConsoleColor.White);
                    Console.WriteLine("Incorrect Texture Path, try again.");
                }
                else
                {
                    break; //if it's sucessful, then break out of the loop
                }
            }

            return(folderPath);
        }
        /// <summary>
        /// Begins the conversion process. Gathers the files found in the texture folder path, filters them, and converts each one.
        /// </summary>
        /// <param name="texPath"></param>
        /// <param name="resultPath"></param>
        public static void Convert_D3DTX_Bulk(string texPath, string resultPath)
        {
            ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Yellow);
            Console.WriteLine("Collecting Files..."); //notify the user we are collecting files

            //gather the files from the texture folder path into an array
            List <string> textures = new List <string>(Directory.GetFiles(texPath));

            ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Yellow);
            Console.WriteLine("Filtering Textures..."); //notify the user we are filtering the array

            //filter the array so we only get .d3dtx files
            textures = IOManagement.FilterFiles(textures, D3DTX_Master.d3dtxExtension);

            //if no d3dtx files were found, abort the program from going on any further (we don't have any files to convert!)
            if (textures.Count < 1)
            {
                ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Red);
                Console.WriteLine("No .d3dtx files were found, aborting."); //notify the user we found x amount of d3dtx files in the array
                Console.ResetColor();
                return;
            }

            ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Green);
            Console.WriteLine("Found {0} Textures.", textures.Count.ToString()); //notify the user we found x amount of d3dtx files in the array
            Console.WriteLine("Starting...");                                    //notify the user we are starting

            Thread[] threads = new Thread[textures.Count];

            int index = 0;

            //run a loop through each of the found textures and convert each one
            foreach (string texturePath in textures)
            {
                //build the path for the resulting file
                string textureFileName     = Path.GetFileName(texturePath);                                    //get the file name of the file + extension
                string textureFileNameOnly = Path.GetFileNameWithoutExtension(texturePath);
                string textureResultPath   = resultPath + "/" + textureFileNameOnly + DDS_Master.ddsExtension; //add the file name to the resulting folder path, this is where our converted file will be placed

                ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.White);
                Console.WriteLine("||||||||||||||||||||||||||||||||");
                ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Blue);
                Console.WriteLine("Converting '{0}'...", textureFileName); //notify the user are converting 'x' file.
                Console.ResetColor();

                //var thre = new Thread(() => ConvertTexture_FromD3DTX_ToDDS(textureFileName, texture, textureResultPath));
                //thre.IsBackground = true;
                //thre.
                //thre.Start();

                //runs the main method for converting the texture
                ConvertTexture_FromD3DTX_ToDDS(texturePath, textureResultPath);

                ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Green);
                Console.WriteLine("Finished converting '{0}'...", textureFileName); //notify the user we finished converting 'x' file.
                ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.White);
                index++;
            }
        }
Esempio n. 4
0
        public void PrintConsole()
        {
            ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Cyan);
            Console.WriteLine("||||||||||| D3DTX Header |||||||||||");
            ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.White);
            Console.WriteLine("D3DTX mVersion = {0}", mVersion);
            Console.WriteLine("D3DTX mSamplerState_BlockSize = {0}", mSamplerState_BlockSize);
            Console.WriteLine("D3DTX mSamplerState = {0}", mSamplerState);
            Console.WriteLine("D3DTX mPlatform_BlockSize = {0}", mPlatform_BlockSize);
            Console.WriteLine("D3DTX mPlatform = {0} ({1})", Enum.GetName(typeof(PlatformType), (int)mPlatform), mPlatform);
            Console.WriteLine("D3DTX mName Block Size = {0}", mName_BlockSize);
            Console.WriteLine("D3DTX mName = {0}", mName);
            Console.WriteLine("D3DTX mImportName Block Size = {0}", mImportName_BlockSize);
            Console.WriteLine("D3DTX mImportName = {0}", mImportName);
            Console.WriteLine("D3DTX mImportScale = {0}", mImportScale);
            Console.WriteLine("D3DTX mToolProps = {0}", mToolProps);
            Console.WriteLine("D3DTX mNumMipLevels = {0}", mNumMipLevels);
            Console.WriteLine("D3DTX mWidth = {0}", mWidth);
            Console.WriteLine("D3DTX mHeight = {0}", mHeight);
            Console.WriteLine("D3DTX mSurfaceFormat = {0} ({1})", Enum.GetName(typeof(T3SurfaceFormat), mSurfaceFormat), (int)mSurfaceFormat);
            Console.WriteLine("D3DTX mResourceUsage = {0} ({1})", Enum.GetName(typeof(T3ResourceUsage), mResourceUsage), (int)mResourceUsage);
            Console.WriteLine("D3DTX mType = {0} ({1})", Enum.GetName(typeof(T3TextureType), mType), (int)mType);
            Console.WriteLine("D3DTX mNormalMapFormat = {0}", mNormalMapFormat);
            Console.WriteLine("D3DTX mHDRLightmapScale = {0}", mHDRLightmapScale);
            Console.WriteLine("D3DTX mToonGradientCutoff = {0}", mToonGradientCutoff);
            Console.WriteLine("D3DTX mAlphaMode = {0} ({1})", Enum.GetName(typeof(eTxAlpha), mAlphaMode), (int)mAlphaMode);
            Console.WriteLine("D3DTX mColorMode = {0} ({1})", Enum.GetName(typeof(eTxColor), mColorMode), (int)mColorMode);
            Console.WriteLine("D3DTX mUVOffset = {0}", mUVOffset);
            Console.WriteLine("D3DTX mUVScale = {0}", mUVScale);

            ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Cyan);
            Console.WriteLine("----------- mToonRegions -----------");
            ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.White);
            Console.WriteLine("D3DTX mToonRegions_ArrayCapacity = {0}", mToonRegions_ArrayCapacity);
            Console.WriteLine("D3DTX mToonRegions_ArrayLength = {0}", mToonRegions_ArrayLength);
            for (int i = 0; i < mToonRegions_ArrayLength; i++)
            {
                Console.WriteLine("D3DTX mToonRegion {0} = {1}", i, mToonRegions[i]);
            }

            Console.WriteLine("D3DTX mRegionCount = {0}", mStreamHeader.mRegionCount);
            Console.WriteLine("D3DTX mAuxDataCount {0}", mStreamHeader.mAuxDataCount);
            Console.WriteLine("D3DTX mTotalDataSize {0}", mStreamHeader.mTotalDataSize);

            ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Cyan);
            Console.WriteLine("----------- mRegionHeaders -----------");
            for (int i = 0; i < mStreamHeader.mRegionCount; i++)
            {
                ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Cyan);
                Console.WriteLine("[mRegionHeader {0}]", i);
                ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.White);
                Console.WriteLine("D3DTX mFaceIndex = {0}", mRegionHeaders[i].mFaceIndex);
                Console.WriteLine("D3DTX mMipIndex = {0}", mRegionHeaders[i].mMipIndex);
                Console.WriteLine("D3DTX mMipCount = {0}", mRegionHeaders[i].mMipCount);
                Console.WriteLine("D3DTX mDataSize = {0}", mRegionHeaders[i].mDataSize);
                Console.WriteLine("D3DTX mPitch = {0}", mRegionHeaders[i].mPitch);
                Console.WriteLine("D3DTX mSlicePitch = {0}", mRegionHeaders[i].mSlicePitch);
            }
        }
        /*
         * /// <summary>
         * /// The main function for reading and converting said .d3dtx into a .dds file
         * /// </summary>
         * /// <param name="sourceFile"></param>
         * /// <param name="destinationFile"></param>
         * public void ConvertTexture_FromD3DTX_ToDDS(string sourceFileName, string sourceFile, string destinationFile)
         * {
         *  string file_dword = D3DTX_File.Read_D3DTX_File_MetaVersionOnly(sourceFile);
         *  D3DTX_File d3dtx_file = new D3DTX_File();
         *
         *  if (file_dword.Equals("6VSM"))
         *  {
         *      //read D3DTX file
         *      d3dtx_file.D3DTX_6VSM = new D3DTX_6VSM(sourceFile, false);
         *  }
         *  else if (file_dword.Equals("5VSM"))
         *  {
         *      //read D3DTX file
         *      d3dtx_file.D3DTX_5VSM = new D3DTX_5VSM(sourceFile, false);
         *  }
         *  else if (file_dword.Equals("ERTM"))
         *  {
         *      //read D3DTX file
         *      d3dtx_file.D3DTX_ERTM = new D3DTX_ERTM(sourceFile, false);
         *
         *      return;
         *  }
         *
         *  //create a DDS file in memory based off the d3dtx
         *  DDS_File ddsFile = new DDS_File(d3dtx_file);
         *
         *  //write the dds file to disk
         *  //ddsFile.Write_D3DTX_AsDDS(d3dtx_file, destinationFile);
         *
         *  //write the d3dtx header to disk
         *  //d3dtx_file.Write_D3DTX_Header(destinationFile);
         *
         *  //GenericImageFormats.ConvertDDS_To_PSD(destinationFile);
         * }
         */
        //-----------------------------------------------DDS TO D3DTX-----------------------------------------------
        //-----------------------------------------------DDS TO D3DTX-----------------------------------------------
        //-----------------------------------------------DDS TO D3DTX-----------------------------------------------

        /// <summary>
        /// Application function for converting DDS to D3DTX
        /// </summary>
        public void App_Convert_DDS_Mode()
        {
            //notify the user we are starting
            ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Green);
            Console.WriteLine("Conversion Starting...");

            //we got our paths, so lets begin
            //Convert_DDS_Bulk(workingDirectory.workingDirectoryPath, workingDirectory.workingDirectoryPath);

            //once BeginProcess is finished, it will come back here and we will notify the user that we are done
            ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Green);
            Console.WriteLine("Conversion Finished.");
            Console.ResetColor();
        }
Esempio n. 6
0
        /// <summary>
        /// Parses the Meta Header from a byte array.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="bytePointerPosition"></param>
        /// <param name="showConsole"></param>
        public MSV5(BinaryReader reader, bool showConsole = true)
        {
            mMetaStreamVersion      += ByteFunctions.ReadFixedString(reader, 4); //Meta Stream Keyword [4 bytes]
            mDefaultSectionChunkSize = reader.ReadUInt32();                      //Default Section Chunk Size [4 bytes] //default section chunk size
            mDebugSectionChunkSize   = reader.ReadUInt32();                      //Debug Section Chunk Size [4 bytes] //debug section chunk size (always zero)
            mAsyncSectionChunkSize   = reader.ReadUInt32();                      //Async Section Chunk Size [4 bytes] //async section chunk size (size of the bytes after the file header)
            mClassNamesLength        = reader.ReadUInt32();                      //mClassNamesLength [4 bytes]

            //--------------------------mClassNames--------------------------
            mClassNames = new ClassNames[mClassNamesLength];

            for (int i = 0; i < mClassNames.Length; i++)
            {
                mClassNames[i] = new ClassNames()
                {
                    mTypeNameCRC = new Symbol()
                    {
                        mCrc64 = reader.ReadUInt64()
                    },
                    mVersionCRC = reader.ReadUInt32()
                };
            }

            MetaHeaderLength = (4 * 5) + (12 * mClassNamesLength);

            if (showConsole)
            {
                ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Cyan);
                Console.WriteLine("||||||||||| Meta Header |||||||||||");
                ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.White);
                Console.WriteLine("Meta Stream Keyword = {0}", mMetaStreamVersion);
                Console.WriteLine("Meta Default Section Chunk Size = {0}", mDefaultSectionChunkSize);
                Console.WriteLine("Meta Debug Section Chunk Size = {0}", mDebugSectionChunkSize);
                Console.WriteLine("Meta Async Section Chunk Size = {0}", mAsyncSectionChunkSize);
                Console.WriteLine("Meta mClassNamesLength = {0}", mClassNamesLength);

                for (int i = 0; i < mClassNames.Length; i++)
                {
                    Console.WriteLine("Meta mClassName {0} = {1}", i, mClassNames[i]);
                }
            }
        }
        public static bool d3dtxMode = false; //true = in d3dtx to dds mode, false = dds to d3dtx mode
        //----------------------CONVERSION OPTIONS END----------------------

        /// <summary>
        /// Main application method
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            if (d3dtxMode)
            {
                //intro message
                ConsoleFunctions.SetConsoleColor(ConsoleColor.Blue, ConsoleColor.White);
                Console.WriteLine("D3DTX to DDS Texture Converter");

                //Convert d3dtx textures to dds
                App_Convert_D3DTX_Mode();
            }
            else
            {
                //intro message
                ConsoleFunctions.SetConsoleColor(ConsoleColor.Blue, ConsoleColor.White);
                Console.WriteLine("DDS to D3DTX Texture Converter");

                //Convert dds textures to d3dtx
                App_Convert_DDS_Mode();
            }
        }
        /// <summary>
        /// Begins the conversion process. Gathers the files found in the texture folder path, filters them, and converts each one.
        /// </summary>
        /// <param name="texPath"></param>
        /// <param name="resultPath"></param>
        public static void Convert_DDS_Bulk(string texPath, string resultPath)
        {
            ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Yellow);
            Console.WriteLine("Collecting Files..."); //notify the user we are collecting files

            //gather the files from the texture folder path into an array
            List <string> files = new List <string>(Directory.GetFiles(texPath));

            //where our dds file paths will be stored
            List <string> ddsFiles;

            ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Yellow);
            Console.WriteLine("Filtering Files..."); //notify the user we are filtering the array

            //filter the array so we only get .dds files
            ddsFiles = IOManagement.FilterFiles(files, DDS_Master.ddsExtension);

            //if none of the arrays have any files that were found, abort the program from going on any further (we don't have any files to convert!)
            if (ddsFiles.Count < 1)
            {
                ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Red);
                Console.WriteLine("No .dds files were found, aborting.");
                Console.ResetColor();
                return;
            }

            ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Green);
            Console.WriteLine("Found {0} Textures.", ddsFiles.Count.ToString()); //notify the user we found x amount of dds files in the array
            Console.WriteLine("Starting...");                                    //notify the user we are starting

            //run a loop through each of the found textures and convert each one
            foreach (string ddsFile in ddsFiles)
            {
                ConvertTexture_FromDDS_ToD3DTX(ddsFile, resultPath);
            }
        }
        /// <summary>
        /// Parses the Meta Header from a byte array.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="bytePointerPosition"></param>
        /// <param name="showConsole"></param>
        public MTRE(BinaryReader reader, bool showConsole = true)
        {
            mMetaStreamVersion += ByteFunctions.ReadFixedString(reader, 4); //Meta Stream Keyword [4 bytes]
            mClassNamesLength   = reader.ReadUInt32();                      //mClassNamesLength [4 bytes]

            //--------------------------mClassNames--------------------------
            mClassNames = new ClassNames[mClassNamesLength];

            for (int i = 0; i < mClassNames.Length; i++)
            {
                mClassNames[i] = new ClassNames()
                {
                    mTypeNameCRC = new Symbol()
                    {
                        mCrc64 = reader.ReadUInt64()
                    },
                    mVersionCRC = reader.ReadUInt32()
                };
            }

            MetaHeaderLength = (4 * 5) + (12 * mClassNamesLength);

            if (showConsole)
            {
                ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Cyan);
                Console.WriteLine("||||||||||| Meta Header |||||||||||");
                ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.White);
                Console.WriteLine("Meta Stream Keyword = {0}", mMetaStreamVersion);
                Console.WriteLine("Meta mClassNamesLength = {0}", mClassNamesLength);

                for (int i = 0; i < mClassNames.Length; i++)
                {
                    Console.WriteLine("Meta mClassName {0} = {1}", i, mClassNames[i]);
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Parses the data from a DDS byte array. (Can also read just the header only)
        /// </summary>
        /// <param name="fileData"></param>
        /// <param name="headerOnly"></param>
        private void GetData(byte[] fileData, bool headerOnly)
        {
            ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.White);
            Console.WriteLine("Total Source Texture Byte Size = {0}", fileData.Length);

            //which byte offset we are on for the source texture (will be changed as we go through the file)
            byte[] headerBytes = ByteFunctions.AllocateBytes(124, fileData, 4); //skip past the 'DDS '

            //this will automatically read all of the byte data in the header
            header = DDS_Functions.GetHeaderFromBytes(headerBytes);

            ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.White);
            Console.WriteLine("DDS Height = {0}", header.dwHeight);
            Console.WriteLine("DDS Width = {0}", header.dwWidth);
            Console.WriteLine("DDS Mip Map Count = {0}", header.dwMipMapCount);
            Console.WriteLine("DDS Compression = {0}", header.ddspf.dwFourCC);

            if (headerOnly)
            {
                return;
            }

            //--------------------------EXTRACT DDS TEXTURE DATA--------------------------
            //calculate dds header length (we add 4 because we skipped the 4 bytes which contain the ddsPrefix, it isn't necessary to parse this data)
            uint ddsHeaderLength = 4 + header.dwSize;

            //calculate the length of just the dds texture data
            uint ddsTextureDataLength = (uint)sourceFileData.Length - ddsHeaderLength;

            //allocate a byte array of dds texture length
            byte[] ddsTextureData = new byte[ddsTextureDataLength];

            //copy the data from the source byte array past the header (so we are only getting texture data)
            Array.Copy(sourceFileData, ddsHeaderLength, ddsTextureData, 0, ddsTextureData.Length);

            //if there are no mip maps
            if (header.dwMipMapCount <= 1)
            {
                textureData = new();
                textureData.Add(ddsTextureData);
                Console.WriteLine("DDS Texture Byte Size = {0}", textureData[0].Length);
            }
            else //if there are mip maps
            {
                //get mip resolutions
                //calculated mip resolutions [Pixel Value, Width or Height (0 or 1)]
                mipMapResolutions = DDS_Functions.DDS_CalculateMipResolutions(header.dwMipMapCount, header.dwWidth, header.dwHeight);

                //get byte sizes
                uint[] byteSizes = DDS_Functions.DDS_GetImageByteSizes(mipMapResolutions, DDS_Functions.DDS_CompressionBool(header));

                textureData = new();
                int test   = ddsTextureData.Length;
                int offset = 0;

                for (int i = 0; i < byteSizes.Length; i++)
                {
                    byte[] temp = new byte[byteSizes[i]];

                    //issue length
                    Array.Copy(ddsTextureData, offset, temp, 0, temp.Length);

                    offset += temp.Length - 1;

                    textureData.Add(temp);

                    test -= (int)byteSizes[i];
                }
            }
        }
        /// <summary>
        /// The main function for reading and converting said .dds back into a .d3dtx file
        /// </summary>
        /// <param name="sourceFile"></param>
        /// <param name="destinationFile"></param>
        public static void ConvertTexture_FromDDS_ToD3DTX(string sourceFilePath, string resultDirectoryPath)
        {
            //deconstruct the source file path
            string textureFileDirectory = Path.GetDirectoryName(sourceFilePath);
            string textureFileNameOnly  = Path.GetFileNameWithoutExtension(sourceFilePath);

            //create the names of the following files
            string textureFileNameWithD3DTX  = textureFileNameOnly + D3DTX_Master.d3dtxExtension;
            string textureFileNameWithHEADER = textureFileNameOnly + D3DTX_Master.headerExtension;
            string textureFileNameWithJSON   = textureFileNameOnly + D3DTX_Master.jsonExtension;

            //create the path of these files. If things go well, these files (depending on the version) should exist in the same directory at the original .dds file.
            string textureFilePath_HEADER = textureFileDirectory + "/" + textureFileNameWithHEADER;
            string textureFilePath_JSON   = textureFileDirectory + "/" + textureFileNameWithJSON;

            //create the final path of the d3dtx
            string textureResultPath_D3DTX = resultDirectoryPath + "/" + textureFileNameWithD3DTX;

            //if a json file exists (for newer 5VSM and 6VSM)
            if (File.Exists(textureFilePath_JSON))
            {
                //read in our DDS file
                DDS_Master dds = new DDS_Master(sourceFilePath, false);

                //dds parse test
                //dds.TEST_WriteDDSToDisk(sourceFilePath);

                //create our d3dtx object
                D3DTX_Master d3dtx_file = new D3DTX_Master();

                //parse the .json file as a d3dtx
                d3dtx_file.Read_D3DTX_JSON(textureFilePath_JSON);

                //modify the d3dtx file using our dds data
                d3dtx_file.Modify_D3DTX(dds); //ISSUE HERE WITH DXT5 AND MIP MAPS WITH UPSCALED TEXTURES

                //write our final d3dtx file to disk
                d3dtx_file.Write_Final_D3DTX(textureResultPath_D3DTX);

                //File.Delete(textureFilePath_JSON);
                //File.Delete(sourceFilePath);
            }
            //if there is no .json, check for a .header (for versions older than 5VSM)
            else if (File.Exists(textureFilePath_HEADER))
            {
                ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Red);
                Console.WriteLine("Converting d3dtx older than 5VSM not supported yet!!!!");
                Console.WriteLine("{0}", textureFileNameOnly);
                Console.WriteLine("Skipping conversion on this file.", textureFileNameOnly);
                ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.White);

                return;
            }
            //if we found neither, we're screwed!
            else
            {
                ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Red);
                Console.WriteLine("No .json or .header was found for the file were trying to convert!!!!");
                Console.WriteLine("{0}", textureFileNameOnly);
                Console.WriteLine("Skipping conversion on this file.", textureFileNameOnly);
                ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.White);

                return;
            }
        }
        /// <summary>
        /// Reads in a D3DTX file from the disk.
        /// </summary>
        /// <param name="filePath"></param>
        public void Read_D3DTX_File(string filePath)
        {
            //read meta version of the file
            string metaVersion = Read_D3DTX_File_MetaVersionOnly(filePath);

            //read the d3dtx version of the file
            int d3dtxVersion = Read_D3DTX_File_D3DTXVersionOnly(filePath);

            using (BinaryReader reader = new BinaryReader(File.OpenRead(filePath)))
            {
                //read meta header
                switch (metaVersion)
                {
                case "6VSM":
                    msv6 = new(reader);
                    break;

                case "5VSM":
                    msv5 = new(reader);
                    break;

                case "ERTM":
                    mtre = new(reader);
                    break;

                default:
                    ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Red);
                    Console.WriteLine("ERROR! '{0}' meta stream version is not supported!", metaVersion);
                    ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.White);
                    return;
                }

                if (d3dtxVersion == 5 || d3dtxVersion == 6 || d3dtxVersion == 7 || d3dtxVersion == 8)
                {
                    ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Yellow);
                    Console.WriteLine("Warning! '{0}' version is not fully complete/tested! There may be some issues with converting.", d3dtxVersion);
                    ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.White);
                }

                //read d3dtx header
                switch (d3dtxVersion)
                {
                case 4:
                    d3dtx4 = new(reader, true);
                    break;

                case 5:
                    d3dtx5 = new(reader, true);
                    break;

                case 6:
                    d3dtx6 = new(reader, true);
                    break;

                case 7:
                    d3dtx7 = new(reader, true);
                    break;

                case 8:
                    d3dtx8 = new(reader, true);
                    break;

                case 9:
                    d3dtx9 = new(reader, true);
                    break;

                default:
                    ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Red);
                    Console.WriteLine("ERROR! '{0}' d3dtx version is not supported!", d3dtxVersion);
                    ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.White);
                    break;
                }
            }
        }