Archived

This topic is now archived and is closed to further replies.

ID3DXMesh and index buffer

This topic is 5376 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

i have a mesh i laod from an x file, i need to know how many indices there are, but there is not "GetNumIndicies" but there is a "GetNumVertices" so is it safe to assume that the index and vertex buffers are TRIANGLE_LIST, so that the number of indeices is number of verticies / 3 ?

Share this post


Link to post
Share on other sites
There is no GetNumIndices function because YOU specifically specify the number of indices when you create the mesh, therefore, just use the value you supplied. Typically this would be number of faces * 3, rather than number of vertices /3, but it's irrelevant anyway since you specify the number of indices when creating the mesh... just store and utilise that value.

*EDIT* hmm just realised you're probably using the D3DXloadmeshfromX function (or whatever it's called), in which case I see your point as you don't specifically create the mesh.... in which case I'd think that you just need to retrieve the number of faces and times by 3.

[edited by - Mephs on March 23, 2003 2:13:55 AM]

[edited by - mephs on March 23, 2003 2:15:37 AM]

Share this post


Link to post
Share on other sites
This is how you get the number of indices. First you call the GetIndexBuffer member of the mesh. Then you call the GetDesc function of the Index Buffer interface. If the format member of that struct is D3DFMT_INDEX16, divide the size member by 2, if it''s D3DFMT_INDEX32 divide it by 4.

Share this post


Link to post
Share on other sites
The number of vertexes is not same as the number of indexes because there are usually shared vertexes.

Isn't the number of indexes the same as 3 times the number of faces? If not, then how do you extract faces from the mesh?

If so, then how are tri- strips and fans, and line lists and strips represented?

[edited by - Jambolo on March 23, 2003 10:28:52 PM]

Share this post


Link to post
Share on other sites
Okay - stupid C question time.

Once I''ve verified that I''m dealing with 16bit format, what''s the best way to get the indices from the buffer?

For example, if I do the following:


  
DWORD * pIndexList;
mesh->LockIndexBuffer(D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK,
(BYTE **)&pIndexList);

DWORD index = pIndexList[0];


... I always get 131022 as the value in index, which couldn''t be more wrong. So, I must be accessing the values incorrectly?

Share this post


Link to post
Share on other sites