ecere/gfx/OpenGL/matrixStack: Flipped glmsRotated() signs to match OpenGL behavior
authorJerome St-Louis <jerome@ecere.com>
Mon, 18 Apr 2016 11:01:04 +0000 (07:01 -0400)
committerJerome St-Louis <jerome@ecere.com>
Thu, 28 Jul 2016 21:35:37 +0000 (17:35 -0400)
- API Change: ecere/gfx/3D/Quaternion: RotationAxis() now taking a Vector3D instead of a Vector3Df

ecere/src/gfx/3D/Quaternion.ec
ecere/src/gfx/3D/models/Object3DSFormat.ec
ecere/src/gfx/drivers/gl3/matrixStack.ec

index 80a2d57..17be262 100644 (file)
@@ -109,15 +109,15 @@ public struct Quaternion
       z =  q2.w * q1.z + q2.x * q1.y - q2.y * q1.x - q2.z * q1.w;
    }
 
-   void RotationAxis(Vector3Df axis, Degrees angle)
+   void RotationAxis(Vector3D axis, Degrees angle)
    {
       double sa = sin( angle / 2 );
       double ca = cos( angle / 2 );
 
-      x = (double)(axis.x * sa);
-      y = (double)(axis.y * sa);
-      z = (double)(axis.z * sa);
-      w = (double)ca;
+      x = axis.x * sa;
+      y = axis.y * sa;
+      z = axis.z * sa;
+      w = ca;
    }
 
    void RotationYawPitchRoll(Euler euler)
index 80ccae2..9bdf512 100644 (file)
@@ -1623,12 +1623,10 @@ static bool ReadFrameInfoBlock(FileInfo * info, ObjectInfoBlock * block)
                   {
                      Vector3Df axis;
                      Angle angle = ReadFloat(info->f);
-                     Vector3Df fixedAxis;
+                     Vector3D fixedAxis;
 
                      Read3DVertex(info->f, axis);
-                     fixedAxis.x = axis.x;
-                     fixedAxis.y = -axis.z;
-                     fixedAxis.z = axis.y;
+                     fixedAxis = { axis.x, -axis.z, axis.y };
 
                      if(c > 0)
                      {
index e3a5fce..37f7d60 100644 (file)
@@ -250,12 +250,14 @@ public void glmsFrustum( double l, double r, double b, double t, double n, doubl
    }
 }
 
-public void glmsRotated( double a, double b, double c, double d )
+public void glmsRotated(double angle, double x, double y, double z)
 {
    Quaternion q;
    Matrix m, r;
+   Vector3D n;
 
-   q.RotationAxis({(float)b,(float)c,(float)-d}, a );
+   n.Normalize({ -x, -y, -z });
+   q.RotationAxis(n, angle);
    m.RotationQuaternion(q);
    r.Multiply(m, matrixStack[curStack][matrixIndex[curStack]]);
    matrixStack[curStack][matrixIndex[curStack]] = r;