This project is read-only.

Polygons with curves

Dec 10, 2012 at 2:00 AM


Perhaps this is obvious, but I'm wondering why paths containing curves revert the shape to that of the bounding box?

For example, when dropping a ball onto a triangular "ramp" it behaves as normal. However once I introduce a curve into the ramp (below: ramp) the physics object becomes the bounding box of the ramp (below: cntrRamp), rather than the ramp itself.

In this case the ball, in my example below, simply sits on top of the bounding box.

Appreciate any help,



<ph:PhysicsCanvas x:Name="cnvWorld" DebugMode="True" Background="Blue" Canvas.Left="0" Canvas.Top="0" Width="480" Height="607">
    <ph:PhysicsSprite x:Name="ground" Background="DarkGreen" Canvas.Left="0" Canvas.Top="557" Width="480" Height="50" IsStatic="True" />
ph:PhysicsSprite x:Name="ball" Canvas.Left="150" Width="50" Height="50" ShapeType="Ellipse" RestitutionCoefficient="0.5" > <Ellipse Width="50" Height="50" Fill="Red" /> </ph:PhysicsSprite> <ph:PhysicsSprite x:Name="block" Background="Yellow" Canvas.Left="281" Canvas.Top="50" Width="40" Height="40" />
<ph:PhysicsSprite x:Name="cntrRamp" Height="301" Width="300" Canvas.Left="0" Canvas.Top="255" ShapeType="Polygon" > <Path x:Name="ramp" Fill="Beige" Data="M0,0 L0,301 L300,301 L300,200 C300,200 316,281 250,280 C184,279 83.3333,93.3333 0,0 z" Height="301" Width="301.706" UseLayoutRounding="False" /> </ph:PhysicsSprite> </ph:PhysicsCanvas>

Dec 10, 2012 at 6:11 PM

Unfortunately, the boundary detection does not work with Bezier Curves. You need to use straight-line polygons for the boundaries.

For a curve, you would need to just have multiple straight-line segments that are angled to create the curve.

Dec 11, 2012 at 2:38 AM

Thanks again Andy.

May 26, 2013 at 3:59 PM

is this a limitation of farseer? Or is it possible to add this feature to the physicshelperxaml? If yes, where should I start?