Clipping

Started by
3 comments, last by staticVoid2 16 years, 2 months ago
hi, I have a problem to do with clipping and texture mapping, basically I have a function that applies a texture to a triangle using basic interpolation, when I perform transformations on points from world space to view space I clip them to the Z plane, for each face/triangle this can leave me with either another triangle or a quadrangle. If the result is a quadrangle I'm not sure how to split this into another two triangles to pass to the texture function. because i'm using the sutherland hodgman algorithm the result points are stored in an unordered list so I can't determine which are the shared points of the two triangles. Is there a more efficient way of doing this, or in other words how is it normally done?
Advertisement
Quote:the result points are stored in an unordered list so I can't determine which are the shared points of the two triangles.


You can't, because there's nothing to determine. You have created two new triangles from one triangle, so you have to decide what vertex belongs to what triangle. It won't make a difference as long as you make sure that the winding order is correct.
so, when I get this list of 4 vertices, will it just be a case of:

draw triangle list[0] list[1] list[2]
draw traingle list[0] list[3] list[2]

?
Like I said, as long as you make sure that the vertex winding order is correct, it should work, though in your example it seems like the two triangles have different winding orders. I think the second one should be 0, 2, 3, or the first one should be 0, 2, 1, depending on what you consider to be a front facing triangle (i.e., clockwise or counter-clockwise).
thanx.

This topic is closed to new replies.

Advertisement