コード例 #1
0
        public static void Export(BF2SkinnedMesh mesh, string filename, int geoMatIdx)
        {
            StringBuilder sb = new StringBuilder();

            Helper.BF2MeshSKMGeometryMaterial lod0 = mesh.geomat[geoMatIdx];
            int vertexcounter = 1;

            for (int i = 0; i < lod0.numMaterials; i++)
            {
                Helper.BF2MeshSKMMaterial          mat  = lod0.materials[i];
                List <RenderObject.VertexTextured> list = new List <RenderObject.VertexTextured>();
                int m = mesh.geometry.vertices.Count / (int)mesh.geometry.numVertices;
                for (int j = 0; j < mat.numIndicies; j++)
                {
                    int pos = (mesh.geometry.indices[(int)mat.indiciesStartIndex + j] + (int)mat.vertexStartIndex) * m;
                    list.Add(mesh.GetVertex(pos));
                }
                if (mat.numIndicies != 0)
                {
                    WriteObject(sb, list, "Material" + i, vertexcounter);
                    vertexcounter += list.Count();
                }
            }
            File.WriteAllText(filename, sb.ToString());
        }
コード例 #2
0
        public List <RenderObject> ConvertForEngine(Engine3D engine, bool loadTextures, int geoMatIdx)
        {
            List <RenderObject> result = new List <RenderObject>();

            if (geoMatIdx >= geomat.Count)
            {
                geoMatIdx = geomat.Count() - 1;
            }
            Helper.BF2MeshSKMGeometryMaterial lod0 = geomat[geoMatIdx];
            for (int i = 0; i < lod0.numMaterials; i++)
            {
                Helper.BF2MeshSKMMaterial mat = lod0.materials[i];
                Texture2D texture             = null;
                if (loadTextures)
                {
                    foreach (string path in mat.textureMapFiles)
                    {
                        texture = engine.textureManager.FindTextureByPath(path);
                        if (texture != null)
                        {
                            break;
                        }
                    }
                }
                if (texture == null)
                {
                    texture = engine.defaultTexture;
                }
                List <RenderObject.VertexTextured> list = new List <RenderObject.VertexTextured>();
                //List<RenderObject.VertexWired> list2 = new List<RenderObject.VertexWired>();
                int m = geometry.vertices.Count / (int)geometry.numVertices;
                for (int j = 0; j < mat.numIndicies; j++)
                {
                    int pos = (geometry.indices[(int)mat.indiciesStartIndex + j] + (int)mat.vertexStartIndex) * m;
                    list.Add(GetVertex(pos));
                    //list2.Add(GetVector(pos));
                }
                if (mat.numIndicies != 0)
                {
                    RenderObject o = new RenderObject(engine.device, RenderObject.RenderType.TriListTextured, texture, engine);
                    o.verticesTextured = list.ToArray();
                    o.InitGeometry();
                    result.Add(o);
                    //RenderObject o2 = new RenderObject(engine.device, RenderObject.RenderType.TriListWired, texture, engine);
                    //o2.verticesWired = list2.ToArray();
                    //o2.InitGeometry();
                    //result.Add(o2);
                }
            }
            return(result);
        }