www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - Earcut polygon triangulation

reply Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= <aferust gmail.com> writes:
For those who are interested in game programming, geospatial 
things, 2D graphics etc. Earcut is a polygon triangulation 
library originally written in js and ported to almost every 
popular language (except D). I was playing around with my hobby 
sdl game and needed to draw some concave polygons. So, I have 
just ported the lib (suitable for betterC). My initial tests 
showed that it is fast that can be used for real-time rendering. 
If you have a function that can draw triangles, you can draw 
concave/convex any polygon which can also have holes.

https://github.com/mapbox/earcut.hpp
https://github.com/aferust/earcut-d
Feb 23 2020
parent reply Ahmet Sait <nightmarex1337 hotmail.com> writes:
On Sunday, 23 February 2020 at 10:07:44 UTC, Ferhat Kurtulmuş 
wrote:
 For those who are interested in game programming, geospatial 
 things, 2D graphics etc. Earcut is a polygon triangulation 
 library originally written in js and ported to almost every 
 popular language (except D). I was playing around with my hobby 
 sdl game and needed to draw some concave polygons. So, I have 
 just ported the lib (suitable for betterC). My initial tests 
 showed that it is fast that can be used for real-time 
 rendering. If you have a function that can draw triangles, you 
 can draw concave/convex any polygon which can also have holes.

 https://github.com/mapbox/earcut.hpp
 https://github.com/aferust/earcut-d
Out of curiosity, why would you need to triangulate polygons instead of using stencil buffer? I'm assuming you're using OpenGL (or something similar) since you talked about your hobby game. Any advantage of triangulating shapes? (anti-aliasing maybe?)
Feb 23 2020
next sibling parent Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= <aferust gmail.com> writes:
On Sunday, 23 February 2020 at 16:20:09 UTC, Ahmet Sait wrote:
 On Sunday, 23 February 2020 at 10:07:44 UTC, Ferhat Kurtulmuş 
 wrote:
 For those who are interested in game programming, geospatial 
 things, 2D graphics etc. Earcut is a polygon triangulation 
 library originally written in js and ported to almost every 
 popular language (except D). I was playing around with my 
 hobby sdl game and needed to draw some concave polygons. So, I 
 have just ported the lib (suitable for betterC). My initial 
 tests showed that it is fast that can be used for real-time 
 rendering. If you have a function that can draw triangles, you 
 can draw concave/convex any polygon which can also have holes.

 https://github.com/mapbox/earcut.hpp
 https://github.com/aferust/earcut-d
Out of curiosity, why would you need to triangulate polygons instead of using stencil buffer? I'm assuming you're using OpenGL (or something similar) since you talked about your hobby game. Any advantage of triangulating shapes? (anti-aliasing maybe?)
I am not using opengl, but just sdl for no reason. I am trying to make a clone of a particular type of game namely wolfied, qix, or gals panic. Actually, I did it using cocos2dx (clipping node does the trick) in js few years ago. But this time I am trying to reclone it using just d and sdl by going bare metal. The ultimate target is running it on the browser maybe using dscripten.
Feb 23 2020
prev sibling parent reply JN <666total wp.pl> writes:
On Sunday, 23 February 2020 at 16:20:09 UTC, Ahmet Sait wrote:
 Out of curiosity, why would you need to triangulate polygons 
 instead of using stencil buffer? I'm assuming you're using 
 OpenGL (or something similar) since you talked about your hobby 
 game. Any advantage of triangulating shapes? (anti-aliasing 
 maybe?)
Triangulation goes beyond rendering. I imagine this library might be useful when making a level editor for a DOOM-like 2.5D engine.
Feb 24 2020
parent reply Ben Jones <fake fake.fake> writes:
On Monday, 24 February 2020 at 19:15:13 UTC, JN wrote:
 On Sunday, 23 February 2020 at 16:20:09 UTC, Ahmet Sait wrote:
 Out of curiosity, why would you need to triangulate polygons 
 instead of using stencil buffer? I'm assuming you're using 
 OpenGL (or something similar) since you talked about your 
 hobby game. Any advantage of triangulating shapes? 
 (anti-aliasing maybe?)
Triangulation goes beyond rendering. I imagine this library might be useful when making a level editor for a DOOM-like 2.5D engine.
It's very poorly documented, but I wrote a delaunay refinement triangulator: https://github.com/benjones/dtriangulate . It's mostly a reimplementation of Shewchuk's Triangle which is probably the most common delaunay triangulator.
Feb 24 2020
parent Andrea Fontana <nospam example.com> writes:
On Monday, 24 February 2020 at 20:28:20 UTC, Ben Jones wrote:
 On Monday, 24 February 2020 at 19:15:13 UTC, JN wrote:
 On Sunday, 23 February 2020 at 16:20:09 UTC, Ahmet Sait wrote:
 Out of curiosity, why would you need to triangulate polygons 
 instead of using stencil buffer? I'm assuming you're using 
 OpenGL (or something similar) since you talked about your 
 hobby game. Any advantage of triangulating shapes? 
 (anti-aliasing maybe?)
Triangulation goes beyond rendering. I imagine this library might be useful when making a level editor for a DOOM-like 2.5D engine.
It's very poorly documented, but I wrote a delaunay refinement triangulator: https://github.com/benjones/dtriangulate . It's mostly a reimplementation of Shewchuk's Triangle which is probably the most common delaunay triangulator.
Both of these libraries would have been useful a year ago when I was writing my 3d printable vases generator in D :)
Feb 25 2020