示例#1
0
    static void ProcessPlyFile(string path)
    {
        Debug.Log("importing: " + path);

        // import .ply model
        var model = VoxelModelPly.LoadModel(path);

        // TODO : optimize

        // export
        ExportOBJ(model, path);
        //ExportFBX(model, path);
    }
示例#2
0
    static void ExportOBJ(VoxelModelPly model, string path)
    {
        // export texture
        string texPath = ChangeExtension(path, ".png");

        WritePng(texPath, model.tex);
        generatedTextures.Add(texPath);
        Debug.Log("generated " + texPath);
        texPath = texPath.Split('/')[texPath.Split('/').Length - 1];

        // export material
        string mtlPath = ChangeExtension(path, ".mtl");

        WriteTextFile(mtlPath, model.ToMtl(texPath));

        // export obj
        WriteTextFile(ChangeExtension(path, ".obj"), model.ToObj(mtlPath));
    }
示例#3
0
    // TODO : Optimizes mesh
    static void optimize(VoxelModelPly model)
    {
        // generate edgecount per vert [2,4,6,8]
        int[] edgeCount = new int[model.numVerts];
        for (var i = 0; i < model.numFaces; i++)
        {
            edgeCount[model.faces[i * 3]]     += 2;
            edgeCount[model.faces[i * 3 + 1]] += 2;
            edgeCount[model.faces[i * 3 + 2]] += 2;
        }


        // use only significant verts edgeCount = [2,4]
        // vertex part of (numEdges / 2) triangles. 1 & 2 means vertex is significant
        for (var i = 0; i < edgeCount.Length; i++)
        {
            Debug.Log(edgeCount[i]);
        }

        // generate outline per polygon


        // triangulate verts
    }
示例#4
0
 static void ExportFBX(VoxelModelPly model, string path)
 {
     WriteTextFile(ChangeExtension(path, ".fbx"), model.ToFBX(GetFilename(path)));
 }