Hi all,

I am having some problems with my frustum class, it cuts out a lot of triangles that are in view and leaves some that are not in view

Heres 2 screenshots, the first is without the frustum culling and the 2nd with:

with in the model rendering i have:

[pascal]

glBegin(GL_TRIANGLES);

For j := 0 To nTriangles-1 Do

Begin

If FRUSTUMCULLING Then

Begin

For k := 0 To 2 Do

With Triangles[TriangleIndices[j]] Do

Tri[k] := Vertices[VertexIndices[k]].Position;

If Not Frustum.TriangleInFrustum(Tri[0], Tri[1], Tri[2]) Then Continue;

End;

[/pascal]

[pascal]

function TxnFrustum.TriangleInFrustum(v1,v2,v3: TVertex3f): Boolean;

begin

Result := (PointInFrustum(v1)) Or (PointInFrustum(v2)) Or (PointInFrustum(v3));

end;

[/pascal]

[pascal]

function TxnFrustum.PointInFrustum(Point: TVertex3f): Boolean;

var

i: Integer;

begin

For i := 0 To 5 Do

Begin

If (fFrustum[i][0]*Point[0]+fFrustum[i][1]*Point[1]+fFrustum[i][2]*Point[2]+fFrustum[i][3] <= 0) Then

Begin

Result := False;

Exit;

End;

End;

Result := True;

end;

[/pascal]

I have probably missed something out (always the way) :s

## Bookmarks