Engines/FlatRedBallXNA/FlatRedBall.Content/ModelAnimation/X File/XMeshImporter.cs
/// <summary>
/// Creates the ModelMeshParts-to-be (geometry) by splitting up the mesh
/// via materials
/// </summary>
Creates the ModelMeshParts-to-be (geometry) by splitting up the mesh
via materials
Creates the ModelMeshParts - to - be ( geometry ) by splitting up the mesh via materials
public void CreateGeometry()
            {
                int numPartions = materials.Length == 0
                    ? 1 : materials.Length;
                List<Face>[] partitionedFaces = new List<Face>[numPartions];
                for (int i = 0; i < partitionedFaces.Length; i++)
                    partitionedFaces[i] = new List<Face>();
                for (int i = 0; i < faces.Length; i++)
                {
                    if (faces[i].VertexIndices.Length == 4)
                        partitionedFaces[faces[i].MaterialIndex].AddRange(
                            faces[i].ConvertQuadToTriangles());
                    else
                        partitionedFaces[faces[i].MaterialIndex].Add(faces[i]);
                }
                int index = 0;
                foreach (List<Face> faceList in partitionedFaces)
                {
                    GeometryContent geom = new GeometryContent();
                    mesh.Geometry.Add(geom);
                    for (int i = 0; i < faceList.Count * 3; i++)
                        geom.Indices.Add(i);
                    foreach (Face face in faceList)
                        geom.Vertices.AddRange(face.VertexIndices);              
                    if (materials.Length > 0)
                        geom.Material = materials[index++];
                }
                AddAllChannels();
            }
public void CreateGeometry ( ) { int numPartions = materials . Length == 0 ? 1 : materials . Length ; List < Face > [ ] partitionedFaces = new List < Face > [ numPartions ] ; for ( int i = 0 ; i < partitionedFaces . Length ; i ++ ) partitionedFaces [ i ] = new List < Face > ( ) ; for ( int i = 0 ; i < faces . Length ; i ++ ) { if ( faces [ i ] . VertexIndices . Length == 4 ) partitionedFaces [ faces [ i ] . MaterialIndex ] . AddRange ( faces [ i ] . ConvertQuadToTriangles ( ) ) ; else partitionedFaces [ faces [ i ] . MaterialIndex ] . Add ( faces [ i ] ) ; } int index = 0 ; foreach ( List < Face > faceList in partitionedFaces ) { GeometryContent geom = new GeometryContent ( ) ; mesh . Geometry . Add ( geom ) ; for ( int i = 0 ; i < faceList . Count * 3 ; i ++ ) geom . Indices . Add ( i ) ; foreach ( Face face in faceList ) geom . Vertices . AddRange ( face . VertexIndices ) ; if ( materials . Length > 0 ) geom . Material = materials [ index ++ ] ; } AddAllChannels ( ) ; }
Creates the ModelMeshParts-to-be (geometry) by splitting up the mesh
via materials
Creates the ModelMeshParts - to - be ( geometry ) by splitting up the mesh via materials
// Number of geometries to create // An array of the faces that each geometry will contain // Partion the faces.  Each face has a material index, and // each geometry has its own material, so the material index // refers to the geometry index for the face. // Add the partioned faces to their respective geometries // Add the channels to the geometries