将OBJ文件材质上的文理索引后缀从dds,tif改为tga

 

using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;

namespace Dds2Tga
{
    public partial class Form : System.Windows.Forms.Form
    {
        List<string> _folderList = new List<string>();
        public Form()
        {
            InitializeComponent();
        }

        private void Btn_OK(object sender, EventArgs e)
        {
            if (txt_path.Text == "")
            {
                return;
            }
            listBox1.Items.Clear();
            progressBar.Value = 0;

            FindFile(txt_path.Text);
            listBox1.Items.Add("---------------- Count : " + listBox1.Items.Count + " ----------------");

            int pbv = 100 / listBox1.Items.Count;

            for (int i = 0; i < listBox1.Items.Count - 1; i++)
            {
                ModifyMtlFile(listBox1.Items[i].ToString());

                //-----------------------------------------
                ModifyMtlFile(listBox1.Items[i].ToString());
                //-----------------------------------------

                progressBar.Value += pbv;
            }
            progressBar.Value = 100;
            MessageBox.Show("你是最棒的!");
        }

        private void Btn_filePath_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog();
            dialog.Description = "请选择文件路径";
            DialogResult result = dialog.ShowDialog();
            if (result == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }
            string folderPath = dialog.SelectedPath.Trim();
            txt_path.Text = folderPath;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            listBox1.Items.Add("-------------------------------------");
        }

        /// <summary>
        /// 获取所有文件.
        /// </summary>
        /// <param name="dirPath"></param>
        public void FindFile(string dirPath) //参数dirPath为指定的目录
        {
            //在指定目录及子目录下查找文件,在listBox1中列出子目录及文件
            DirectoryInfo Dir = new DirectoryInfo(dirPath);
            try
            {
                foreach (FileInfo f in Dir.GetFiles("*.mtl")) //查找文件
                {
                    listBox1.Items.Add(Dir + "\\" + f.ToString()); //listBox1中填加文件名
                }
                foreach (DirectoryInfo d in Dir.GetDirectories())//查找子目录
                {
                    FindFile(Dir + "\\" + d.ToString());
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }


        private void ModifyMtlFile(string path)
        {
            string loadTex = Read(path);
            if (loadTex == "") return;

            string str = ReplaceString(loadTex, tb_pattern.Text, tb_replace.Text);

            FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Write);
            StreamWriter sr = new StreamWriter(fs);
            sr.Write(str);
            sr.Close();
            fs.Close();
        }

        public string Read(string path)
        {
            try
            {
                return File.ReadAllText(path);
            }
            catch (IOException e)
            {
                MessageBox.Show(e.Message);
            }
            return "";
        }

        public string ReplaceString(string strInput, string strPattern, string strReplace)
        {
            string str = "";
            try
            {
                str = System.Text.RegularExpressions.Regex.Replace(strInput, strPattern, strReplace);
            }
            catch (IOException e)
            {
                MessageBox.Show(e.Message);
            }
            return str;
        }
    }




}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
三态门是一种在Verilog常用的逻辑门,用于实现双向接口。三态门的工作原理是通过控制信号来控制门的开关状态,从而实现数据的输入和输出。当控制信号为1时,门处于高阻态,输出为高阻态;当控制信号为0时,门开通,输入信号可以通过门传递。在Verilog三态门可以使用module来描述,具体的代码描述如下所示: module v_three_st_2 (T, I, O); input T, I; output O; assign O = (~T) ? I: 1'bZ; endmodule 在这段Verilog代码,T表示控制信号,I表示输入信号,O表示输出信号。当T为1时,O处于高阻态;当T为0时,O等于输入信号I。根据控制信号T是高有效还是低有效,三态门的行为会有所不同。根据上述代码描述的逻辑,当T为1时,O处于高阻态,对应于输入端口;当T为0时,O等于输入信号I,对应于输出端口。 三态门Verilog常用于双向接口,比如FLASH的数据接口。在写入数据时,数据接口作为输出端口接收FLASH控制器传来的数据;在读取数据时,数据接口作为输入端口,将从FLASH内部读取的数据传递给FLASH控制器。这种双向接口可以通过使用三态门实现。 总结起来,三态门是一种在Verilog常用的逻辑门,用于实现双向接口。通过控制信号来控制门的开关状态,从而实现数据的输入和输出。在编写三态门Verilog代码时,需要根据实际情况确定控制信号的有效性,同时保证与原语保持一致。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [2022-5-20](https://blog.csdn.net/A15619228315/article/details/124881909)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [verilog三态门用法](https://blog.csdn.net/qq_47891174/article/details/122005422)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值