   Problem with Collision Detection
  Hello guys, I'm having problem with collision detection :(I have 2 objects, one is a ball and another one is a spaceship.I'm using BoundingSphere to do with the collision...This is code of creating bounding spherebool ComputeBoundingSphere() // return bounding sphere{//pd3dMeshRock is the Ball Mesh//sphere is a struct which contained two members (center and radius)HRESULT hr = 0;BYTE* v = 0;pd3dMeshRock->LockVertexBuffer(0, (void**)&v);hr = D3DXComputeBoundingSphere( (D3DXVECTOR3*)v, pd3dMeshRock->GetNumVertices(), D3DXGetFVFVertexSize(pd3dMeshRock->GetFVF()), &sphere->center, &sphere->radius);pd3dMeshRock->UnlockVertexBuffer();if( FAILED(hr) )return false;return true;}bool CheckCollision(D3DXVECTOR3 pos, D3DXVECTOR3 pos2, float radius, float radius2){   //pos = spaceship position   //pos2 = ball position   //radius = spaceship bounding sphere's radius   //radius2 = ball bounding sphere's radiusfloat dx = pos.x - pos2.x;float dy = pos.y - pos2.y;float dz = pos.z - pos2.z;float distance = sqrt(dx*dx + dy*dy + dz*dz);if( (radius + radius2) >= distance){ return true;}return false;}With the code above, I cannot get the accurate collision between the ball and spaceship.I tried to scale down the size of spaceship and collide with the ball again, and I found out that the boundingsphere of spaceship seems like never change eventhough it has been scaled down.Seeking for help :(Hope to get some replies here.   
  Make sure you have both spheres defined in same space(world or object) before testing.   ;  I've defined and I've found out that the result of using the computing bounding sphere is not accurate :(It has covered some extra spaces around the object...Anyway I can do to get a more accurate bounding sphere?;  Are you sure pos1 and pos2 are the sphere centre you're getting from the compute bounding sphere function? How are you scaling your sphere?   ;  You could use bounding ellipsoid calculated from objects AABB. It is more accurate.   ;  Ya I think the pos and pos2 are the center of the bounding spherevoid getCenter(D3DXVECTOR3& targetCenter){targetCenter = sphere->center;}D3DXVECTOR3 spaceshipPos, rockPos;float spaceshipRadius, rockRadius;spaceship->getCenter(spaceshipPos);rock->getCenter(rockPos);spaceshipRadius = spaceship->getRadius();rockRadius = rock->getRadius();bool collided = CheckCollision(spaceshipPos, rockPos, spaceshipRadius, rockRadius);bool CheckCollision(D3DXVECTOR3 pos, D3DXVECTOR3 pos2, float radius, float radius2){float dx = pos.x - pos2.x;float dy = pos.y - pos2.y;float dz = pos.z - pos2.z;float distance = sqrt(dx*dx + dy*dy + dz*dz);if( (radius + radius2) >= distance){return true;}return false;};  That seems right. If you are scaling right and you find the accuracy not good enough you could do what SIIYA said or you could make multiple bounding spheres that represent a more accurate shape of your model.   ;  Also, you should probably use the built in DirectX math function D3DXVec3Length(). Their math will be faster and looks nicer. =)   ;  >.<..i still cannot figure out what happens to the collisionNow after I've change the center to the bounding sphere's center, the collision become even worst.. even the two objects didnt touch each other but it treated as collided >.<.Anyone know what might cause this to happen?   ;  The code above should work unless sphere positions are defined in their respective object space. Try transforming both positions with objects world position matrices before testing.   