1
Graphics / Re: LineStrip VertexArray and ConvexShape problem
« on: February 16, 2024, 06:30:36 pm »I have almost finished my polygon class. Actually, when I first looked at the ear clipping code in SelbaWard, I didn't understand anything. However, after watching the video in the link above, I realized how simple it actually is, and I tried to code it myself. The result was quite successful, and now I can draw shapes using both ear clipping and scanline algorithms. However, when the edges of the polygon overlap, the expected result is not achieved when drawn with ear clipping. In such cases, I have a few shapes where I compare the results of drawing with ear clipping and scanline algorithms. For example, when I try to draw some shapes with ear clipping, due to the overlapping edges, I exit the loop without fully filling the shape. I also checked if overlapping edges can be drawn with the scanline algorithm, but even though the scanline fills the interior most of the time, there can still be minor glitches. Additionally, I thought it would be silly to draw a simple square with the scanline, so adding ear clipping seemed quite logical, and now both of them work (except for the exceptions I mentioned). Furthermore, I have shared some visuals below regarding this matter. For instance, when you want to draw a crescent shape, you don't need to send 30-40 points to the polygon. I achieved this with just 3 points. To explain how it works, only 3 key points are sent, which determine the real identity of the polygon. Between these points, arcs are drawn at the angle you specify, and by sending only 3 points, we can draw based on the angles of the arcs between these 3 points. Features like this can be added, and instead of asking the user to reverse the corners based on whether they are clockwise or not, the polygon should calculate it based on the points sent. For example, if your calculations work counterclockwise, then let there be a function that calculates this, and if your calculations work counterclockwise and the polygon is calculated clockwise, then you can reverse the corners. Allowing the user to do this might result in a runtime error for novice coders like me. Other than that, that's all I have to say. I'll be closely following your developments.
https://drive.google.com/file/d/1FdalzQlJhhzCmc5OnFjEc7UAzxvsNkfg/view?usp=sharing
"Here is the visual representation. The shapes in the top row are drawn with the ear clipping algorithm, while the shapes in the bottom row are drawn with the scanline algorithm. The shapes are exactly the same; the only difference is the drawing methods. Take a close look at the differences between them."