packages/Windows API Code Pack 1.1/source/Samples/DirectX/CS/UtilitiesLibrary/MeshLoader/XMeshLoader.cs
/// <summary>
/// Extracts the transformation associated with the current frame
/// </summary>
/// <param name="dataFile"></param>
/// <param name="dataOffset"></param>
/// <returns></returns>
Extracts the transformation associated with the current frame
Extracts the transformation associated with the current frame
private Matrix4x4F ExtractFrameTransformation(IXDataObject dataObject)
        {
            IXDataObject matrixObject = GetSingleChild(dataObject, "FrameTransformMatrix");
            if (matrixObject == null)
            {
                return Matrix4x4F.Identity;
            }
            string rawMatrixData = matrixObject.Body;
            Regex matrixData = new Regex(@"([-\d\.,\s]+);;");
            Match data = matrixData.Match(rawMatrixData);
            if(!data.Success)
                throw new System.IO.InvalidDataException("Error parsing frame transformation.");
            string[] values = data.Groups[1].ToString().Split(new char[] { ',' });
            if(values.Length != 16)
                throw new System.IO.InvalidDataException("Error parsing frame transformation.");
            float[] fvalues = new float[16];
            for(int n = 0; n < 16; n++)
            {
                fvalues[n] = float.Parse(values[n], CultureInfo.InvariantCulture);
            }
            return new Matrix4x4F(fvalues);
        }
private Matrix4x4F ExtractFrameTransformation ( IXDataObject dataObject ) { IXDataObject matrixObject = GetSingleChild ( dataObject , " " ) ; if ( matrixObject == null ) { return Matrix4x4F . Identity ; } string rawMatrixData = matrixObject . Body ; Regex matrixData = new Regex ( @"([-\d\.,\s]+);;" ) ; Match data = matrixData . Match ( rawMatrixData ) ; if ( ! data . Success ) throw new System . IO . InvalidDataException ( " " ) ; string [ ] values = data . Groups [ 1 ] . ToString ( ) . Split ( new char [ ] { ' ' } ) ; if ( values . Length != 16 ) throw new System . IO . InvalidDataException ( " " ) ; float [ ] fvalues = new float [ 16 ] ; for ( int n = 0 ; n < 16 ; n ++ ) { fvalues [ n ] = float . Parse ( values [ n ] , CultureInfo . InvariantCulture ) ; } return new Matrix4x4F ( fvalues ) ; }
Extracts the transformation associated with the current frame
Extracts the transformation associated with the current frame
None
dataObject
IXDataObject
dataFile
None
dataOffset
None