Joined: Wed Sep 10, 2008 9:06 pmPosts: 22Location: Paris - France
Hi!
Here is a small addon (with example) that wraps triangle c++ wrapper from Piyush Kumar for openframeworks according to the method described by Todd in his blog. It also uses the great PointInsidePolygon function of Theo! You can use these triangles to reproduce your shape in box2d.
Joined: Wed Sep 10, 2008 9:06 pmPosts: 22Location: Paris - France
I think you find the triangulation messy because the debug drawing gives a random color for each triangle on every update. It looks way more stable when you only draw the strokes of the triangles!
I'm not sure about the best way to interpolate the triangles instead of replacing on each update. But if your goal is to use the triangles as rigid bodies for human interactions, it's likely that you want them to be accurate as often as possible!
Joined: Wed Sep 10, 2008 9:06 pmPosts: 22Location: Paris - France
If it's a box2d assertion that make your app crash, it's probably because the points have to be ordered clockwise and the triangles have to fit some requirements :
Quote:
- Edges can't be too close to parallel - Area must be greater than a minimum value - Each edge must be more than b2_toiSlop away from the centroid
I haven't figured yet how to perform these checks but I'll give it a try in the next couple of days!
Joined: Wed Sep 10, 2008 9:06 pmPosts: 22Location: Paris - France
well after doing some researches i found out 2 things :
- first is that plong0 made a similar addon (ofxDelaunay) a couple of months ago that may be faster than the one i posted! - second is that Todd Vanderlin already did all the maths of the polygon requierements in the ofxBox2dPolygon.validateShape() method! so for us, validating a triangle is as easy as :
Joined: Mon Jan 19, 2009 7:02 amPosts: 214Location: sydney
hi kikko,
im trying to run your example but running into problems, think its do with my version of ofxBox2d.
i got the latest from vanderlin's trunk (rev 73) http://code.google.com/p/vanderlin/ and ofxBox2dPolygon is missing the validateShape() method you call in your code. not sure why it has been removed.
so i went back a revision to rev 72 and i was able to compile your code but running into this error,
Quote:
Assertion failed: (m_I > 0.0f), function SetMassFromShapes, file /Volumes/STORAGE/OF_0061/apps/forum/3386_ofxTriangle_box2d/../../../addons/ofxBox2d_rev72/scr/lib/Box2D/Source/Dynamics/b2Body.cpp, line 334. Program received signal: “SIGABRT”.
would you mind posting your version of ofxBox2d you are using for your example?
Users browsing this forum: No registered users and 3 guests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum