Problem with frustum-culling and scaling

Hi,

I have a problem with the implementation of a linear-scaled
frustum-culling method (means: without quad-tree or something like that).
I have followed the implementation shown at http://www.flipcode.com/articles/article_frustumculling.shtml.
There is a paper mentioned on how to extract the frustum out of the
modelview and projection matrices
(http://www2.ravensoft.com/users/ggribb/plane%20extraction.pdf)
which I have also read and implemented.

The odd thing is, that the objects (trees) which I want to cull are
culled “to early” as if the far pane has wandered nearer towards the
camera-position. I could trace the error to the computation of the
far-clipping pane in my code. If I divide it by the scaling-factor
for the trees then the culling works fine.


An excerpt from my source-code is as follows:

void RenderGLScene()
{
// …
glPushMatrix();

// scale the map
glScalef(20,20,20);
// translate the map
glTranslatef(-HEIGHTMAPSIZE/2,0,HEIGHTMAPSIZE/2);
// render the map
renderHeightMap();
// render the trees on it which are completely billboarded
renderTreeMap();

glPopMatrix();
}

void renderTreeMap()
{
// compute the combined modelview (M) and projection (p) matrix
// M x P = comboMatrix in model-space

// exactly the function from the mentioned paper
extractFrustum(…, comboMatrix, …);

// check wether the point is in the frustum or not
}

void extractFrustum(…, comboMatrix, …)
{
// Far clipping plane
// this must be divided by the scaling-factor to get it right…

p[5].a = comboMatrix._41 - comboMatrix._31 / 20;
p[5].b = comboMatrix._42 - comboMatrix._32 / 20;
p[5].c = comboMatrix._43 - comboMatrix._33 / 20;
p[5].d = comboMatrix._44 - comboMatrix._34 / 20;

}


The matrices look like that:

pre-scaled: M = | 1 0 0 0 |
| 0 1 0 0 |
| 0 0 1 0 |
| 0 0 -10 0 |

     P = | 1.5  0  0  0 |
	 |  0  2.4 0  0 |
	 |  0   0  -1 -1|
	 |  0   0 -0.2 0|

post-scaled: M’= | 20 0 0 0|
| 0 20 0 0|
| 0 0 20 0|
| 0 0 -10 0|

     P' = P

A top-down view of the clipping-frustum

should be:
-------- F
| |
| |
| |
– N

is:

------ F
|    |
 |  |
  --   N

The higher the scaling factor the “nearer” the far-clipping pane…

Is there a way on how to solve this problem without needing to divide
by the scaling factor?

Thank you in advance

PS: Sorry for this rather long posting…