Jump to content
  • Advertisement
Sign in to follow this  
Dun

[directX9] Detecting out of screen objects

This topic is 2695 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.

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!