InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

Introducing Farseer - An Open Source Physics Engine for Silverlight and XNA

Posted by Jonathan Allen on Nov 19, 2007

Sections
Architecture & Design,
Development,
Operations & Infrastructure
Topics
Silverlight ,
.NET ,
Open Source
Tags
XNA ,
Physics Engines

In the modern push for showier and more interactive interfaces, it is inevitable that real-time animation is going to be asked for from time to time. When this animation involves objects on the screen bouncing off each-other or being affected by gravity, a physics engine is a must.

The Farseer Physics Engine, though primarily billed as something for writing 2D games, addresses this need. We interviewed Jeff Weber, designer of Farseer.

Why did you decide to start the Farseer Physics Engine project in the first place?

I built the Farseer Physics Engine because I had a desire to make 2D physics games using .Net. I looked around for a good 2D physics engine written in managed code that would allow me to make the games I had in my head. There were very few and the ones that did exist didn't quite have all the features I knew I would need.

There was however a very interesting C++ physics engine called Box2D written by Erin Catto. It had most the features I needed and I was pretty sure I could add the rest so I decided to use it as a basis to build my own managed physics engine. The Farseer Physics Engine is this engine.

Note: The Box2D engine behind the link above is a newer version of Erin Catto's engine. The concepts are similar but Farseer was build of an earlier version of the Box2D engine.

Do you have any prior background in physics engines or are you learning this as you go?

I have a B.S. in Mathematics from way back. I never really had the opportunity to use it until I started doing game development as a hobby about 6 yrs ago. Since then I've always tried to include some type of physics in my projects, which, by the way, have always just ended up being demos of one sort or another rather than a finished game.

I was also fortunate enough to work for about a year on a Truck Driving simulator several years back for my "real" job as a .Net developer consultant. For that project we used the Open Dynamics Engine (ODE) with a managed .Net wrapper.

So, yes I've had some experience here and there with physics and physics engines, but the Farseer Physics Engine is my first "finished" project outside of my day job.

When having to choose between ease of use and power/flexibility, which direction do you tend to lean towards when creating libraries like Farseer?

With Farseer simple-to-use was definitely my primary goal. I even had "Keep It Simple" written on my whiteboard. (still do actually) The object hierarchy of some of my earlier versions started to get more and more complex with a bunch of abstract classes, interfaces, and levels of inheritance Finally I remembered my goal to keep it simple and re-factored everything to meet that goal. I am very happy with the way it turned out.

In general I try to find a balance between power, flexibility, ease-of-use, and finishing in a timely manner. If I have to lean one way or the other, I lean toward keeping things simple.

Have you given any thought to compatibility with non-Microsoft runtimes like Mono?

Not really. Not to sound too selfish, but I really created Farseer for my own needs. I don't use Mono and I don't have any immediate plans to use it so I've never really given it any consideration. I'll leave that up to others. I'm guessing it would be an easy port as the engine doesn't really rely on to much outside the core .Net framework.

Overall, what is your impression of Silverlight and XNA for building software like this? Does they lend themselves to this kind of code or do you find yourself fighting against the platforms?

I love both these frameworks and both lend themselves well to Farseer. Farseer is pretty much identical on both these platforms. The Silverlight version required the creation of some math constructs to duplicate those in XNA, but other than that the only difference is that each is compiled against different version of the .Net framework. The demos, of course were a little more work. Bill Reiss of Blue Rose Games was the guy who ported both the Farseer Physics Engine and demos to Silverlight. It was a great idea to do the port and I'm very glad he approached me about it.

Currently, I've moved away from XNA for a while and I am focusing more on Silverlight. I'm able to get things on screen and usable much quicker in Silverlight than in XNA. Mostly because of the 2D vector drawing built into Silverlight. I wish Microsoft would build an XAML parser into the XNA framework.

I also like the idea of building games for the web. I think there is a bright future there.

What are your future plans for Farseer?

My future plans mostly revolve around actually USING the Farseer Physics Engine now that it's finished. I will continue to update it as useful

ideas/code is submitted by users or when I need some new functionality for games I'm writing. I've already had some very good stuff submitted by users in the user forum and I'm working on getting that incorporated into the engine.

Overall, I'd like to use the engine to make the games I have in my head and to hopefully earn some supplemental income from them. I currently have a Silverlight game in progress that I feel is unlike most existing web games. (I know, they all say that.) Oddly enough, this will be my first finished game since I started game development as a hobby 5 or 6 years ago.

The Farseer Physics Engine is available on CodePlex.

No comments

Watch Thread Reply

Educational Content

Collaboration: At the Extremities of Extreme

Jason Ayers share the observations he made watching a team of developers collaborating in real time on the same code base, pushing XP, pair programming and continuous integration to their extremes.

Yesod Web Framework

Michael Snoyman presents Yesod, a web framework written in Haskell and containing a web server, templating, ORM, libraries (templating, gravatar, etc.).

Transactions without Transactions

Richard Kreuter and Kyle Banker on how to avoid classical RDBMS transactional systems by using compensation mechanisms, transactional messaging or transactional procedures.

Attila Szegedi on JVM and GC Performance Tuning at Twitter

Attila Szegedi talks about performance tuning Java and Scala programs at Twitter: how to approach GC problems, the importance of asynchronous I/O, when to use MySQL/Cassandra/Redis, and much more.

10 tips on how to prevent business value risk

One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.

Interview: Software Systems Architecture: Working With Stakeholders Using Viewpoints and Perspectives

InfoQ spoke to the authors of Software Systems Architecture on a couple of new topics, the System Context viewpoint and Agile, which have been added to the second edition.

Beauty Is in the Eye of the Beholder

Alex Papadimoulis discusses ugly code, where it comes from, how to avoid it, and how to get rid of it.

Architecting Visa for Massive Scale and Continuous Innovation

John Davies examines Visa’s architecture and shows how enterprises have architected complex integrations incorporating Hadoop, memcached, Ruby on Rails, and others to deliver innovative solutions.