PDA

View Full Version : Clipping portal polygon by Frustum



Gtps
10-18-2003, 10:18 AM
Hi

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.

Humus
10-19-2003, 03: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).]

Gtps
10-19-2003, 06: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.

Gtps

JotDot
10-19-2003, 07: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.

Gtps
10-19-2003, 09:45 AM
JotDot

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?

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

Gtps
10-19-2003, 10: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;

poly_in->split(frstm_planes[0],back,front);

// 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

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