Subtract from triangulated polygon
Monkey Forums/Monkey Programming/Subtract from triangulated polygon
| ||
I'm drawing a bunch of triangles inside an area(polygon) by using this code: http://www.monkey-x.com/Community/posts.php?topic=7911 But now I want to place smaller areas inside the big areas and have the triangles avoid those smaller areas. Basically a CSG Subtract function I guess. I couldn't find anything like that here on the forums, does anyone have any code like that laying around? Or is anyone willing to help me out with some examples? I've had a look around online, but math really isn't my strong side I'm afraid. |
| ||
There are some CSG examples on the BlitzBasic web site. These are good, at least if you have Blitz3D to test in: http://www.blitzbasic.com/codearcs/codearcs.php?code=560 http://www.blitzbasic.com/codearcs/codearcs.php?code=2418 (change CSG_FILL to CSG_CARVE in the demo to cut shapes out) ... but the algorithms would presumably work the same without Blitz3D, provided you replace any access to triangles/surfaces, etc, with your own. |
| ||
Thank you. However, I don't have Blitz3D and these seem to be mostly for 3D usage while I'm just using simple 2D... Seems tricky to convert it! |
| ||
Assuming you haven't figured this out; you can get Blitz3D and BlitzPlus for free now. They're open source, so you can either compile them yourself, or use a pre-built version. Go here, then scroll down to "Blitz3D", and read what it says. |
| ||
Here you go: http://www.monkey-x.com/Community/posts.php?topic=8035&post=83369&view=all#83369 |
| ||
Wow sweet Difference! How do I actually make a "hole" though? |