• Advertisement

Archived

This topic is now archived and is closed to further replies.

Frustum generation...

This topic is 6554 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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;
}
[/CODE]
Greets Tobias     

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement