I've been trying to have a set of objects not colliding with each other but with everything else. I've understood that this can be done by setting the same value (not 0) as their PhysicsObjectBehavior's CollisionGroup. I started with the following user control:
<Canvas x:Name="LayoutRoot" Width="100" Height="100">
<Ellipse x:Name="Ellipse" Height="20" Stroke="#FFACB160" Width="20">
<pb:PhysicsObjectBehavior x:Name="Pob1" IsBullet="False" Mass="0.1" RestitutionCoefficient="1" CollisionGroup="5"/>
<LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
<GradientStop Color="#FFED1313" Offset="1"/>
then created two instances dynamically and assumed they'd both be in the same collision group, CollisionGroup == 5.
As they still seemed to collide, i tried to set the collision group manually with:
foreach (FrameworkElement element in ellipse1.LayoutRoot.Children)
PhysicsObjectMain main = element.GetValue(PhysicsObjectMain.PhysicsObjectProperty) as PhysicsObjectMain;
if (main != null)
main.CollisionGroup = 5;
which didn't have effect, either. What actually did work was :
PhysicsSprite sprite = _physicsController.PhysicsObjects["Ellipse"];
foreach (Fixture f in sprite3.BodyObject.FixtureList)
f.CollisionFilter.CollisionGroup = 5;
which I guess is more of a FPE way of doing things rather than how it should be done when using Physics Helper.
I'm quite certain I'm doing it wrong so it'd be nice if someone could point out my stupidity and maybe even provide a solution. With all the samples from across different versions of Physics Helper and Silverlight, I'd really appreciate a working example, that's
using the latest Physics Helper, with two object passing through each other.
Thanks in advance,