D3DXComputeBoundingSphere
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
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();
}
}
// 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();
}
}
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
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
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement