Concave Polygon Decomposition in Flash

Cool game, though i think it bugs when you start the slice ON the block, there is no "ploppy sound" and a rectangular seciton of ice seems to have disappeared.

Other than that though, I think it's an awesome game and very original use of physics engine!!! 😀
Is it possible to get the b2Polygon.as to work with box2d 2.0 ? Cause now when i try to create a concave polygon, it gives a error that b2PolyDef.as does not exist ( which doesnt ) . I also tryed replacing all the "b2PolyDef" with "b2PolygonDef" it still gave a error guess it is rewritten in a other way.

Is ther a way to get this running? Cause i'm looking for this for so long!!
Or could anyone help me changing the old b2Polygon.as so that it will work allong with the b2Triangle?

Thanks in advance!!

Erik
Glacious wrote:
Is it possible to get the b2Polygon.as to work with box2d 2.0 ? Cause now when i try to create a concave polygon, it gives a error that b2PolyDef.as does not exist ( which doesnt ) . I also tryed replacing all the "b2PolyDef" with "b2PolygonDef" it still gave a error guess it is rewritten in a other way.

Is ther a way to get this running? Cause i'm looking for this for so long!!
Or could anyone help me changing the old b2Polygon.as so that it will work allong with the b2Triangle?

Thanks in advance!!

Erik


Is ther anyone who could point me in the right direction?
The changes are fairly substantial but you should be able to update it. Changing Poly -> Polygon was a good start, you should have noticed this reduced the number of errors. Keep at it, and I'm sure you'll succeed.
Sorry, but I'm not aware of this having already been updated.
Haha thanks, ill give this a shot tomorrow. And try to reduce the errors.
If you look at the SVN history in the corresponding c++ code (Contrib directory) that should help tell you what needs to be changed. IIRC it wasn't anything too major, but changes were scattered a bit throughout the file because a lot of Box2d stuff changed.
Ok i gave it a shot, tryed my best.

But i cant seem to understand it, since your file is in c++ and so is the log. I'm not into c++
It seems that the first problem starts with ;

DecomposeConvexAndAddTo() function

It asks for a localPosition from the prototype, which is not used any more.
so as all the other properties.
Then ther is the addShape function which doesnt exist in the BodyDef.

Im not into the whole engine, i tryed to just open every file and see wher it leads to etc etc. But i cant seem to figure what to really change, but i know whats wrong.

Is ther anyway you could help me out with this Eric, cause i would really like to work with this awesome tool!

Cheers,
Erik
hi, i'm new to this...

i got the jsfl to trace a shape for me but i don't know how to use the output within Box2D.. i'm presuming the code at http://www.artificial-studios.co.uk/Files/b2Polygon.as was meant to do it, but it's no longer there.

does anyone have this code please?

basically i'm trying to trace something like eg
Image
I trace bitmap in flash and smooth it so that i get a decent result from the jsfl, I just need to work out how to create my b2d shape data from the jsfl data.

I should then be able to add my bitmap back over the b2d shape as per this example
http://wonderfl.net/code/a31f4e302db617 ... 5b55562817

thanks
J
ok i think i got this working

Code:
    // array from Decompositon JSFL
    var pArray:Array = [[[122, 0.5], [122, 86.5], [101.95, 56.3], [101.95, 0.5]], [[101.95, 56.3], [122, 86.5], [6.7, 86.5], [6.7, 56.3]]];
   
    for (var p:Number = 0; p < pArray.length; p++)
    {
        var poly:Array = pArray[p];
      
        var sd:b2PolygonDef = new b2PolygonDef();

        sd.density = 0.7;
        sd.restitution = 0.5;
        sd.vertexCount = poly.length;

        for (var v:Number = 0; v < poly.length; v++)
        {
                trace(poly[v][0] + "," + poly[v][1]);
                sd.vertices[v].Set((poly[v][0]/DRAW_SCALE), (poly[v][1]/DRAW_SCALE));
        }
        body.CreateShape(sd);
}


i had to fudge the x,y a bit though because it was a little off. maybe because i didnt orientate my original shape around the origin

Original thread: https://box2d.org/forum/viewtopic.php?t=463