Only problem with that sample is that it uses a very slow method of frustum culling. It does something like transforming a box for each object, then checking all eight vertices of the box against the view frustum and determines if it's intersecting an edge, a face, is in, or out, etc. Add to that it's very messily coded and hard to follow.
I use a routine to test if a sphere is outside teh view frustum. It takes the View*Projection matrix, the world X, Y, and Z position of the sphere and the radius of the sphere. It returns a True if the object is outside the frustum and a False if it's inside the frustum (sounds backwards, but there's a reason). The only thing is that it tests only the left, right, top, and bottom for speed.. any objects that would be culled by the near plane are taken care of by left and right, and the far plane isn't tested at all. If you'd like, I could give you the code to test the near and far planes as well.
Here it is translated to VB (to the best of my ability.. I have no idea how most things are defined in VB, and don't know how D3DXMATRIX is laid out especially):
Sub cullSphereToViewFrustum(ByRef MatViewProj as D3DXMATRIX, x As Float, y As Float, z As Float, radius As Float) As Boolean Dim p As D3DXPLANE radius=-radius 'left plane p.a=MatViewProj.m(0,3)+MatViewProj.m(0,0) p.b=MatViewProj.m(1,3)+MatViewProj.m(1,0) p.c=MatViewProj.m(2,3)+MatViewProj.m(2,0) p.d=MatViewProj.m(3,3)+MatViewProj.m(3,0) D3DXPlaneNormalize p,p If ((p.a*x)+(p.b*y)+(p.c*z)+p.d)<=radius Return True 'right plane p.a=MatViewProj.m(0,3)-MatViewProj.m(0,0) p.b=MatViewProj.m(1,3)-MatViewProj.m(1,0) p.c=MatViewProj.m(2,3)-MatViewProj.m(2,0) p.d=MatViewProj.m(3,3)-MatViewProj.m(3,0) D3DXPlaneNormalize p,p If ((p.a*x)+(p.b*y)+(p.c*z)+p.d)<=radius Return True 'top plane p.a=MatViewProj.m(0,3)-MatViewProj.m(0,1) p.b=MatViewProj.m(1,3)-MatViewProj.m(1,1) p.c=MatViewProj.m(2,3)-MatViewProj.m(2,1) p.d=MatViewProj.m(3,3)-MatViewProj.m(3,1) D3DXPlaneNormalize p,p If ((p.a*x)+(p.b*y)+(p.c*z)+p.d)<=radius Return True 'bottom plane p.a=MatViewProj.m(0,3)+MatViewProj.m(0,1) p.b=MatViewProj.m(1,3)+MatViewProj.m(1,1) p.c=MatViewProj.m(2,3)+MatViewProj.m(2,1) p.d=MatViewProj.m(3,3)+MatViewProj.m(3,1) D3DXPlaneNormalize p,p If ((p.a*x)+(p.b*y)+(p.c*z)+p.d)<=radius Return True Return FalseEnd Sub
If you just want to test a single vertex, here's the function modified to just test the X, Y, and Z without the radius:
Sub cullSphereToViewFrustum(ByRef MatViewProj as D3DXMATRIX, x As Float, y As Float, z As Float) As Boolean Dim p As D3DXPLANE 'left plane p.a=MatViewProj.m(0,3)+MatViewProj.m(0,0) p.b=MatViewProj.m(1,3)+MatViewProj.m(1,0) p.c=MatViewProj.m(2,3)+MatViewProj.m(2,0) p.d=MatViewProj.m(3,3)+MatViewProj.m(3,0) D3DXPlaneNormalize p,p If ((p.a*x)+(p.b*y)+(p.c*z)+p.d)<=0 Return True 'right plane p.a=MatViewProj.m(0,3)-MatViewProj.m(0,0) p.b=MatViewProj.m(1,3)-MatViewProj.m(1,0) p.c=MatViewProj.m(2,3)-MatViewProj.m(2,0) p.d=MatViewProj.m(3,3)-MatViewProj.m(3,0) D3DXPlaneNormalize p,p If ((p.a*x)+(p.b*y)+(p.c*z)+p.d)<=0 Return True 'top plane p.a=MatViewProj.m(0,3)-MatViewProj.m(0,1) p.b=MatViewProj.m(1,3)-MatViewProj.m(1,1) p.c=MatViewProj.m(2,3)-MatViewProj.m(2,1) p.d=MatViewProj.m(3,3)-MatViewProj.m(3,1) D3DXPlaneNormalize p,p If ((p.a*x)+(p.b*y)+(p.c*z)+p.d)<=0 Return True 'bottom plane p.a=MatViewProj.m(0,3)+MatViewProj.m(0,1) p.b=MatViewProj.m(1,3)+MatViewProj.m(1,1) p.c=MatViewProj.m(2,3)+MatViewProj.m(2,1) p.d=MatViewProj.m(3,3)+MatViewProj.m(3,1) D3DXPlaneNormalize p,p If ((p.a*x)+(p.b*y)+(p.c*z)+p.d)<=0 Return True Return FalseEnd Sub
Hope that helps.
_______________________________________________________________________Hoo-rah.