Farseer on the 360

Topics: User Forum
Jan 4, 2007 at 10:03 PM
I made a simple physics demo using Farseer in Windows but I'm having a bit of trouble converting it to the 360.

I created a 360 project, added all my code and the FarseerGames.FarseerXNAPhysics.dll to the references but when I try and compile the project I get errors such as...

Error 1 The type 'Microsoft.Xna.Framework.Vector2' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.Xna.Framework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d'. C:\Documents and Settings\Louise\My Documents\Visual Studio 2005\Projects\PhysicsDemo\PhysicsDemo\RigidBodySprite.cs 41 19 PhysicsDemo

and

Error 2 Cannot implicitly convert type 'Microsoft.Xna.Framework.Vector2 []' to 'Microsoft.Xna.Framework.Vector2 c:\Program Files\Microsoft XNA\XNA Game Studio Express\v1.0\References\Xbox360\Microsoft.Xna.Framework.dll' C:\Documents and Settings\Louise\My Documents\Visual Studio 2005\Projects\PhysicsDemo\PhysicsDemo\RigidBodySprite.cs 41 26 PhysicsDemo

and

Error 5 Argument '1': cannot convert from 'Microsoft.Xna.Framework.Vector2 c:\Program Files\Microsoft XNA\XNA Game Studio Express\v1.0\References\Xbox360\Microsoft.Xna.Framework.dll' to 'Microsoft.Xna.Framework.Vector2 []' C:\Documents and Settings\Louise\My Documents\Visual Studio 2005\Projects\PhysicsDemo\PhysicsDemo\RigidBodySprite.cs 73 34 PhysicsDemo

I can't figure out what the problem is. I wonder if it's because the FarseerXNAPhysics project was made for Windows and therefor is x86. If this is the problem, how can I go about converting FarseerXNAPhysics into a 360 library?
Coordinator
Jan 5, 2007 at 2:45 AM
Not sure on this. I haven't tried playing with it yet. Might get some answers if you post over on the XNA msdn forums.

I won't be set up to test this myself for a while... sorry I can't be of more help.
Jan 6, 2007 at 7:18 PM
Heya,
Farseer works well on the 360. I got WildBoarders running on it the other day. The problem is you have to delete the XNA reference in the Farseer project and add the XNA .dll that is for the 360 as a reference. If you installed GSE in the default location you'll find the XNA reference here:
C:\Program Files\Microsoft XNA\XNA Game Studio Express\v1.0\References\Xbox360\Microsoft.Xna.Framework.dll

Jeff, there are a few issues for 360 compatibility with the engine, I was thinking about starting a new thread but this is just as good as any. Inside Grid.cs I was getting an error running on the 360 saying mscorlib.dll could not load the type. The error sprung up on :

throw new MissingFieldException("Geometry was not properly set");


So it seems mscorlib doesn't have the definition of that exception on the .NET compact framework for the 360 (my best guess, I'm not expert).

The other issue is something I'm currently looking into, it deals with performance of alot of physics objects on the 360. The 360 hardware doesn't like a lot of new objects being created mid-frame as the garbage collection isn't as great (or so I've read). So doing vector2 + vector2 returns a new vector while Vector2.Add(ref v1, ref v2, out result) can do it without generating any new objects. Anyway, just a heads up on it, as I've been noticing some stuttering in the physics on some of my larger levels.
Coordinator
Jan 6, 2007 at 11:24 PM
Thanks for the info Alex. I will get rid of that exception.

As for the garbage collection, I will also need to look into it. I've been meaning to go thru and change as many of my vector methods to use the ref overloads. I've also read a few blog posts about how the garbage collectors work differently on the xbox360 than they do in windows. I'll need to do some research.

I've got an xbox, but have not yet signed up for the creators club so I haven't done any testing on my own. Hopefully soon I can do that.

Thanks again for the good feedback.
Jan 8, 2007 at 6:09 AM
No problem :)
Gotta say that using Farseer has been rather painless on both platforms. I wouldn't have thought to make a game library for XNA as just an ordinary C# project (instead opting to do a windows game lib or 360). Making it a C# project allows it to work on both without creating a new project :). Time saver indeed.