Oops with Quaternions

Oct 30, 2009 at 7:10 PM
Edited Oct 30, 2009 at 7:15 PM

 Hello

 I'm still experimentig with Oops Physics Component, seems very well built so far. Thanks for providing it for the community.

 Is there any drawback to using OopsFramework with quaternions instead of matrixes for orientation purposes?

Since there are #if QUATERNION_ORIENTATION throughout the code I tried to use them but there seems to be one function that isn't Quaternion compatible

 float function GetPenetrationDepth in BoxMeshCollisionDetector in lines 313 to 316:

 float projection0 =
 box.Extents.X * Math.Abs(axis.X * box.Orientation.M11 + axis.Y * box.Orientation.M12 + axis.Z * box.Orientation.M13) +
 box.Extents.Y * Math.Abs(axis.X * box.Orientation.M21 + axis.Y * box.Orientation.M22 + axis.Z * box.Orientation.M23)  +
 box.Extents.Z * Math.Abs(axis.X * box.Orientation.M31 + axis.Y * box.Orientation.M32 + axis.Z * box.Orientation.M33);

I believe this is the only part in the OopsFramework where it fails to build with the QUATERNION_ORIENTATION define.

Commenting these lines and setting some bogus value to projection0 enabled me to run the framework with Quaternions since I'm not using mesh based collisions. Aparently Quaternion code seems to run just fine

any input is welcomed

Edit reason: copying and pasting code messes up with the rest of the text

Coordinator
Nov 1, 2009 at 10:34 PM

I must have missed an area where Quaternions can be used when specifying the QUATERNION_ORIENTATION directive.  If you're not using box-mesh collision, doing what what you did should be okay until the next release.

The drawbacks to using Quaternions instead of Matrices is that the code hasn't been as optimized as the "Matrix" path and there's a bit more transformation to use results for things like drawing, since most drawing code requires matrices.  The benefits are memory usage and value type allocations, which are slower on the XBOX.  Allocating 4 floats (Quaternion) instead of 16 (Matrix) helps with performance on the XBOX.

Good luck!

Nov 12, 2009 at 12:54 AM

 Hello again.

 When I used the Oops Framework with Quaternions I inserted #define QUATERNION_ORIENTATION in every file that had the corresponding #if.

My question is:  Is there a more elegant way of doing this without spamming #defines that I missed?

thanks

Coordinator
Nov 13, 2009 at 5:09 AM

if you go to the projects Properties, on the Build tab you can specify them in the "Conditional compilation symbols" filed, separated by semicolons.  Then you don't need #define on each file.