c++ - 从保存在 .txt 文件中的数组加载 3D 立方体
问题描述
在编码方面我仍然处于中级水平,所以请原谅任何听起来不太正确的事情。
我在一个名为“cube”的 .txt 文件中创建了一个数组。我有一段我一直在处理的代码,它已部分完成,但我只是想知道,它看起来是否会按照预期的方式运行,从文件中加载信息以及我将如何加载“颜色" 和 "索引" 信息,如代码底部的注释。
bool Cube::Load(char* path)
{
std::ifstream inFile;
inFile.open(path);
if (!inFile.good())
{
std::cerr << "Can't open text file" << path << std::endl;
return false;
}
inFile >> numVertices;
indexedVertices = new Vertex[numVertices];
for (int i = 0; i < numVertices; i++)
{
//TODO use inFile to populate the indexedVertices array
ifstream inputFile;
inputFile.open("cube.txt");
}
//TO DO: Load Color information
//TO DO: Load Indices information
inFile.close();
return true;
}
解决方案
推荐阅读
- c# - xml反序列化不绑定列表
- flutter - 边框半径不适用于容器小部件内
- python - 确保用户的输入不是 Python 3 中的字符串
- javascript - 应用于特定数字输入字段的混合/最大范围
- java - 需要在等待函数上下文中实现 Thread.sleep(100) 来评估睡眠时间吗?
- java - 关于springboot的问题
- javascript - 在 jQuery UI DatetimePicker 中突出显示特定日期
- mongodb - 如何在mongodb中级联删除文档?
- angular - 无法读取 Angular 中未定义的属性
- apache-spark - Spark org.apache.spark.sql.catalyst.analysis.UnresolvedException 加载 Hive 表时出错