我有这样的结构:填充结构的阵列动态
struct Vertex {
Vertex(float px, float py, float pz,
float nx, float ny, float nz,
float tx, float ty) : position(px, py, pz),
normals(nx, ny, nz),
texCoords(tx, ty) {}
XMFLOAT3 position;
XMFLOAT3 normals;
XMFLOAT2 texCoords;
};
,我需要填补该阵列与某些载体:
std::vector<XMFLOAT3> positions;
std::vector<XMFLOAT3> normals;
std::vector<XMFLOAT2> texCoords;
阵列的长度由
给出int numVertices;
我想用向量填充struct Vertex
的数组。我怎样才能做到这一点? 我试图初始化这样的数组:
Vertex points[numVertices];
但VAR没有一个恒定值。
谢谢你的帮助。
为什么不能使用'std :: vector'? –
mpiatek
之后,我不得不使用'reinterpret_cast(点)'这需要数组而不是向量。 –
Pino
vector :: data()像一个原始数组(指向它的第一个元素的指针)。你可以用它来投射“BYTE *”或其他。 –