HIDIHO!

giving something back to the Flash community

concave polygon > box2D

Tags: , , , , , ,

cover

now here’s a little demo of what the ear cutting algorithm can do


to use a shape inside Box2D it has to be convex.
the ggod thing with triangles is that they are convex.
and the good thing with triangulation is that it turns a concave object into a series of convex objects….
still following ?
right ! this is the purpose of the ear cutting algorithm :)

which means that you can start integrating (easily) free shapes into Box2D which is good news :D
now here’s a (not that ground breaking) demo to show the thing with one of the shapes from the other article:

Ok, so first, there are still atrefacts due to the weakness of the shapes (some balls can penetrate the shape). That comes from the triangulation which is not homogeneous enough. I’m thinking of a more clever algorithm to do that.

Second I probaly misunderstood something on how to configure the restitution factor of the bodies… or maybe the balls are too small… maybe you should try the bulletMode too …. well there might be something to fix between the keyboard and the chair.

Third, the amount of shapes has to stay very low ( I tried it with the horse model and the player crashed badly). I know there’s a limit to the number of the shapes you can create within a body. I should check that some day.

And Fourth, triangle is not the best shape, actually by default you can create an 8 vertices shape and if change some Box2D classes, you can go up to 64 vertices per shape( which is too heavy for the engine, trust me I tried). so next step is to find a better way to chop the poly.

Anyway as such, it can be nice to use for a terrain or a landscape because creating such a complex object out of boxes might be a real hassle ;)
have fun :)

Tags: , , , , , ,

© 2009 HIDIHO!. All Rights Reserved.

This blog is powered by Wordpress and Magatheme by Bryan Helmig.