View Full Version : Clipping portal polygon by Frustum

10-18-2003, 11:18 AM

I have a problem, i need clip portal polygon by Frustum. Anybody have a function as this does?

I understand this technology, but I need function for practical.

in Style

bool ClipPolygonByFrustum(Vector3D *polygon_in,Vector3D *polygon_out, Planes *frstm_planes);

Vector3D *polygon_out - must be new polygon.

Help me please anybody.

Sorry for my English.

10-19-2003, 04:35 AM
On my website, http://esprit.campus.luth.se/~humus/ , there's a file called Framework.zip, download it and find the Polygon.cpp file. In there I have code which cuts Polygons against a plane. I suppose it could be useful for you.

[This message has been edited by Humus (edited 10-19-2003).]

10-19-2003, 07:07 AM
Thank you Humus

class Polygon, which I have found in your Framework, very good.

I have found in this class Polygon::split() function.

Can you help me, create function ClipPolygonFromFrustum with your function Polygon::split().

I need clip polygon on each side of frustum.
If you worked with portal, then you must know how cut polygon of portal by camera frustum.

for example:

void ClipPolygonFromFrustum(Polygon *poly_in, Polygon *poly_out, Plane *frustum_planes);

But how do it, i don't know.
Please if you know how do it, help me.

thank you in advance.


10-19-2003, 08:17 AM
Have you tried looking on the web for articles on Sutherland-Hodgeman clipping? This is a common method used to clip polygons against a plane and is fairly easy to code.

10-19-2003, 10:45 AM

This algorithm to me and needs. I searched for on this subject, but nothing necessary has not found. Could you give me some links, On this subject?

10-19-2003, 07:57 PM
An example http://hpcc.engin.umich.edu/CFD/users/charlton/Thesis/html/node90.html

10-19-2003, 11:42 PM
thanks roffe

Here is that I have:

function Polygon::split from Humus FrameWork
which separates polygon on plan on two parts

now pseudo-code:

void ClipPolygonByFrustum(Polygon *poly_in,Polygon *poly_out, Plane *frstm_planes)

Polygon *front;
Polygon *back;


// Now I have two polygons
// What polygon it is necessary to use
// for next plane.
// front or back?


Sorry for my english

I hope you understand me

10-20-2003, 04:49 AM
front is the polygon on the side the normal points to.