Jump to content
  • Advertisement


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


DX9 - D3DXComputeBoundingSphere?

This topic is 5836 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

I''m trying to convert an engine from DX8.1 to DX9 and one thing has got me STUMPED. Te D3DXComputeBoundingSphere() function has changed in DX9 and is now defined as follows: HRESULT D3DXComputeBoundingSphere( LPD3DXVECTOR3 pFirstPosition, DWORD NumVertices, DWORD dwStride, D3DXVECTOR3 *pCenter, FLOAT *pRadius ); In DX8, the first parameter was the actual vertices of the mesh. Now, in DX9, I''m not at all sure what the first parameter means, nor how to feed the function the actual mesh vertices (since it''s no longer a parameter). Can ANYONE please HELP!! Tony

Share this post

Link to post
Share on other sites

When an API appears to change, do a Find In Files on the samples which come with the SDK to see how to use the changed function.

Doing that and looking at the EnhancedMesh sample found as a result of the search reveals:

hr = pVB->Lock( 0, 0, &pVertices, 0 );
if( FAILED(hr) )
return hr;

hr = D3DXComputeBoundingSphere( (D3DXVECTOR3*)pVertices, m_pMeshSysMem->GetNumVertices(),
D3DXGetFVFVertexSize(m_pMeshSysMem->GetFVF()), &m_vObjectCenter,
&m_fObjectRadius );

i.e. all they''ve done is made it a tad more type safe so that the compiler will catch silly mistakes which it wouldn''t have with a (nasty) void pointer in DX8.

So basically just point it to the first "position" vector in the vertex data (in the code snippet above, the vertex format has positions first in each vertex so the start of the locked VB data is passed).

Simon O''Connor
Creative Asylum Ltd

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!