コード例 #1
0
        internal static unsafe void ConvertToD3DMATRIX(
            /* in */ Matrix *matrix,
            /* out */ D3DMATRIX *d3dMatrix
            )
        {
            *d3dMatrix = D3DMATRIXIdentity;

            float * pD3DMatrix = (float *)d3dMatrix;
            double *pMatrix    = (double *)matrix;

            // m11 = m11
            pD3DMatrix[0] = (float)pMatrix[0];

            // m12 = m12
            pD3DMatrix[1] = (float)pMatrix[1];

            // m21 = m21
            pD3DMatrix[4] = (float)pMatrix[2];

            // m22 = m22
            pD3DMatrix[5] = (float)pMatrix[3];

            // m41 = offsetX
            pD3DMatrix[12] = (float)pMatrix[4];

            // m42 = offsetY
            pD3DMatrix[13] = (float)pMatrix[5];
        }
コード例 #2
0
        internal static unsafe void ConvertFromD3DMATRIX(
            /* in */ D3DMATRIX *d3dMatrix,
            /* out */ Matrix *matrix
            )
        {
            float * pD3DMatrix = (float *)d3dMatrix;
            double *pMatrix    = (double *)matrix;

            //
            // Convert first D3DMatrix Vector
            //

            pMatrix[0] = (double)pD3DMatrix[0];  // m11 = m11
            pMatrix[1] = (double)pD3DMatrix[1];  // m12 = m12

            // Assert that non-affine fields are identity or NaN
            //
            // Multiplication with an affine 2D matrix (i.e., a matrix
            // with only _11, _12, _21, _22, _41, & _42 set to non-identity
            // values) containing NaN's, can cause the NaN's to propagate to
            // all other fields.  Thus, we allow NaN's in addition to
            // identity values.
            Debug.Assert(pD3DMatrix[2] == 0.0f || Single.IsNaN(pD3DMatrix[2]));
            Debug.Assert(pD3DMatrix[3] == 0.0f || Single.IsNaN(pD3DMatrix[3]));

            //
            // Convert second D3DMatrix Vector
            //

            pMatrix[2] = (double)pD3DMatrix[4];  // m21 = m21
            pMatrix[3] = (double)pD3DMatrix[5];  // m22 = m22
            Debug.Assert(pD3DMatrix[6] == 0.0f || Single.IsNaN(pD3DMatrix[6]));
            Debug.Assert(pD3DMatrix[7] == 0.0f || Single.IsNaN(pD3DMatrix[7]));

            //
            // Convert third D3DMatrix Vector
            //

            Debug.Assert(pD3DMatrix[8] == 0.0f || Single.IsNaN(pD3DMatrix[8]));
            Debug.Assert(pD3DMatrix[9] == 0.0f || Single.IsNaN(pD3DMatrix[9]));
            Debug.Assert(pD3DMatrix[10] == 1.0f || Single.IsNaN(pD3DMatrix[10]));
            Debug.Assert(pD3DMatrix[11] == 0.0f || Single.IsNaN(pD3DMatrix[11]));

            //
            // Convert fourth D3DMatrix Vector
            //

            pMatrix[4] = (double)pD3DMatrix[12];  // m41 = offsetX
            pMatrix[5] = (double)pD3DMatrix[13];  // m42 = offsetY
            Debug.Assert(pD3DMatrix[14] == 0.0f || Single.IsNaN(pD3DMatrix[14]));
            Debug.Assert(pD3DMatrix[15] == 1.0f || Single.IsNaN(pD3DMatrix[15]));

            *((MatrixTypes *)(pMatrix + 6)) = MatrixTypes.TRANSFORM_IS_UNKNOWN;
        }
コード例 #3
0
ファイル: D3DMATRIX.cs プロジェクト: zxmak/ZXMAK2
 public static unsafe D3DMATRIX *Transformation2D(
     D3DMATRIX *pOut, D3DXVECTOR2 *pScalingCenter,
     float ScalingRotation, D3DXVECTOR2 *pScaling,
     D3DXVECTOR2 *pRotationCenter, float Rotation,
     D3DXVECTOR2 *pTranslation)
 {
     return(NativeMethods.D3DXMatrixTransformation2D(
                pOut, pScalingCenter,
                ScalingRotation, pScaling,
                pRotationCenter, Rotation,
                pTranslation));
 }
コード例 #4
0
        internal unsafe virtual void ConvertToD3DMATRIX(/* out */ D3DMATRIX *milMatrix)
        {
            Matrix matrix = Value;

            MILUtilities.ConvertToD3DMATRIX(&matrix, milMatrix);
        }
コード例 #5
0
 public static extern unsafe D3DMATRIX *D3DXMatrixTransformation2D(
     D3DMATRIX *pOut, D3DXVECTOR2 *pScalingCenter,
     float ScalingRotation, D3DXVECTOR2 *pScaling,
     D3DXVECTOR2 *pRotationCenter, float Rotation,
     D3DXVECTOR2 *pTranslation);