Original Post
I need some help on how to use a stl vector with a type that contains another stl vector. In my code below I have have two questions that I'm confused with.
[edited by - MagTDK on May 26, 2002 2:59:01 PM]
struct Vertex
{
float X, Y, Z;
float U, V;
};
struct Frame
{
std::vector<Vertex> VertexList;
};
// declared in my class header
std::vector<Frame> Frames;
//////////////////////////////////////////////////////////////////////////////
m_Frames // contains a list of frames and vertices
m_Faces // contains vertex and texture coord indices that make up face
m_TextureCoord // contains texture coord
//////////////////////////////////////////////////////////////////////////////
void CMesh::VertexList()
Vertex TempVert;
// for each frame
for (int i = 0; i < NumFrames; i++) {
// for each face
for (int j = 0; j < NumFaces; j++) {
// for each vertex
for (int k = 0; k < 3; k++) {
// copy over to TempVert
TempVert.X = m_Frames[i].Vertex[m_Faces[j].VertexIndex[k]].X;
TempVert.Z = m_Frames[i].Vertex[m_Faces[j].VertexIndex[k]].Y;
TempVert.Y = m_Frames[i].Vertex[m_Faces[j].VertexIndex[k]].Z;
// copy texture coordinates over.
TempVert.U = m_TextureCoord[m_Faces[j].TextureIndex[k]].U;
TempVert.V = m_TextureCoord[m_Faces[j].TextureIndex[k]].V;
// set vertex color
TempVert.Color = D3DCOLOR_XRGB (255, 255, 255);
// *** after i copy over the vertex data into TempVert, i want to use the vector
// *** push_back method to add the vertex to this m_Frames list
????????.push_back(TempVert); // This is were I'm confused
}
}
// *** after i have collected all the vertices for this frame, I want to add the list of
// *** vertices to this frame
??????.push_back(?????????); // This is were I'm confused
}
}