Which physics engine is working with MonoGame?

@Fox9 well , i didn’t know anything about DebugView but it looks like it is a seperate Project.

I found the project now. And trying to make it work on WP8. I will post it here as soon as i got it work. ( Doesn’t look like hard, just like orj monogame -> wp8 process. )

@Fox9 Can you try downloading and adding this .dll to your project and using debugView ?

It should work but i am not sure.

I added a reference to your .dll but I get an error message in this line:

DebugViewXNA physicsDebug;
The type ‘FarseerPhysics.DebugViewBase’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘FarseerWindowsPhoneMono, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’.

What is wrong?

@Fox9, ooh i got it.

I have to use the .dll that i created on blog post. .dll’s must be the same. I used different .dll that i create for test. Sorry.

I now created a DebugView .dll with previously created WindowsPhoneParseer .dll

I am giving a link to both of them, i believe you can use both without a problem.

WindowsPhoneFarseer
WindowsPhoneFarseerDebug

PS : I am going to create a blog post about this, but until then, i believe this .dll’s will work for you.

It’s not working. I get an error message in the line base.Initialize().

protected override void Initialize()
{
base.Initialize();
}
An exception of type ‘System.IO.FileNotFoundException’ occurred in MonoGame.Framework.DLL but was not handled in user code
Additional information: Could not load file or assembly ‘WindowsPhoneFarseerDebug, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. The system cannot find the file specified.

@Fox9
Did you use that 2 .dll i uploaded ? unreferance the old ones.

This is the WP project that has Farseer and FarseerDebug that works for me.

http://bit.ly/workingMFFD

Your project works for me if I debug on a device, but it’s not working if I debug on an emulator. If I choose an emulator, then I get many error messages.
How can I build the Farseer DebugView .dll myself?

@Fox9 Hey, i wrote a blog post about it.

You can see in here : http://semihmasat.info/how-to-build-and-use-farseer-debugview/

PS : Video is on the way.

I downloaded the source code of Farseer, but there is no DebugView MonoGame.csproj in the .zip file. Where can I find DebugView MonoGame.csproj?

@Fox9, sorry gave a non-working link. You need to download entire source code from here : http://bit.ly/farseerSource

There is download link on the sub menu

It worked, but I have some additional questions.
I build the Farseer DebugView .dll like this:
I selected “Release” from top and build the WPCL DebugView project.

But I build the other Farseer .dll like this:
I selected “Debug” from top and build the WPCL project.

Are my build settings correct like this? Should I build both .dlls with “Release” selected?

In addition, what can I do so that the .dlls work with Windows Phone Emulators and Devices? Should I build two more dlls with other build settings? For the moment, my own dlls just work with Emulators but not with a device. If I debug on a device, I get this error message:

There was a mismatch between the processor architecture of the project being built “ARM” and the processor architecture, “x86”, of the implementation file “C:.…\Desktop\WinPhone8Farseer\Farseer Physics Engine 3.5\FarseerForWindowsPhone\Bin\x86\Debug\SharpDX.WP8.dll” for “C:.…\Desktop\WinPhone8Farseer\Farseer Physics Engine 3.5\FarseerForWindowsPhone\Bin\x86\Debug\SharpDX.WP8.winmd”. This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and implementation file, or choose a winmd file with an implementation file that has a processor architecture which matches the targeted processor architecture of your project.

@Fox9 Glad they worked for you.

**Did you referance .dll’s other than WindowsPhoneFarseer and WindowsPhoneFarseerDebug ? You don’t need the referance other files built in folders. If you did, remove them and try like that. **

If it doesn’t work, then you continue to read this post.

It looks like , when you try to build .dll’s for Windows Phone, it builds for ARM architecture. But when you try to build it for emulator, it builds for x86 architecture. So the old dll’s that you build for x86 or ARM is not working.

You can this this methods

  1. Right click the Solution of your Windows Phone game Solution on Visual Studio ( Not Project, The Solution ) and Click properties.
  2. Click, “Configuration Propertied” from the left panel.
  3. You will see your projects name on the right panel. Click the platform tab of your Project and change platform to x86 for Emulator. Click “Apply” after. ( optional : change Configuration to Release )
  4. If you want to target your build, change back to that to “ARM”.

If this isn’t work for you. Try this steps.

  1. Build WindowsPhoneFarseer for both ARM and x86. You can name that ARM one WindowsPhoneFarseerARM and visa versa.
  2. Build WindowsPhoneFarseerDebug for ARM and x86, using the dll’s you build for ARM and x86, you can name them like WindowsPhoneFarseerDebugARM and x86. it’s your choise.
  3. Use ARM ones for building for device and x86 ones for building for Emulator.

Hope that’s Works for you. But same dll’s Works for me.

@craftworkgames do you have your updated source on GitHub or Codeplex somewhere.
Should have a little time to play with it this week, might even create a little NuGet as well :smiley:

It’s not working. I build WindowsPhoneFarseer and WindowsPhoneFarseerDebug for ARM and referenced both .dlls to my MonoGame Windows Phone 8 project. In addition, I went to “Configuration Properties” and clicked on the platform tab of my project and changed the platform to ARM.
But I always get these error messages if I want to run the project on my device.

public GamePage()
{
InitializeComponent();
_game = XamlGame.Create(“”, this);
// Sample code to localize the ApplicationBar
//BuildLocalizedApplicationBar();
}
The best overloaded method match for ‘MonoGame.Framework.WindowsPhone.XamlGame<GameName1.Game1>.Create(string, System.Windows.Controls.DrawingSurfaceBackgroundGrid)’ has some invalid arguments
Argument 2: cannot convert from ‘GameName1.GamePage’ to ‘System.Windows.Controls.DrawingSurfaceBackgroundGrid’

What is wrong?

@SimonDarksideJ I’ve just pushed my updated Farseer Physics Portable project to github. It should work out of the box. A NuGet package would be great :smile:
https://github.com/craftworkgames/FarseerPhysics.Portable

I haven’t really created a NuGet package before, but it’s something I’m interested in so once you’ve made the changes create a pull request so I can take a look. Thanks

I have some difficulties with Farseer if I want to support different screen resolutions. If the resolution of the device is less than 720p, then the sprites and their corresponding Farseer bodies need to be scaled down. If I run my project with the 720p emulator, then everything looks fine. But if I choose an emulator with a lower resolution(for example WVGA emulator), then everything looks weird.
In this picture, I use the 720p emulator: http://s1.directupload.net/images/140520/gnpwvjsw.jpg
In this picture, I use the WVGA emulator: http://s14.directupload.net/images/140520/hxhicnph.jpg

If I use the WVGA emulator, then the Farseer collision shapes are drawn on another position than their corresponding sprites. I’m not sure why this happens. Does somebody know why Farseer isn’t working with different screen resolutions?
My uploaded my project here: http://www.file-upload.net/download-8938491/farseerinmonogame.rar.html

My guess is that you need to make sure the Farseer Debug Renderer is scaling the graphics the same way as the SpriteBatch.

So this code:

            // calculate the projection and view adjustments for the debug view
            Matrix projection = Matrix.CreateOrthographicOffCenter(0f, graphics.GraphicsDevice.Viewport.Width / _displayUnitsToSimUnitsRatio,
                                                             graphics.GraphicsDevice.Viewport.Height / _displayUnitsToSimUnitsRatio, 0f, 0f,
                                                             1f);
            Matrix view = Matrix.CreateTranslation(new Vector3((_cameraPosition / _displayUnitsToSimUnitsRatio) - (_screenCenter / _displayUnitsToSimUnitsRatio), 0f)) * Matrix.CreateTranslation(new Vector3((_screenCenter / _displayUnitsToSimUnitsRatio), 0f));
            // draw the debug view
           physicsDebug.RenderDebugData(ref projection, ref view);

And this code:

spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, camera.GetMatrix());

I don’t know exactly what is wrong but my guess is that the transformation matrix returned from camera.GetMatrix() and Matrix.CreateOrthographicOffCenter need to be in sync somehow.

I’ve published a NuGet package for my FarseerPhysics.Portable library. If you already use NuGet it should be relatively painless to get Farseer working in any MonoGame project.

Thanx. It works.
Will you add a portable version of the Farseer DebugView project as well?

The DebugView is only two files (DebugViewXNA.cs and PrimitiveBatch.cs). You can simply add them to your project directly. You can find them in the Farseer source code on code project here:
https://farseerphysics.codeplex.com/SourceControl/latest#DebugViews/DebugView XNA/DebugViewXNA.cs
(note: there is a space in the above URL that breaks the link, not sure how to prevent that).

The reason I didn’t add them to the PCL is because they use code that can’t go in a PCL. Although it’s technically possible to use the “bait and switch” method there’s really not a lot of benefit, because then we would still have to maintain a version for each platform.