changing vectors of an x file

Recommended Posts

ryt    294
ths is how i did it:

Vertex* tri;
xFile->LockVertexBuffer(D3DLOCK_NOOVERWRITE, (void**)&tri);
for(DWORD i = 0; i < xFile->GetNumVertices(); i++){
tri[i] = Vertex(angle,angle,angle);
}
xFile->UnlockVertexBuffer();

my Vertex isnt the same as xFile, but i dont know how to retrive it, i tried with GetFVF() but i dont know how to implement it

Share on other sites
There are two ways to do this. The first is that you can clone the mesh to force it to have a specific vertex format. To do this, use the ID3DXMesh::CloneMesh or ID3DXMesh::CloneMeshFVF methods. Once you do this, you can lock the vertex buffer and use a pointer to your vertex structure to access the data.

The second, and more flexible way, is to figure out at what offset within the vertex buffer is the particular data you want to change. For example, if you want to change the NORMAL vector of a vertex, then you need to call ID3DXMesh::GetDeclaration to get a detailed description of the vertex format. Then you look through that array until you find the element tagged as a normal vector. You can then use this offset number to offset from the beginning of the vertex buffer's memory.

neneboricua

Share on other sites
ryt    294
thx, ill try the first metod, it seems easyer