Tunneling problem?

Jan 8, 2011 at 9:04 PM

I am trying to have a globe with a ball inside of it. (think snowglobe). When I shake the globe I want to have the ball bounce around inside the globe, but always stay on the inside, not pop outside.

This often works, but occasionally the ball will fly right through the globe. Is this a tunneling bug or is there an error in my code?

Thanks.

Here is my XAML:

<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
	xmlns:pb="clr-namespace:Spritehand.PhysicsBehaviors;assembly=Spritehand.PhysicsBehaviors" mc:Ignorable="d"
	x:Class="Shake.MainPage"
	Width="640" Height="480">

	<Canvas x:Name="LayoutRoot" Background="White">
		<i:Interaction.Behaviors>
			<pb:PhysicsControllerBehavior MousePickEnabled="True"/>
		</i:Interaction.Behaviors>
		<Rectangle x:Name="Ground" Fill="#FF1CD816" Height="21" Stroke="Black" StrokeThickness="0" Canvas.Top="439" Width="640">
			<i:Interaction.Behaviors>
				<pb:PhysicsObjectBehavior IsStatic="True"/>
			</i:Interaction.Behaviors>
		</Rectangle>
		<Ellipse x:Name="Globe" Height="140" Canvas.Left="226" StrokeThickness="2" Canvas.Top="123" Width="146" Stroke="Black">
			<i:Interaction.Behaviors>
				<pb:PhysicsObjectBehavior/>
			</i:Interaction.Behaviors>
		</Ellipse>
		<Ellipse x:Name="Ball" Fill="#FFD83916" Height="20" Canvas.Left="307" Stroke="Black" StrokeThickness="0" Canvas.Top="163" Width="20"  >
			<i:Interaction.Behaviors>
				<pb:PhysicsObjectBehavior RestitutionCoefficient="0.8"/>
			</i:Interaction.Behaviors>
		</Ellipse>
	</Canvas>
</UserControl>
Coordinator
Jan 8, 2011 at 9:40 PM

I haven't tried your sample, but just a couple of ideas from the XAML:

- it looks like you have your "Ball" ellipse _inside_ of your "Globe" ellipse, correct? I'm pretty sure this would cause irregular physics behavior because you need to image that the shapes are solid. At least, I've never tried doing what you're doing with FS3 :)

- you could try to turn DebugMode="true" on the PhysicsControllerBehavior to make sure the boundaries are being determined correctly (although in this case I don't think that's the problem).

Jan 10, 2011 at 4:18 AM
andybeaulieu wrote:

I haven't tried your sample, but just a couple of ideas from the XAML:

- it looks like you have your "Ball" ellipse _inside_ of your "Globe" ellipse, correct? I'm pretty sure this would cause irregular physics behavior because you need to image that the shapes are solid. At least, I've never tried doing what you're doing with FS3 :)

- you could try to turn DebugMode="true" on the PhysicsControllerBehavior to make sure the boundaries are being determined correctly (although in this case I don't think that's the problem).

 

Yes, I do have the ball inside the globe. Think of a snowglobe or a gumball dispenser. When you shake one of them the stuff on the "inside" does not fly through the surface of the sphere and end up "outside". Now it may very well be that spherical objects (or circles in this case since it is 2-D) with "insides" and "outsides" are not supported, that is my question.