This project has moved and is read-only. For the latest updates, please go here.

SlimDX Version?

Dec 27, 2011 at 8:06 AM
Edited Dec 27, 2011 at 8:15 AM

Is there any chance of this happening?

XNA is pretty good, but, it's also limited compared to SlimDX, and, long story short, after talking with the XNA devs, it's clear they aren't putting much focus on the PC platform, or on bringing me the features I want from DX. (I know you can mix n' match(SlimDX+XNA), but, I recreated the core(bare bones, game class, etc,.) of XNA, and now have the same setup as a normal XNA game project, but all the power of DirectX under SlimDX, so why bother?)

Anyways, I would really appreciate a SlimDX compatible version, and I'm sure others would as well. (ie, for the better winform support, controller support, DX10\11, etc,.)

This is the best 2D physics engine available(that I've seen), I've had great success using it in the past, and would love to continue using it in future projects.

Thanks. :)


Edit: I tried making it work myself, but honestly, an official version would help everyone using SlimDX, and be more likely to work as intended. (I don't know your internals well enough, I'm very likely to break tons of stuff during the 'port'..)

Sep 20, 2012 at 12:46 AM
Edited Sep 20, 2012 at 1:13 AM

Could still use this..

I've tried making it work on my own, however, various methods are causing issues. (Vector2.IsValid, for example, doesn't even exist according to the MSDN, how can I make a replacement for a function when I have no clue what it is, or does? Does it check for NULL, -1, 0, etc,. ??)

Personally, I suggest removing all XNA dependencies.

The only issue I can foresee is with things like Vector2, that exist in both XNA\SlimDX.

However, if you write your own functions, and only use the basic values of the structure(ie, Vector2.X), it should be as easy as swapping out using statements(XNA\SlimDX). (ie, you can use Vector2.X\Y, etc, but, don't use custom XNA methods like(IsValid), write your own checks for that, things of that nature, same with the MathHelper, write your own versions, most of it's functions are simple math, and not worth creating a dependency over.)

This should avoid backwards compatibility issues, since it wouldn't require breaking changes.

public bool IsValid()
    Vector2 d = UpperBound - LowerBound;
    bool valid = d.X >= 0.0f && d.Y >= 0.0f;
    valid = valid && LowerBound.IsValid() && UpperBound.IsValid();
    return valid;

For example:

// Either will work with this class.
using Microsoft.Xna.Framework;
//using SlimDX.Direct3D9; Contains Vector2

public static class Vector2Extension
    public static bool IsValid(Vector2 v)
        return results; 

bool IsValid() { Vector2 d = UpperBound - LowerBound; bool valid = d.X >= 0.0f && d.Y >= 0.0f; valid = valid && Vector2Extension.IsValid(LowerBound) && Vector2Extension.IsValid(UpperBound); return valid; } 
Sep 20, 2012 at 5:55 PM
Edited Sep 20, 2012 at 5:57 PM

Or use the base class library (not the XNA or Silverlight versions) available in the downloads which comes with its own implementation of some Microsoft.Xna.Framework classes like Vector2, Vector3, Matrix and the MathHelper. You don't need more from XNA for the physics - the rest is convenience like Texture2D in the MSTerrain (can be replaced). There is also no IsValid method the the class library.

Convert to whatever graphics library of choice SlimDX, OpenTK only when drawing.

In more words what you're saying is that Farseer should have a Bridge design pattern. Abstract vector classes that could be extended with concrete implementations. Instead you can use the Adapter pattern - let Farseer use its own Vector2 internally and convert the results to other Vector implementations.

Benefits of the Farseer Class Library:

  • No dependency on the XNA redistributables.
  • No need to make sure the graphics library implements its own Vector class that has the same interface.
  • No need to even consider there might be a graphics library, an AI library, a particle engine, native code and all the rest. I use third-party libraries that have their own vector classes that are non compatible with XNA so a simple using directive won't do. Still with some data messaging conversion they work fine without the need for a rewrite in XNA. Yes the code might not be pretty having a few Vector classes with identical purposes but that's what the Adapter is for - to hide the ugliness. This allows to freely interface with other great frameworks too - think CGAL or VTK. How about Farseer in Unity3D... Even if there was a common interface between XNA and SlimDX the latter is just one framework among many.
  • Separation between subsystems (graphics and physics) - that's always a good thing. IsValid might have a different meaning for a "graphics" vector and a "physics" vector. 
  • Can compile your own version on C# 5 instead of being stuck with XNA/Game Studio and C# 4

Or ... port the Microsoft.Xna.Framework namespace in the class library to SlimDX... then port again when you decide to use OpenTK...

Sep 21, 2012 at 5:33 PM

I'll check out this "base" version, and see if it works any better, thanks.