Separating Math classes (Vector3, Quaternion) from Mogre

zarfius

11-10-2011 12:35:12

Hi good people :)

I'm currently working on a project that requires a lot of 3D math and until now I've been using Mogre as a math library even though the project doesn't require rendering directly. Ideally I'd rather not have the dependency on Mogre for this project (or any other graphics engine for that matter) but I still need that math classes.

I had a bit of a look around and there doesn't seem to be any stand alone 3D math libraries for C#. They all seem to be tied to graphics or game engines one way or another. So, I decided to start implementing my own to suit my needs. So far, I've implemented Vector2, Vector3, Quaternion and a couple of other minor bits. Then I thought, maybe other people might be interested in a stand alone 3D math library too? I know this idea has popped up a few times on the Ogre forums before.

So, I'm wondering if there's enough interest, should I create an open source project and get some help implementing and testing the rest of the classes? The project shouldn't take very long to finish and could provide a valuable resource to others that need a lightweight 3D math library.

smiley80

11-10-2011 17:23:33

I had a bit of a look around and there doesn't seem to be any stand alone 3D math libraries for C#. They all seem to be tied to graphics or game engines one way or another.
Have you tried this one:
http://code.google.com/p/slimmath/

zarfius

12-10-2011 00:53:44

Thanks smiley80, that's exactly what I was looking for :)

Funnily enough, just after I posted this topic I was having a look at the math classes in SlimDX. I didn't realise they had already split them out into their own project.

Beauty

01-11-2011 12:47:49

Your problem is solved, but I want to add something.

For some mathematical calculations the Mogre wrapper still uses System.Math instead of Ogre.Math.
I suppose this decision was done by the retired Mogre author Bekas for performance reasons.
Unfortunately in some cases this causes different behaviour than Ogre or even invalid values in special cases. (e.g. look to the Quaternion.Yaw problem)
The know funktions/properties I added to the Mogre bug tracker.

I thought about to fix that issues in the Mogre wrapper code.
Either by use of Ogre.Math instead of System.Math (slower, secure) or by porting the calculation code to C# (faster).
1)
Both should be easy, but I have only very less C++ knowledge. So I'm aware to write invalide code.
2)
I'm not shure how/where to apply the changes correctly. When I update the wrapper code directly, the Mogre autowrapper would overwrite my changes (when it's applied later in the future).
Most of the Ogre class members are wrapped automatically by the autowrapper. Some other members are not wrapped and use pure .NET code instead (e.g. class Vector3).
Does anybody know how/where to apply changes for class members which are not wrapped by the autowrapper?
3)
Somebody has to re-build Mogre to become the changes available for applications.

Well, has anybody an idea how we want to fix this kind of Mogre bugs?

zarfius

02-11-2011 06:00:24

I suppose this decision was done by the retired Mogre author Bekas for performance reasons.

I think this decision was probably the right one because the math classes are often used in a lot of performance critical code. However, it's also important that the math classes work correctly.

Either by use of Ogre.Math instead of System.Math (slower, secure) or by porting the calculation code to C# (faster).

Porting the code to C# is probably okay since this code is likely very stable and unlikely to change.

I'm not sure how/where to apply the changes correctly.

This is the real issue here. Mogre has always been pretty difficult to maintain and runs the very real risk of getting behind the latest version of Ogre (especially in terms of plugins like the Terrain manager).

The only thing I can think to do is to make a list of all the problems we are currently having maintaining Mogre in another forum post (or on the wiki) and take small steps to solve them. The problems seem too great for any one person to solve alone.

Beauty

09-11-2011 10:22:13

The problems which I know are still added in the Mogre Bug Tracker.
Right, additionally we can use the forum for update questions. I think the topic Understanding the Mogre build process could be a good place for general update questions. And a second one for special update cases.