Jump to content
  • Advertisement

Archived

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

steg

D3DXComputeBoundingSphere

This topic is 6105 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, I was wondering if someone could give an example of this method. I''m using one big''ish vertex buffer which contains vertices for a couple of objects - so when passing NumVertices across to this method do I still pass the whole size of the vertex buffer or the amount for the object within this vertex buffer ? example : D3DXComputeBoundingSphere(&myVertexBuffer[index], numVerticesForObject,FVF,pCenter,pRadius); index is an offset into vertex buffer for object in question and numVertices is for that object (not the whole buffer). Kind reg''ds, sTeVe

Share this post


Link to post
Share on other sites
Advertisement
hi! this is copied from my source and it works fine...

// compute radius and box
if( m_pSysMemMesh )
{
hr = m_pSysMemMesh->LockVertexBuffer( D3DLOCK_READONLY, &Data );

if( SUCCEEDED(hr) )
{
D3DXComputeBoundingSphere(
Data,
m_pSysMemMesh->GetNumVertices(),
m_pSysMemMesh->GetFVF(),
&m_vCenter,
&m_fRadius);

D3DXComputeBoundingBox(
Data,
m_pSysMemMesh->GetNumVertices(),
m_pSysMemMesh->GetFVF(),
&m_vBoxMin,
&m_vBoxMax);

m_pSysMemMesh->UnlockVertexBuffer();
}

}

Share this post


Link to post
Share on other sites
Thanks,

But what I want to know is if I have one vertex buffer containing many objects what do I pass for the vertex size, all the buffer OR size of vertices for the particular object.

I take it this method stores the maximum radius size and works it out as doing :

radius = sqrt(x*x + y*y + z*z);

where x,y,z are vertices of the object ?

Kind regards,
sTeVe

Share this post


Link to post
Share on other sites
If you want to know the bounding sphere for a singe object, you have to pass the vertex data for that object only. Thus all the vertices must be in a continous block and you just have to pass the number of vertices for the object.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!