コード例 #1
0
ファイル: BulletXPlugin.cs プロジェクト: dirkhusemann/opensim
 //Next methods are extracted from XnaDevRu.BulletX(See 3rd party license):
 //- SetRotation (class MatrixOperations)
 //- GetRotation (class MatrixOperations)
 //- GetElement (class MathHelper)
 //- SetElement (class MathHelper)
 internal static void SetRotation(ref Matrix m, Quaternion q)
 {
     float d = q.LengthSquared();
     float s = 2f/d;
     float xs = q.X*s, ys = q.Y*s, zs = q.Z*s;
     float wx = q.W*xs, wy = q.W*ys, wz = q.W*zs;
     float xx = q.X*xs, xy = q.X*ys, xz = q.X*zs;
     float yy = q.Y*ys, yz = q.Y*zs, zz = q.Z*zs;
     m = new Matrix(1 - (yy + zz), xy - wz, xz + wy, 0,
                    xy + wz, 1 - (xx + zz), yz - wx, 0,
                    xz - wy, yz + wx, 1 - (xx + yy), 0,
                    m.M41, m.M42, m.M43, 1);
 }
コード例 #2
0
ファイル: BulletXPlugin.cs プロジェクト: dirkhusemann/opensim
 public static OpenMetaverse.Quaternion XnaQuaternionToQuaternion(Quaternion xnaQuaternion)
 {
     return new OpenMetaverse.Quaternion(xnaQuaternion.W, xnaQuaternion.X, xnaQuaternion.Y, xnaQuaternion.Z);
 }
コード例 #3
0
ファイル: BulletXPlugin.cs プロジェクト: dirkhusemann/opensim
        internal static float SetElement(ref Quaternion q, int index, float value)
        {
            switch (index)
            {
                case 0:
                    q.X = value;
                    break;
                case 1:
                    q.Y = value;
                    break;
                case 2:
                    q.Z = value;
                    break;
                case 3:
                    q.W = value;
                    break;
            }

            return 0;
        }