2008/11/13 paulo lesgaz jeremielapuree@yahoo.fr:
Hello
I would like to implement ComputeSphereVisibility. The sting game is completely black because of this stubbed function. Here is my idea to implement it. Am I in the good way, or it is completely a bad idea?
With GetViewport, I retrieve the viewport matrix V, and with GetTransform, I retrieve projection P and world W matrices ofn the device.
I multiply the three matrices in a matrice M: M=VPW
If M is singular, function returns with a failing message Otherwise, with the matrix M I retrieve the planes of the frustum view (that's a little bit of math, but quite easy)
Then for each sphere,
Let Visibility=0 for each plane of the frustum view Let I be the intersection of the orthogonal projection of the center sphere on the plane. If I is in the frustum view, then I have the visibility.So Visibility=Visibility|(flag for the visibility of the chosen plane)
Once I did it for the 6 plane, I have the visibility of the sphere.
Is it a good point of start?
David
The basic idea sounds about right. I don't think you need to project the sphere onto the frustum planes, just using the plane normal to calculate the distance to the sphere center should do.