I converted Mark Bayazit's polygon decomposition algorithm (
http://mnbayazit.com/406/bayazit) to lua and made a quick demo video. It's still got some more work to go (e.g., code is a mess, hangs sometimes, doesn't split polygon's with more than 8 vertices into smaller ones). There are three basic functions in the code:
1. convert the vertices to counter-clockwise
2. simplify the shape (i.e., remove co-linear points and points that are close together)
3. convert the shape to a series of convex polygons
The idea is to be able to convert a hand drawn shape into a box2d set of convex polygons. I'll share the code once it's a little more polished.
Comments
Gives ideas for games, if it is possible to convert polygons to fixtures and use them as physical objects.
Will look forward to that code
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
nice work!
www.tntengine.com
- figure out when user draws an "invalid" shape (a shape where lines cross -- including when the line from the last point to the first point crosses any other lines in the shape)
- split convex polygons w/ large number of points into polygons w/ less than 8 points
Here's what it looks like so far:
Likes: gorkem, atilim
Likes: chipster123, avo
incredible!!
=D>
www.tntengine.com
ndoss' Gideros playground is here...
https://github.com/ndoss/gideros_playground
cheers
evs
cheers
evs
Thanks a lot! =D>