Jump to content
  • Advertisement
Sign in to follow this  
Dun

[directX9] Detecting out of screen objects

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

Hello, i am trying to detect objects out of screen, but i am not sure how to compute bounding sphere of current object. When i use this code, i get bounding radius 1.4 on object rectangle of size 2*2. How it is possible? Is this code wrong?


VOID *pData = NULL;
D3DXVECTOR3 center;
m_pObjectVB->Lock(0,m_pObject->Size(),(void**)&pData,0); //m_pObjectVB is type LPDIRECT3DVERTEXBUFFER9
D3DXComputeBoundingSphere((D3DXVECTOR3*)pData,m_pObject->m_iVertexCount, sizeof(SMSD3DVertex), &center, &m_sphereRadius);
m_pObjectVB->Unlock();

Share this post


Link to post
Share on other sites
Advertisement
1.4 is correct as it's approx. the square root of 2, which - according to an old Greek bloke who lived a coupla thousand years ago - is the formula you need for this.

Share this post


Link to post
Share on other sites
You have a 2x2 rectangle, with the centre at (1,1). So the furthest point from there is one of the corners, which is sqrt(1*1 + 1*1) = ~1.414.

Share this post


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

  • 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!