Box2D Forums

It is currently Sun May 19, 2013 1:05 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Sun Dec 12, 2010 3:50 pm 
Offline

Joined: Mon Jul 27, 2009 6:46 am
Posts: 230
Hello there!

I was messing about with Box2D a bit, and I noticed something that disturbed me slightly: the C# version wasn't up to date.

I took it upon myself to perform some porting duties to get 2.1.2 working under .NET (non-XNA or anything), but firstly, I had to find a medium for porting it.

Rather than choosing the general direction of porting the code itself, I made a front-end for Box2D in pure C, named Box2C. This frontend allows languages that support invoking C DLLs to use Box2D. The following are required for a port to work properly:

  • Structure support
  • Pointers, or "out" variables
  • Callbacks from native C (although you can possibly find a workaround using a message pump, but I haven't implemented this for various reasons)

Then, from there I wrote a frontend in C# for Box2C, named Box2CS.

The reason for this slightly complicated web of frontends is for one main reason: maintainability. If, for example, a small patch is released that modifies some of the code somewhere, rather than trying to port the fixes over to a different codebase and merge stuff, you just drop in the new .lib file and recompile. That's it.

Secondly, there is a slight performance boost due to the native code running the actual simulation, although that was more of a minor thing.

Anyway, you can check out the project here:
http://code.google.com/p/box2c

Currently, Box2C and Box2CS are near-fully functional as you can see in the test apps there, with only a few minor functions missing (shape::TestOverlap, etc).

Please note that Box2DX and Box2CS are NOT compatible on a 1:1 ratio, because Box2CS uses 2.1.2 and Box2DX is an older version that did not have fixtures.

-P


Top
 Profile  
 
PostPosted: Sun Dec 19, 2010 3:57 pm 
Offline

Joined: Mon Jun 15, 2009 4:34 pm
Posts: 69
I was in charge of porting over Box2D to C# in the Box2DX project along with some very helpful guys from the Farseer Physics Engine forums and the Box2D forums.

However, we were barely finished when the Box2D.XNA crew released their fully functional Box2D port, so we decided to let the Box2DX project go.

I used Box2D.XNA as a basis for version 3.0 of the Farseer physics engine, however, a lot has changed since then and I now maintain an up to date Box2D port instead of waiting for the Box2D.XNA crew to release updates. I'm now at revision 141 of Box2D SVN.

So my recommendation is to use Box2D.XNA if you need a 1:1 port or use Farseer Physics Engine if you need a faster, more feature-rich version of Box2D in C#. That being said, I welcome your project to the managed world. :)

Edit: By the way; Farseer Physics Engine works with Silverlight, WPF, Xbox360, WP7, XNA and vanilla .NET. You can download the latter if you need the library only as it has 0 dependencies other than .NET itself.


Top
 Profile  
 
PostPosted: Fri Dec 24, 2010 7:21 pm 
Offline

Joined: Fri Dec 24, 2010 9:05 am
Posts: 3
Box2C is a unadulterated C frontend to Box2D, manufacture it much easier to port across to other languages. Box2C was urbanized at first just for Box2CS, an up-to-date C# frontend to Box2C, but I determined to release both together.

Rewards over code-ports:

• Native simulation velocity
• Easier to preserve (if a newer version is released that doesn't change the API,
we can simply drop in the new .lib and compile)
• More dependable (no need to worry about shocking code porting -
implementation is a breeze).
-----------------------------------------
hp coupon codes


Top
 Profile  
 
PostPosted: Sat Dec 25, 2010 6:27 am 
Offline

Joined: Mon Jun 15, 2009 4:34 pm
Posts: 69
I would like to test Box2DC and the C# wrapper, but after downloading the latest source code (revision 13) I was faced with a couple of unfamiliar errors.

First off it tried to build with VS2008 toolkit, I changed that to VS2010 toolkit instead.
Then I got some errors that Box2D.h was missing and Tao.FreeGlut was missing.

Could you upload a version that compiles correctly?

Make sure to post Eric Jordan's license inside his implementation of the Ear clipping algorithm. You could have saved some time porting that to C# as Matthew and myself did that a long time ago when we were working on FPE 3.0. Guess it is too late now :)


Top
 Profile  
 
PostPosted: Sat Dec 25, 2010 5:20 pm 
Offline

Joined: Mon Jul 27, 2009 6:46 am
Posts: 230
I'm working on it mang. There's a reason why I haven't added downloads yet: it isn't done! :)

I'm constantly committing new versions. I'm about to commit one right now, actually, which is working fully and has every testbed test (that was useful) ported.

I had ported that convex decomposition code years ago actually, and just brought it over from an old old OLD project of mine.

About the toolkit: it is left at VS2008 for a specific purpose; Windows XP users don't have the 2010 runtime as a recommended Windows update, so I use the 2008 toolkit and .NET 3.5 in all of my projects.

I use those two for my projects because I can't be sure that every one of my beta testers can test my programs without me having to track down 150 DLL dependency errors inwhich the end result is finding out that they don't have the 2010 runtime.

-P


Top
 Profile  
 
PostPosted: Sun Dec 26, 2010 4:51 am 
Offline

Joined: Mon Jun 15, 2009 4:34 pm
Posts: 69
Sounds great. I will update the distribution right away.


Top
 Profile  
 
PostPosted: Sun Dec 26, 2010 4:59 am 
Offline

Joined: Mon Jul 27, 2009 6:46 am
Posts: 230
Box2CS is really just another alternative that people can use if they wish to use Box2D in a managed environment without all the extra features that the other alternatives provide. The biggest difference is that Box2CS isn't managed in terms of actual simulation, it runs at native speed and requires a lot less maintenance to upkeep with new versions of Box2D. For example, to get Box2C/Box2CS working with the SVN version now, all I'd have to do is change a couple of functions in Box2C and Box2CS and that's pretty much it, the rest just works the same.

EDIT: I should clarify also what I meant about a 1:1 port ratio. Box2DX is using the old version where fixtures weren't implemented, so trying to port Box2DX over to Box2CS (or even Box2D.XNA I assume since it is updated) will not work without some modifications. However, porting Box2D.XNA to Box2CS or vice versa should work on a 1:1 ratio.

-P


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group