Sign in to follow this  
Trillian

ID3DXMesh Attribute buffer

Recommended Posts

Trillian    410
Hello! I have a model containing 2 materials that I load into a ID3DXMesh. For simplicity, let's say that: material 1 - faces 0 2 4 material 2 - faces 1 3 So I want to use the ID3DXMesh Attribute buffer to separate my mesh into two subsets: subset 0 - material 1 - DrawSubset(0); subset 1 - material 2 - DrawSubset(1); how can I do that? I looked at the msdn ID3DXMesh::LockAttributeBuffer but it's not very helpful. My guess is that I must ID3DXMesh::LockAttributeBuffer(flags,attr) and then consider there is ID3DXMesh::GetNumFaces attributes, and fill it with the subset to which each face corresponds. In that case it would be: attr[0]=0 attr[1]=1 attr[2]=0 attr[3]=1 attr[4]=0 and then render for each subset (pseudocode): SetMaterial(MATERIALS[i]); SetTexture(TEXTURES[i]); mesh.DrawSubset(i); Is that what I must do?

Share this post


Link to post
Share on other sites
jollyjeffers    1570
You've almost got it.

Your list seemed to be a per-primitive, rather it's the other way around - it's primitives-per-subset.

Look into ID3DXMesh::SetAttributeTable( ). You construct a number of D3DXATTRIBUTERANGE structures and pass them in.

There's nothing hugely complex about the D3DXATTRIBUTERANGE struct, BUT you might need to rearrange the order of your indices (vertices can probably stay the same initially) so as to match the specified ranges.

Regarding efficieny, you might want to make a call to ID3DXMesh::OptimizeInplace() after messing with the attribute table - it's possible that the stock algorithms can gain you a bit of performance without messing with your newly created subset/orders [smile]

hth
Jack

Share this post


Link to post
Share on other sites
Trillian    410
Hey!

Thanks a lot for the help!
I don't know if it actually helped but now it works!
In fatc, my main problem was noobish (but I must admit I am a newbe), simply, I loaded my attributes in a DWORD heap but (and I'm not proud of myself), I actually forgot to copy them in the mesh's attribute buffer!

Thanks again for your support.

Sorry, I already rated you as Extremely helpful and/or friendly, you can't go higher!

Share this post


Link to post
Share on other sites
rouncer    294
materials are old style, new style means using pixel masks
as textures and you combine them in the shader.
you only need one material for any amount of effects on
any part of the model at any weighting. :)
cool stuff, but yeh, more video ram is required.

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