@Goz

I work out my view frustum by multiplying the view and projection matrices together and extracting the planes as follows.

Shouldn’t that be the inverse view and projection matrices?

In normalized screen space (i.e. right after the projection matrix), frustum corners are (1, 1, 1, 1), (-1, 1, 1, 1), (1, -1, 1, 1), (-1, -1, 1, 1), (1, 1, -1, 1), (-1, 1, -1, 1), (1, -1, -1, 1), (-1, -1, -1, 1) (*). So back-transforming them by first multiplying with the inverse projection matrix, then the inverse view matrix, gives the frustum corners in world space. Divide x, y, z by w. You can then use them to construct frustum planes, which requires a cross and dot product (and care for orientation). Maybe it can be simplified a lot, but your approach seems a little too simple at first look.

Your clipping algorithm is also a bit odd. I basically do it like this:

```
Vector T[16]; // Newly clipped polygon
int t = 0;
for(int i = 0; i < numVertices; i++)
{
int j = i == numVertices - 1 ? 0 : i + 1; // Next vertex index
float di = plane.distance(V[i]);
float dj = plane.distance(V[j]);
if(di >= 0) // Inside
{
T[t++] = V[i];
if(dj < 0) // Outside
{
T[t++] = V[i] + di / (di - dj) * (V[j] - V[i]);
}
}
else
{
if(dj > 0) // Inside
{
T[t++] = V[i] + di / (di - dj) * (V[j] - V[i]);
}
}
}
```

I hope this helps. If not, try to systematically verify every step. This is a little too much code to verify at once. Try to visualize the frustum planes. Try clipping with a very simple plane and a very simple polygon and verify every coordinate.

Good luck!

(*) OpenGL conventions

Hi all!

Im suffering from complete mind failure at the moment and am trying to figure out what is going wrong with my 3D clipping system of quads. I am clipping against a frustum completely in world space. I work out my view frustum by multiplying the view and projection matrices together and extracting the planes as follows.

I call the clipping as follows …

At which point my stack should contain a tri-fan that is ready for rendering. My clip function is

Im convinced the mistake im making is simple but i just cannot spot what i am doing wrong. Anyone got any ideas?

PS: I know its a bit crap posting up my code but my mind is really not working very well on this. Any ideas will be much appreciated!