Using Box2D for pixel perfect overlap test between pictures

Discuss issues specific to the Flash/AS3 port of Box2D
Posts: 8
Joined: Fri Jan 15, 2010 6:08 am

Using Box2D for pixel perfect overlap test between pictures

Postby xraven13 » Fri Jun 18, 2010 1:26 am

Hi everyone.. I will divide my question into small parts so that is easier to reply :

1) I wanted to ask is there a way to test pixel perfect overlap using BOX2D between 2 images of any shape, offset, origin etc..
HitTest variatons are really slow so i was thinking is there a way to use Box2D only for that ?

2) Since in that case i wouldn't need any actualy pyshics , but bodies should follow the pictures instead, what would the best way to do it ?

3) Since i can access pixels of bitmap data i was thinking to make a body for each pixel that is not transparent and then somehow group them... Is there a way to group them so that they are fixed and grouped together forever.. And did someone made already something like this ? Obviously i could make a algorithm that would make biggest rectangles as possible so not all bodies would be 1x1 size.. Not sure how i would make them same size since Box2D uses meters, i guess simple conversion would do it huh...

4) Ok this question is similar to 3), but much more simple ( and a little different though) . Did someone make a function that transforms picture of any shape ( or at least some ) into Box2D body ?

Thanks in advance

Posts: 1911
Joined: Mon Jan 07, 2008 10:51 am

Re: Using Box2D for pixel perfect overlap test between pictu

Postby BorisTheBrave » Fri Jun 18, 2010 10:28 am

Box2D has no support for arbitrary collision hulls. It is likely that using many shapes to cover the pixels exactly will severely strain the engine, too.

It is recommended you outline the shapes, using automatic or manual techniques. Neither is particularly easy.

Return to “Flash”

Who is online

Users browsing this forum: No registered users and 3 guests