Advertisement

AABB and Frustum collisions

Started by February 19, 2003 09:54 AM
0 comments, last by DumbBill 22 years ago
Now, I''m not sure if this should be here or in the DirectX bit.. but here goes.. I have started writing a simple engine in DirectX, and I have implemented a basic Octree to use in my scene-graph culling stuff. This all works ok, but I now need to traverse the tree and see if the AABBs of the nodes intersect the view frustum. This I can''t figure. I have a function that (supposedly) extracts the planes of the frustum from a DirectX view matrix, but they are defined as D3DXPlanes (which are 4 floats...) How can I test for collisions between my AABBs and these planes? Help!!! Thanks.
Well, the idea is something like this:

(some changes)
Normal.x = plane.a
Normal.y = plane.b
Normal.z = plane.c
Distancia = plane.d

vMin = D3DXVECTOR3
vMax = D3DXVECTOR3


  for(int i=0; i<6; i++)	{		if(m_Frustrum[i].Normal.x* vMin.x + m_Frustrum[i].Normal.y*vMin.y + m_Frustrum[i].Normal.z*vMin.z + m_Frustrum[i].Distancia > 0)  continue;		if(m_Frustrum[i].Normal.x* vMax.x + m_Frustrum[i].Normal.y*vMin.y + m_Frustrum[i].Normal.z*vMin.z + m_Frustrum[i].Distancia > 0)  continue;		if(m_Frustrum[i].Normal.x* vMin.x + m_Frustrum[i].Normal.y*vMax.y + m_Frustrum[i].Normal.z*vMin.z + m_Frustrum[i].Distancia > 0)  continue;		if(m_Frustrum[i].Normal.x* vMax.x + m_Frustrum[i].Normal.y*vMax.y + m_Frustrum[i].Normal.z*vMin.z + m_Frustrum[i].Distancia > 0)  continue;		if(m_Frustrum[i].Normal.x* vMin.x + m_Frustrum[i].Normal.y*vMin.y + m_Frustrum[i].Normal.z*vMax.z + m_Frustrum[i].Distancia > 0)  continue;		if(m_Frustrum[i].Normal.x* vMax.x + m_Frustrum[i].Normal.y*vMin.y + m_Frustrum[i].Normal.z*vMax.z + m_Frustrum[i].Distancia > 0)  continue;		if(m_Frustrum[i].Normal.x* vMin.x + m_Frustrum[i].Normal.y*vMax.y + m_Frustrum[i].Normal.z*vMax.z + m_Frustrum[i].Distancia > 0)  continue;		if(m_Frustrum[i].Normal.x* vMax.x + m_Frustrum[i].Normal.y*vMax.y + m_Frustrum[i].Normal.z*vMax.z + m_Frustrum[i].Distancia > 0)  continue;		// If we get here, it isn''t in the frustum		return NO_VISIBLE;	}	// Return a true for the box being inside of the frustum	return COMPLETAMENTE_VISIBLE;  


Hope this help
--------------------------------------------- If God with me, Who against me?Personal Web Samuel Prince Blog...

This topic is closed to new replies.

Advertisement