Ejemplo n.º 1
0
        static void SetTriangle(Mesh mesh, fbxImporter.UPolygons polygons,
                                fbxImporter.UMaterialIndex matList)
        {
            if (polygons.polygon == null || polygons.polygon.Count == 0)
            {
                return;
            }

            List <int> matindexList;

            if (matList != null)
            {
                matindexList = matList.indexList;
            }
            else
            {
                matindexList = new List <int>();
            }

            if (matindexList.Count != polygons.polygon.Count)
            {
                matindexList = new List <int>();
                for (int i = 0; i < polygons.polygon.Count; ++i)
                {
                    matindexList.Add(0);
                }
            }

            var dicTriangle = new Dictionary <int, List <int> >();
            int baseIndex   = 0;

            for (int i = 0; i < polygons.polygon.Count; ++i)
            {
                List <int> indexlist = null;
                if (!dicTriangle.TryGetValue(matindexList[i], out indexlist))
                {
                    indexlist = new List <int>();
                    dicTriangle.Add(matindexList[i], indexlist);
                }
                int n = polygons.polygon[i].coordinates.Count;
                GenIndex(baseIndex, n, indexlist);
                baseIndex += n;
            }

            mesh.subMeshCount = dicTriangle.Keys.Count;

            var list = new List <KeyValuePair <int, List <int> > >(dicTriangle);

            list.Sort(delegate(KeyValuePair <int, List <int> > a, KeyValuePair <int, List <int> > b)
            {
                return(a.Key.CompareTo(b.Key));
            }
                      );


            for (int i = 0; i < list.Count; ++i)
            {
                mesh.SetTriangles(list[i].Value, i);
            }
        }
Ejemplo n.º 2
0
 static void RemoveUnusedMaterial(fbxImporter.UMaterialIndex matList, ref List <fbxImporter.UTextureInfo> texList)
 {
     for (int i = 0; i < texList.Count; ++i)
     {
         if (!IsTextureUsed(texList[i].materialId, matList))
         {
             texList.Remove(texList[i]);
         }
     }
 }
Ejemplo n.º 3
0
        static bool IsTextureUsed(int id, fbxImporter.UMaterialIndex matList)
        {
            bool bUsed = false;

            for (int i = 0; i < matList.indexList.Count; ++i)
            {
                if (id == matList.indexList[i])
                {
                    bUsed = true; break;
                }
            }
            return(bUsed);
        }