コード例 #1
0
        SCNMatrix4 MakeProjectionMatrix(UIInterfaceOrientation orientation)
        {
            const int bufferSize = 16;

            float[] projectionBuffer = new float[bufferSize];

            unsafe
            {
                fixed(float *ptr = &projectionBuffer[0])
                {
                    SDPlugin.SixDegreesSDK_GetProjection(ptr, bufferSize);
                }
            }

            var matrix = new Matrix4
            {
                Row0 = new Vector4(projectionBuffer[0], projectionBuffer[1], projectionBuffer[2], projectionBuffer[3]),
                Row1 = new Vector4(projectionBuffer[4], projectionBuffer[5], projectionBuffer[6], projectionBuffer[7]),
                Row2 = new Vector4(projectionBuffer[8], projectionBuffer[9], projectionBuffer[10], projectionBuffer[11]),
                Row3 = new Vector4(projectionBuffer[12], projectionBuffer[13], projectionBuffer[14], projectionBuffer[15])
            };

            var rotation = MakeInterfaceRotationRadians(orientation);

            var        matrixRotated = CreateMatrixFromRotation(rotation, 0, 0, 1);
            var        newMatrix     = matrix * matrixRotated;
            SCNMatrix4 poseMatrix    = new SCNMatrix4(newMatrix.Row0, newMatrix.Row1, newMatrix.Row2, newMatrix.Row3);

            return(poseMatrix);
        }