Setting an ellipse as BoundaryElement causes collisions to stop

Jul 24, 2011 at 4:35 PM
Edited Jul 24, 2011 at 4:40 PM

Having a simple UserControl with contents like this:

    <Canvas x:Name="LayoutRoot" Height="31" Width="33">
        <Canvas CacheMode="BitmapCache" x:Name="cnvFootball" Height="31" Width="33">
                <pb:PhysicsObjectBehavior Mass="1" CollisionGroup="1000" BoundaryElement="image" RestitutionCoefficient="0.8" FrictionCoefficient="10"/>
			<Ellipse x:Name="ellipse" Height="32" Width="33" Canvas.Top="-1"/>
			<Image x:Name="image" Height="31" Source="football.png" Stretch="Fill" Width="33"/>

if I change BoundaryElement value to "ellipse", the physics object stops colliding with other bodies. Any ideas?


Jul 24, 2011 at 6:27 PM
Edited Jul 24, 2011 at 6:27 PM

Hmm idk what seems to be the problem because I have a very similar user control for a bouncy ball that doesn't cause me any problems. Maybe the code will help:


       <Canvas x:Name="LayoutRoot" Background="Transparent">
		<Canvas x:Name="ball" Height="60" Width="60">
                <pb:PhysicsObjectBehavior RestitutionCoefficient="0.8" BoundaryElement="ellipse"/>
			<Ellipse x:Name="ellipse" Fill="Black" Height="60" Width="60"/>
			<Image Height="60" Source="Assets/ball.png" Stretch="Fill" Width="60"/>
Jul 24, 2011 at 8:13 PM

@PriceXperience: Thank you, I've got it - the problem was that the ellipse had no visible brush, and I believe that the tesselation algorithm in the helper did not create any geometry for the body. I added Fill="Black", and it started working. (I needed an ellipse to make bouncing more predictable, as the image has some rough edges because of pixelation after I made transparent background.)

Jul 25, 2011 at 12:45 PM

Just a note: If you can set the BoundaryElement to the name of the Ellipse, and make sure the Ellipse has correct height and width, it will give you better performance than using the tesselation algorithm output.