Skip to main content
gamedev.net
🔒 Locked

Polygon Intersection

Started by LarrxX Sep 10, 2003 at 8:43 AM 4 replies 550+ views
Original Post
LarrxX
LarrxX
I''m not sure this is an openGL question but here goes: I''m drawing triangles (and only triangles) on the surface of a given 3D object. Sometimes, these triangles overlap. Is there a way to find the overlapping areas and draw them only once? I know this means breaking down the triangles and I don''t mind. I''d prefer if it were possible to use only triangles in the result but it''s not imperative.
LarrxX
LarrxX
It might be both. But I managed to get rid of the triangles that are "parallell and occupy the same space". It''s the intersecting ones that are giving me problems. Sorry for being so vague.
benjamin bunny
benjamin bunny
Perhaps I misunderstand you, but why are the intersecting triangles giving you problems? Unless you need a closed mesh for some reason, Z buffered rendering should take care of them nicely.

If you''re saying it looks wrong, perhaps a screenshot would help.
LarrxX
LarrxX
Here''s a detailed explanation of what I''m doing. I''ve got a 3D object and I want to add some "logical" information to parts of its surface (nothing to do with openGL, this information is used by an AI engine). So anyway, I use a "click and drag" selection to select a "square" on the surface of the objectusing the feedback buffer; so far so good. Now if I want to add another "square" that intersects the first one I get twice the info of the intersected part and I don''t want that. The way it looks is great, but it doesn''t look like it''s drawn, if you see what I mean.

Let me try and explain by example. If I select a perfect square with bottom left (1,1) and top right (3,3). The feedback buffer tells me there are 2 triangles (1,1)(1,3)(3,3) and (1,1)(3,1)(3,3). Now if I add to my selection another perfect square from (2,2) to (4,4) I get 2 new triangles (2,2)(2,4)(4,4) and (2,2)(4,2)(4,4). So now I have 4 overlapping triangles in my selection. But what I would like to have are, for example:
(1,1)(1,3)(3,3)
(1,1)(3,1)(3,3)
(3,2)(4,2)(3,3)
(4,2)(3,3)(4,4)
(4,4)(3,3)(2,4)
(2,4)(2,3)(3,3)

Sorry about all this, but I don''t have a personal webpage where I can post images. And, as I said, this is definitely not an openGL question but I really dont know where else to post this since I think this must be a common problem (and it apears it''s not...)
benjamin bunny
benjamin bunny
Ok, I think I follow you: you want to retesselate the mesh where it intersects your selection squares in eye space, and then retreive the triangles which are within the squares. It''s definitely not a question I''ve seen before.

I''m not sure about multiple squares (which may be non-convex, and therefore harder), but you could split the triangles for a single square by treating the four lines as planes which run outwards from the eyepoint to form a frustum. Then, for each plane, you could you could split each triangle whose lines intersect the plane. The intersection point can be found like this.

You could do this for each selection square.

Finally you could build a list of of the triangles which fall within all four plane equations by plugging their points into each plane and selecting triangles which are inside each plane.

Hope that helps. I''m moving this to graphics programming and theory, so someone else might be able to help you there.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.