• Advertisement
Sign in to follow this  

direct3d mesh and convex hulls and compound collision

This topic is 3166 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 all i am triing to create an array of convex hulls to pass it to a compound collision as i heard they work freakin awesome for concave shapes but create convex hulls of what? i think i should create a convex hull for every subset of my mesh so how can i acces the vertex and vertex buffer of every subset one by one i acces the whole vertex and index buffer like this
[source lang = "cpp"]
	  for(DWORD i = 0; i < FaceNum; i ++ )
	    {
	    vArray[0] = pVertices[pIndices[i*3+0]].vPosition.x;
            vArray[1] = pVertices[pIndices[i*3+0]].vPosition.y;
            vArray[2] = pVertices[pIndices[i*3+0]].vPosition.z;
            vArray[3] = pVertices[pIndices[i*3+1]].vPosition.x;
            vArray[4] = pVertices[pIndices[i*3+1]].vPosition.y;
            vArray[5] = pVertices[pIndices[i*3+1]].vPosition.z;
	    vArray[6] = pVertices[pIndices[i*3+2]].vPosition.x;
            vArray[7] = pVertices[pIndices[i*3+2]].vPosition.y;
            vArray[8] = pVertices[pIndices[i*3+2]].vPosition.z;

	    }

is it possible at all to acces the VB and IB of a specified subset???? please help

Share this post


Link to post
Share on other sites
Advertisement
You need to access the attribute table of the mesh. Each attribute table entry contains the indices and vertices used by that subset (There's still only one VB and IB). Untested example code:

HRESULT foo(ID3DXBaseMesh* pMesh, DWORD dwSubset)
{
// Get attribute table size
DWORD dwSize = 0;
HRESULT hResult = pMesh->GetAttributeTable(NULL, &dwSize);
if(FAILED(hResult))
return hResult;

// Check subset ID
if(dwSubset >= dwSize)
return E_INVALIDPARAM;

// Allocate and get attributes
D3DXATTRIBUTERANGE* pAttr = new D3DXATTRIBUTERANGE[dwSize];
hResult = pMesh->GetAttributeTable(pAttr, &dwSize);
if(FAILED(hResult))
{
delete[] pAttr;
return hResult;
}

// Get starting vertex and index for this subset
DWORD dwVertexStart = pAttr[dwSubset].VertexStart;
DWORD dwVertexCount = pAttr[dwSubset].VertexCount;
DWORD dwIndexStart = pAttr[dwSubset].FaceStart*3;
DWORD dwIndexCount = pAttr[dwSubset].FaceCount*3;

// Cleanup
delete[] pAttr;
return D3D_OK;
}

Share this post


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

  • Advertisement