我一直在构建一个将一种模型文件类型转换为波前 obj 类型的程序,但是在将我的面孔写入该文件时遇到了问题。
if(!strcmp(line , "TEX:TOP"))
{
i++;
TEX_TOP << "f " << i << "/" << i << "/" << i << " ";
i++;
TEX_TOP << TEX_TOP << i << "/" << i << "/" << i << " ";
i++;
TEX_TOP << TEX_TOP << i << "/" << i << "/" << i << " ";
i++;
TEX_TOP << TEX_TOP << i << "/" << i << "/" << i << "\n";
}
这部分代码应该输出..
f 1/1/1 2/2/2 3/3/3 4/4/4
但出来时..
f 1971327331/1971327331/1971327331 0x28f5a81971327332/1971327332/1971327332 0x28f5a81971327333/1971327333/1971327333 0x28f5a81971327334/1971327334/1971327334
我已经搜索了几个小时,仍然找不到修复程序。
编辑:感谢 LihO,我的问题是我将 TEX_TOP fstream 对象放在每行的开头,假设我正在重新声明它,并且 int 必须从 0 开始才能计数。
i = 0;
if(!strcmp(line , "TEX:TOP"))
{
i++;
TEX_TOP << i << "/" << i << "/" << i << " ";
i++;
TEX_TOP << i << "/" << i << "/" << i << " ";
i++;
TEX_TOP << i << "/" << i << "/" << i << " ";
i++;
TEX_TOP << i << "/" << i << "/" << i << "\n";
}