 # Interaction of 2 Shapes

hi all,

i follow rhe forum for a long time… and now i have a problem and unfortunataly i couldn’t find the solution.
i’d be really glad if someones could help me find out how i can solve that problem.

i will try to explain it by the picture

• The A part is the initial situation of the progress and i have 4 vertices at that moment

• The B part is the progress that i wanna make it real. While the triangle goes through the square i want to get the progress to be like exactly in the part B OpenGL doesn’t work (at least, isn’t guaranteed to work) for concave polygons (dented, like B). So you need to break it up into different pieces. I would draw a rectangle, or two triangles, from edge 7 to edge 9, and from edge 2 to edge 9. I would draw another rectangle from edge 9 to the vertex where 4 and 5 meet, then fill in the remaining area, along edges 4 and 5 with triangles.

As the triangle moves through shape A, move the triangles along edges 4 and 5 and shrink the rectangle there.

The B part is the progress that i wanna make it real. While the triangle goes through the square i want to get the progress to be like exactly in the part B

Perhaps, the solution is not to draw a complex polygon but clear a part of the quad using some tricks like alpha or stencil test.

Can tell us a bit more about what you intend to do?

first of all thank you for your replies…

the thing i wanna do is making a real time interaction progress. the interaction will be executed in 2D. so after interaction the square will get the shape of triangle.
u can think that progress as a sculpting… i wanna sculpt the Square with Triangle. so whenever square and triangle interact… the triangle will change the shape of square…
when the prosess has complited i must to know every vertexes the new shape has…

Ok, for rendering I advise you to use stencil tests. To find all shape vertices, I think you will have to compute intersections between the triangle and your shape but you do not need to use all generated vertices for rendering, stencil buffer is enough and very easy to use.