Concave ground

Hello,

After looking at the documentation and over the forum, and finding many little answers, I just want to know if do you think this is possible to be programmed: http://www.ductil.org/example.jpg

I will appreciate your answer.
Thanks.

Guille.
Yes and no. It is not possible to code something exactly like this at the moment. But a approximation made out of several polygons is usually acceptable for almost all cases. Imagine e.g. the bridge example from the test bed, only with the individual pieces fixed in place.

If you aren't interested in making an arch, and only a dip in the ground, then my (currently unfinished) b2ConcaveArc shape would sort you out. I'm stalling on writing it though, so I'd go with the polygon approach.
If you do just need an approximation, look at http://www.brainblitz.org/BoxCAD2/?load=demo-71383

That is using very thin rectangles.

That's not actually the best way to do it - as non-bullet bodies will pas through fairly easily - but should give you the idea.
I see a blank simulation with that link...
It's not working in firefox unfortunately - as I just now found out.

[edit]
If you're using firefox, just go File, Load User File "demo-71383".
[/edit]
Thank you very much!

I am going to try with this approximations.
The example demo-71383 is quite good.

I will tell you what I get at the end.
Verso,

I recently noticed in Firefox my simulation was completely different, ie: uncontrolable in firefox but fine in IE.

Do you know why this is?
PM'd - I want to make sure I'm not hijacking threads!
I did it!
And it was not difficult. Also the result is quite good.

It's simple like use the ellipse equation (http://en.wikipedia.org/wiki/Ellipse).

For each point of the ellipse draw a rectangle.

If you are interested, here you have the code:

Code:
var width:Number = 20;
var height:Number = 10;
var initX:Number = 400;
var initY:Number = 100;
var a:Number = 380;
var b:Number = 450;
var ang:Number = Math.PI;
var num:Number = 400;
var inc:Number = 2*Math.PI / num;
         
for (var j:Number = 0; j < num; ++j){
   var sd:b2BoxDef = new b2BoxDef();
   sd.extents.Set(width/2, height/2);
   sd.density = 0.0;
   sd.friction = 0.2;
   var bd:b2BodyDef = new b2BodyDef();
   bd.AddShape(sd);

   var caja:Sprite = new Sprite();
   caja.graphics.beginFill(0x3C3C3C);
   caja.graphics.drawRect(-50, -50, 100, 100);
   caja.graphics.endFill();
   bd.userData = caja;
   bd.userData.width = width;
   bd.userData.height = height;

   var x:Number = initX + a * Math.cos(ang);
   var y:Number = initY + b * Math.sin(ang);
   ang -= inc;
   bd.position.Set(x, y);
   bd.rotation = ang;
   var body:b2Body = m_world.CreateBody(bd);
   addChild(bd.userData);
}

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