3

I am beginner in Box2D physics engine. As I am having a Image with irregular curves I am trying to develop the polygon. But with the reference of the Raywenderlich demo tutorial using the Vertex Helper I am drawing the Polygon but in many cases it produces the concave polygon and when I am executing my Project it crashes.. So If can get some Help for the usage of the concave polygon it would be great.

Any help or suggestions appreciated. Thanks

Marine
  • 1,097
  • 7
  • 19

1 Answers1

5

@Marine; to use concave polygons you'll need to break it into smaller convex polygons. Just break the concave polygon into different convex polygons at the time of body creation and just create shapes for all those individual convex polygons.

Suran
  • 1,209
  • 1
  • 17
  • 21
  • I have more than 100 images for which it needs to create an individual polygon.... but if it is done so, will it affect the memory in iPod? – Marine Dec 29 '11 at 05:01
  • there won't be any difference on the performance. Actually, you won't be creating any extra bodies. You'll be defining the shape of each body using multiple polygons. To convert concave polygons, you can use an app called physicseditor. Just google the name and you can download a trial version. You could either use physicseditor or create an algorithm to convert concave polygons into convex polygons. – Suran Dec 29 '11 at 08:43
  • I have implemented the Physics Editor Images but in the Simulator it shows the small(scaled) Polygon compared to the image which is used by me. Please Suggest me the way to make bigger(scaled) Polygon..... – Marine Dec 29 '11 at 13:12
  • i didn't get exactly what you meant. Are the polygons taking collision properly, with the corresponding size me objects? Or is it just the drawing that is scaled down? If that is the case, may be you are drawing polygons in debugdraw in meters; ie, without multiplying by ptm_ratio. Try multiplying polygon vertices by ptm_ratio in debugdraw. If the problem persists, explain the problem in detail, if possible with screen shot – Suran Dec 29 '11 at 13:22
  • The Problem is solved now actually it was for the PTM_Ratio to be set while creating the .pist file..... Thanks for suggesting the gorgeous Polygon Maker i.e. Physics Editor. @Suran – Marine Dec 30 '11 at 12:15
  • You're always welcome. Please don't forget to upvote for the answers that you find useful. – Suran Dec 31 '11 at 07:32