Sign in to follow this  

changing vectors of an x file

Recommended Posts

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);
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 this post

Link to post
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.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this