PDA

View Full Version : Interaction of 2 Shapes

Arunes
06-15-2009, 05:15 AM
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

http://img10.imageshack.us/img10/60/shapex.jpg (http://img10.imageshack.us/i/shapex.jpg/)

i really appreciate and thank for your help in advance

todayman
06-15-2009, 08:15 AM
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.

dletozeun
06-15-2009, 08:39 AM
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?

Arunes
06-15-2009, 10:55 AM
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..

dletozeun
06-16-2009, 03:38 AM
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.