Directx mesh vertices problem
I use DirectX to create a boxmesh,and I want to get the vertices position in the mesh,
but I find the 24 vertices are wrong!
or is there any way to use the 24 vertices??? here is my code
D3DXCreateBox(pd3dDevice,2,2,2,&g_model,NULL);
DWORD size=g_model->GetNumVertices();g_model->GetVertexBuffer(&Points);
Points->Lock(0,0,(void**)&v,0);
for(int i=0;i<size;i++)
{
D3DXVECTOR3 vertcle(v[i].x,v[i].y,v[i].z);
Pos.push_back(vertcle);
};
Points->Unlock();
The vectorPos is this:
Pos[24]({-1, -1, -1},{-1, 0, 0},{-1, -1, 1},{-1, 0, 0},开发者_如何学JAVA{-1, 1, 1},{-1, 0, 0},{-1, 1, -1},{-1, 0, 0},{-1, 1, -1},{0, 1, 0},{-1, 1, 1},{0, 1, 0},{1, 1, 1},{0, 1, 0},{1, 1, -1},{0, 1, 0},{1, 1, -1},{1, 0, 0},{1, 1, 1},{1, 0, 0},{1, -1, 1},{1, 0, 0},{1, -1, -1},{1, 0, 0}) std::vector<D3DXVECTOR3,std::allocator<D3DXVECTOR3> >
you can notice some position are wrong(-1,0,0)....
Your vertex buffer contains normals as well as positions -- The odd vectors are the normals.
Try:
for(int i=0;i<size;i++)
{
D3DXVECTOR3 vertcle(v[2*i].x,v[2*i].y,v[2*i].z);
Pos.push_back(vertcle);
}
精彩评论