Engines/FlatRedBallXNA/FlatRedBall.Content/ModelAnimation/X File/XMeshImporter.cs
/// <summary>
/// Reads in the vertex positions and vertex indices for the mesh
/// </summary>
Reads in the vertex positions and vertex indices for the mesh
Reads in the vertex positions and vertex indices for the mesh
private void InitializeMesh()
            {
                int numVerts = -1;
                int i = -1;
                try
                {
                    numVerts = tokens.NextInt();
                    for (i = 0; i < numVerts; i++)
                    {
                        skinInfo.Add(new BoneWeightCollection());
                        Vector3 v = tokens.NextVector3();
                        v.Z *= -1;
                        mesh.Positions.Add(v);
                    }
                }
                catch (Exception e)
                {
                    throw new Exception("Error trying to parse the verts.  The model claims to have " + numVerts + " verts.  We were able to parse " + i + " verts");
                }
                int numFaces = -1;
                i = -1;
                try
                {
                    numFaces = tokens.NextInt();
                    faces = new Face[numFaces];
                    for (i = 0; i < numFaces; i++)
                    {
                        int numVertsPerFace = tokens.NextInt();
                        faces[i].VertexIndices = new int[numVertsPerFace];
                        for (int j = 0; j < numVertsPerFace; j++)
                            faces[i].VertexIndices[j] = tokens.NextInt();
                        tokens.SkipToken();
                    }
                }
                catch (Exception e)
                {
                    string error = "Error trying to parse the faces.  The model claims to have " + numFaces + " faces.  We were able to parse " + i + " faces";
                    error += "\nThe parser parsed " + numVerts + " verts.  Should there really be that many?";
                    throw new Exception(error);
                }
            }
private void InitializeMesh ( ) { int numVerts = - 1 ; int i = - 1 ; try { numVerts = tokens . NextInt ( ) ; for ( i = 0 ; i < numVerts ; i ++ ) { skinInfo . Add ( new BoneWeightCollection ( ) ) ; Vector3 v = tokens . NextVector3 ( ) ; v . Z *= - 1 ; mesh . Positions . Add ( v ) ; } } catch ( Exception e ) { throw new Exception ( " " + numVerts + " " + i + " " ) ; } int numFaces = - 1 ; i = - 1 ; try { numFaces = tokens . NextInt ( ) ; faces = new Face [ numFaces ] ; for ( i = 0 ; i < numFaces ; i ++ ) { int numVertsPerFace = tokens . NextInt ( ) ; faces [ i ] . VertexIndices = new int [ numVertsPerFace ] ; for ( int j = 0 ; j < numVertsPerFace ; j ++ ) faces [ i ] . VertexIndices [ j ] = tokens . NextInt ( ) ; tokens . SkipToken ( ) ; } } catch ( Exception e ) { string error = " " + numFaces + " " + i + " " ; error += " \n " + numVerts + " " ; throw new Exception ( error ) ; } }
Reads in the vertex positions and vertex indices for the mesh
Reads in the vertex positions and vertex indices for the mesh
// This will turn into the ModelMeshPart //geom = new GeometryContent(); // mesh.Geometry.Add(geom); // read the verts and create one boneweight collection for each vert // which will represent that vertex's skinning info (which bones influence it // and the weights of each bone's influence on the vertex) // Reflect each vertex across z axis to convert it from left hand to right // hand // Add the indices that describe the order in which // the vertices are rendered