Advertisement

Frustum generation...

Started by February 09, 2000 04:48 PM
1 comment, last by Tobias 25 years, 1 month ago
Hi, I''m coding a portal engine and everything works fine except generating frustums from the portal polygons. It doesn''t work very well. Just hope someone could help find what''s wrong with my algo. It works something like this:

i = 0; 
j = 1;
 while(i < PortalPoly->NumVertices)
 {
   v1 = Vertices[ Poly.Verts ] - CameraPosition;  //Vertices are world coordinates
   v2 = Vertices[ Poly.Verts[j] ] - CameraPosition;

   Planes[ NumPlanes ].Normal = crossproduct( v1, v2 );
   Planes[ NumPlanes ].Normal.Normalize(); 
   Planes[ NumPlanes ].Dist = - dotproduct( Planes[ NumPlanes ].Normal, CameraPosition );

   i += 1;
   j += 1;
    if( j == PortalPoly->NumVertices )
      j = 0;
   NumPlanes += 1;
}
Greets Tobias
I can see a few potential problems:

You forget to index with i when you''re assigning v1. Or you just forgot to type it here since I doubt the code would compile.

Is PortalPoly supposed to be the same as Poly?

Maybe you get the wrong direction on the normal when computing the crossproduct.
Advertisement
Actually that''s not the code I use, I just rewrote the function to make it more understandable.
But it could be that the planes face the wrong direction,
is there a good way to check that?

BTW, should vertices be in world space when I create the
frustum from them?

Greets Tobias

This topic is closed to new replies.

Advertisement