I have a LPD3DXMESH called g_pMesh.

I want to find the distance from the local origin of this mesh to its farthest out vertex. (to use as a very simple bounding radius from the local origin)

I was hoping I could use the D3DXComputeBoundingSphere function in a similar way to this in my Mesh class:

But I don't know how to get the starting position. I think i need to dereference the address of the pointer to the vertex buffer one or two times.Code://put bounding radius in this float void Mesh::getBoundingRadius(float* pBoundingRadius){ D3DXVECTOR3 center;//holds the computed center LPDIRECT3DVERTEXBUFFER9* ppVB=NULL;//address of pointer to vertex buffer g_pMesh->GetVertexBuffer(ppVB);//get the address //compute bounding radius D3DXComputeBoundingSphere( (D3DXVECTOR3 *)(ppVB), //convert to pointer to vector g_pMesh->GetNumVertices(), g_pMesh->GetNumBytesPerVertex(), ¢er, pBoundingRadius ); //add the largest (absolute value) component of the center vector to the radius so the center can be the local origin and the radius will encompass entire mesh *pBoundingRadius+=max(max(abs(center.x),abs(center.y)),abs(center.z)); }

How can I get this to work and is there an easier/better way to do this?

Thanks!