Getting started with Physics Helper

Mar 25, 2010 at 7:35 AM
Edited Mar 25, 2010 at 8:16 AM

I am just getting started with Farseer and the Physics Helper (great stuff!)

For starters, there is something basic that I don't understand. Take for example Demo3 inside the PhysicsHelper.Silverlight in the code samples. When I open the Page.xaml from Demo3, I can see the main path or terain with the x:Name="ramp", but I don't understand where Farseer is told that that this is a CreateRectangleGeom that will be collided with.

When I look inside the Farseer samples inside Demo2, I see this:

            Body rectangleBody = BodyFactory.Instance.CreateRectangleBody(physicsSimulator, 128, 128, 1);
            rectangleBody.Position = new Vector2(256, 384);

            Geom rectangleGeom = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, rectangleBody, 128, 128);
            rectangleGeom.CollisionGroup = 15;

How does Farseer know that the 'ramp' in Demo3 is a geometry to be collided with?

 *edit -- Adding to my confusion: I opened the page.xaml from Demo3 in Blend. I modified the shape of the 'ramp' significantly, saved it, went into VS2008, answered 'yes' to reload files modified outside the editor, and ran the solution. The ramp has not changed.


Mar 25, 2010 at 12:20 PM
Edited Mar 25, 2010 at 12:22 PM

Hi Roger,

I would suggest you use Behaviors instead of UserControls when using the Physics Helper.

The UserControls were created back in Silverlight 2 _before_ Behaviors were introduced (in Silverlight 3).

Behaviors make it much more natural inside Blend to drag/drop Physics Behaviors from the Assets library and set Physics Properties. And going forward, User Controls will not be supported, they are more there for backwards compatibility.

I would suggest starting with the intro videos (let me know if they don't work for you) - here -

(oops, forgot to mention) - The Boundary detection is part of the Physics Helper, and it "traces" the outline of a UIElement to determine an appropriate Geometry for the Physics Object. This is one of the main features of the Helper library, because you don't need to define the Farseer geometries in code and its easy to tie your artwork to a physics object.

Mar 27, 2010 at 7:44 PM
Edited Apr 4, 2010 at 3:23 PM

Wow... Great stuff.




Apr 4, 2010 at 3:24 PM

I can't seem to get the videos to load. I am positive I watched two of them in the past week or more.


Apr 5, 2010 at 1:03 AM

The links seem OK to me. The only thing I can suggest is to right-click the link to the video, and select Save As... And the download the entire video before viewing.