This project is read-only.

Physics sprite polygon being rendered as a rectangle, why?

Jun 21, 2014 at 12:43 PM
Edited Jun 21, 2014 at 12:43 PM
Hi there,

I'm trying to make what resembles a square with a circle cut out of the middle, then cut into 2 halves that I indent to stack on top of each other to encase a ball physics sprite in. My path renders correctly in the designer but for some reason the physics engine sees it as a rectangle, not a polygon,
            <ph:PhysicsSprite x:Name="Bottom" IsStatic="True" Height="250" CollisionGroup="1" Width="500" Canvas.Left="8" Canvas.Top="256" ShapeType="Polygon">
                <Path Data="M0.5,0.5 L50.5063,0.5 L50.5,1 C50.5,111.181 139.819,200.5 250,200.5 C360.181,200.5 449.5,111.181 449.5,1 L449.494,0.5 L499.5,0.5 L499.5,250.5 L0.5,250.5 z" Fill="Transparent" Stroke="White" StrokeThickness="3" UseLayoutRounding="False" />
in the designer,


during simulation,


What am I doing incorrectly?
Jun 21, 2014 at 2:18 PM
Upon further investigation it appears that the Polygon PhysicsSprite type has issues with curved sections, I've tried creating a crude rendition of this shape with lines, obviously very low definition and it works as expected. Anything as accurate as this and it gets treated as a rectangle.

I also tried creating this shape again from scratch, typing in the data field manually and got something half decent,
            <Path Data="M 0,0 L 50,0 C 50,0 50,200 250,200 C 250,200 450,200 450,0 L 500,0 L 500,250 L 0,250 L 0,0" Fill="Transparent" Stroke="White" StrokeThickness="3" UseLayoutRounding="False" />
But this also gets treated as a rectangle.
Jun 21, 2014 at 4:06 PM
I have a working solution, made by me manually tracing a path for the shape using lines, but as I make the path transparent anyway it doesn't look bad.
            <ph:PhysicsSprite x:Name="Bottom" IsStatic="True" Height="250" Width="500" Canvas.Left="8" Canvas.Top="256" ShapeType="Polygon">
                <Path x:Name="BottomBody" Data="M0.138894,0.555561 L49.5832,0.555561 L54.028,38.8885 L64.0278,75.555 L82.3609,108.888 L107.917,141.11 L135.139,163.332 L163.472,181.11 L199.028,194.443 L235.694,201.11 L270.694,199.443 L313.472,190.555 L346.806,175.555 L375.139,158.332 L399.583,133.333 L419.028,105.555 L436.25,73.8883 L446.25,35.555 L450.139,0.555122 L499.583,-0.000872 L499.583,249.999 L0.138788,250.555 z" Fill="Transparent" UseLayoutRounding="False" />