Jump to content
  • Advertisement
Sign in to follow this  
pp000

[SOLVED] reading indeces from D3DXMESH

This topic is 3322 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I'm trying to get the Indeces from a D3DXMESH, but i cannot figure out how? I have tried to solve it on my own, but I realised I couldn't. As far as I came:
const BYTE* pIndexes;
DWORD* indeces;
mesh->LockIndexBuffer(D3DLOCK_READONLY, (void**)&pIndexes); 


mesh->UnlockIndexBuffer() ;
I hope you can help me. PS: sorry for my bad english language skills, im from austria (not australia) [Edited by - pp000 on June 18, 2009 2:32:17 PM]

Share this post


Link to post
Share on other sites
Advertisement
Typically an index buffer will have 16-bit indices, in which case you should use an unsigned short* pointer instead of a BYTE* pointer. You can check for sure by calling GetDesc on the index buffer and checking the Format member of the D3DINDEXBUFFER_DESC.

Share this post


Link to post
Share on other sites
i have a working solution i think , checks for the format 16 or 32 bit and gets the x,y,z in to a D3DXVECTOR3, if i find it i will post it

Share this post


Link to post
Share on other sites
thank you, that helped a lot, but ive got another problem now:

i have tried something that writes the indices into a textfile. and i have changed pIndeces from BYTE* to unsigned short*.

ofstream myfile;
myfile.open ("test.txt");
for (UINT j = 0; j < noOfIndices; ++j) {
const unsigned short* d = (const unsigned short*)pIndexes;
myfile << *d << "\n";
pIndexes++;
}
myfile << "end" << "\n";
myfile.close();


ive looked into the .x file and the indices are:
0,3,2,1, 4,7,6,5, 8,11,10,9, 12, ...

but when i print them, i get (i have sorted/formatted it):
0,3,2,0,2,1,
4,7,6,4,6,5,
...

my question:
what am i doing wrong?

thank you

Share this post


Link to post
Share on other sites
i solved it, thank you for helping me =)

here's the code i use:

		DWORD nFaces = mesh->GetNumFaces();

ofstream myfile;
myfile.open ("process.txt");
UINT count = 0;
for (UINT j = 0; j < nFaces*3; ++j) {
if (count != 2 && count != 3) {
const unsigned short* d = (const unsigned short*)pIndexes;
myfile << *d << "\n";
}
count++;
if (count == 6) {
count = 0;
}
pIndexes++;
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!