Sign in to follow this  
anders211

Access to BLENDINCIDES field of vertex buffer?

Recommended Posts

Hi,
I hava a question. There is such popular function (from Quake3 source of soce) like buildSkinnedMesh. I suppose that everyone hear about it.
In this function mesh which has format (POSITION(float3), NORMAL(float3), TEXCOORD(float2)) is changed with the aid of ConvertToIndexedBlendedMesh into skinned mesh which has format (POSITION(float3), BLENDWEIGHT (in my case float2), BLENDINDICES (UBYTE4), NORMAL(float3), TEXCOORD(float2)).And after that I am confused... because when I get vertex buffer of the skinned mesh I see that all the members related to BLENDINDICES has 0 in it!!!
[CODE]
HRESULT hr = mSkinInfo->ConvertToIndexedBlendedMesh(tempMesh, D3DXMESH_DYNAMIC,
MAX_NUM_BONES_SUPPORTED, 0, 0, 0, 0, &mMaxVertInfluences,
&numBoneComboEntries, &boneComboTable, &mSkinnedMesh);

if(FAILED(hr))
d3d::CheckError(hr, "ConvertToIndexedBlendedMesh()");

//Get vertex declaration for debug purpose
D3DVERTEXELEMENT9 elements[64];
u32 numElements = 0;
mSkinnedMesh->GetDeclaration(elements);

//Get vertex buffer for debug purposes
IDirect3DVertexBuffer9 *pVB = NULL;
mSkinnedMesh->GetVertexBuffer(&pVB);


u32 numBytes = mSkinnedMesh->GetNumBytesPerVertex();
void* dataVB = NULL;
if(FAILED(pVB->Lock(0, numBytes, &dataVB, D3DLOCK_DISCARD))) return;

float* data = (float *) dataVB;
float position_x = (float) data[0];
float position_y = (float) data[1];
float position_z = (float) data[2];
float weight0 = (float) data[3];
float weight1 = (float) data[4];
u32 blendindices = (u32) data[5]; //zero!!!
float n0 = (float) data[6];
float n1 = (float) data[7];
float n2 = (float) data[8];
float tex0 = (float) data[9];
float tex1 = (float) data[10];

float position2_x = (float) data[11];
float position2_y = (float) data[12];
float position2_z = (float) data[13];
float weight20 = (float) data[14];
float weight21 = (float) data[15];
u32 blendindices2 = (u32) data[16]; //zero!!!

u32 posBLENDINDICES = 5;
u32 posWEIGHT = 3;
u32 size = numBytes/4;
vector<u32> blendIndices;
for(u32 i = 0; i< 1000; ++i)
blendIndices.push_back((u32)data[i*11+5]); //all zeros!!!
[/CODE]

The most probably is that BLENDINDICES returns alway 0 (so it is only for read) because when I was trying to modify this field I was failed. I was also trying to change another field just to check if I get well access to the vertex buffer and I was succeed. So it seems that BLENDINDICES is READONLY field. Could anybody confirm that. In runtime the animation behaves in the way like BLENDINDICES values are properly set, that is why I have assumptions that are only for READ. Edited by anders211

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