Archived

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

DmGoober

D3D: matrix palette Question

Recommended Posts

DmGoober    136
I have triangles where each vertex of the triangle is affected by a different matrix. Each vertex is affected by at most 1 matrix. So, in D3D how would i set this up? The matrix palette seems like the obvious solution so here''s what i tried: #define SKIN_FVF (D3DFVF_XYZB1 | D3DFVF_LASTBETA_UBYTE4 | D3DFVF_NORMAL) struct SSkinVertex { D3DXVECTOR3 v; float weight; //always 1.0 DWORD matrixIndices; //low byte is the only one used. D3DXVECTOR3 n; }; m_pDevice->SetRenderState(D3DRS_VERTEXBLEND, D3DVBF_0WEIGHTS); m_pDevice->SetRenderState(D3DRS_INDEXEDVERTEXBLENDENABLE, TRUE); Then i tried rendering. This renders garbage. I have also tried with D3DFVF_XYZB1 and D3DVBF_1WEIGHTS, however this also renders garbage. Does anyone know how to setup d3d so you can use the matrix palette but only have 1 weight (which is always 1.0) for each vertex? PS. I know that my rendering stuff is set up correctly because if i remove matrix and blending information, D3D renders fine. Thanks in advance. DmGoober

Share this post


Link to post
Share on other sites
DmGoober    136
I love this. Everytime after i post, i find my own answer. I think its cause i stop programming for a bit and start thinking about it.

Anway, here a combo that works:

#define SKIN_FVF (D3DFVF_XYZB1 | D3DFVF_LASTBETA_UBYTE4 | D3DFVF_NORMAL)

struct SSkinVertex
{
D3DXVECTOR3 v;
DWORD matrixIndices; //low byte is the only one used.
D3DXVECTOR3 n;
};

m_pDevice->SetRenderState(D3DRS_VERTEXBLEND, D3DVBF_0WEIGHTS);
m_pDevice->SetRenderState(D3DRS_INDEXEDVERTEXBLENDENABLE, TRUE);

Fairly obvious i guess. . . just notice that there is no weight at all in the vertex structure (despite the fact that the documentation says the DWORD with teh packed indices should always follow the weight.)

Hope this helps someone else too.

DmGoober

Share this post


Link to post
Share on other sites