c++ - 从 Vector3f 访问数据

标签 c++ ios

我想知道为什么我无法执行以下操作:

std::cout << myMesh.faces[i].vertices[k].pos[k];

错误:Type 'Vector3f' does not provide a subscript operator

我的结构:

struct ObjMeshVertex{
    Vector3f pos;
    Vector2f texcoord;
    Vector3f normal;
};

我的网格:

struct ObjMesh{
    std::vector<ObjMeshFace> faces;
};

struct ObjMeshFace{
    ObjMeshVertex vertices[3];
};

我无法以任何方式访问该 pos。

最佳答案

编译器告诉您 Vector3f 类没有operator[](一些整数类型),您在这里尝试使用它:

myMesh.faces[i].vertices[k].pos[k]
                                ^ calling Vector3f::operator[](...)

关于c++ - 从 Vector3f 访问数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10812247/

相关文章:

c++ - 几个模板问题(已经解决了...只是想知道为什么)

android - React Native 3 按钮和 3 模态

ios - 获取用户位置不起作用?

带有 JSON 数组的 iOS swift tableView header

ios - 从 iOS 应用程序向蓝牙扬声器播放现场声音

c++ - GCC 问题 : in template

c++ - 为什么我的 double 或 int 值在除法后总是 0?

c++ - 波特词干算法实现问题?

iphone - NSManagedObject 异常 “this class is not key value coding-compliant” 并在 ios 6 中使应用程序崩溃,但适用于 ios 5

c++ - QT 5.2.0 getOpenFileName 慢