Exemple #1
0
    //"/Users/mrs/Projects/Power Offense/Assets/chic fashion gothic collar.duf"

    private void Start()
    {
        DSF dsf = Utility.LoadDSF(Filepath);

        Debug.Log(dsf.asset_info.contributor.author);
        Debug.Log(dsf.file_version);

        GameObject simple_mesh = new GameObject("DSF_Object");

        generateMesh(simple_mesh, dsf, out Vector3[] vertexData, out int[] indices);
        if (doubleSided)
        {
            GameObject second_mesh = new GameObject("DSF_Object_inverse");
            Vector3    object_pos  = new Vector3(0, 0.5f, 0);
            Quaternion object_rot  = new Quaternion(0, 0, 0, 0);
            second_mesh.transform.position = object_pos;
            second_mesh.transform.rotation = object_rot;
            second_mesh.AddComponent <MeshFilter>();
            second_mesh.AddComponent <MeshRenderer>();
            second_mesh.GetComponent <MeshRenderer>().material = DefaultMaterial;
            Mesh mesh = second_mesh.GetComponent <MeshFilter>().mesh;
            mesh.name     = "inverted";
            mesh.vertices = vertexData;
            for (int i = 0; i < indices.Length; i += 3)
            {
                int temp = indices[i];
                indices[i]     = indices[i + 1];
                indices[i + 1] = temp;
            }
            mesh.SetIndices(indices, MeshTopology.Triangles, 0);
            mesh.RecalculateNormals();
        }
    }
Exemple #2
0
        static void Main(string[] args)
        {
            //calc();
            DSF sF = new DSF();
            var s  = sF.getPathBFS(37, 9);

            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.White;
            var i = 0;

            while (s.getParent() != null)
            {
                i++;
                s = s.getParent();
            }
            Console.WriteLine(i + 1 /* because it doesn't count where it ends */);
            Console.ReadLine();
        }
Exemple #3
0
    private void generateMesh(GameObject simple_mesh, DSF dsf, out Vector3[] vertex_data, out int[] indices)
    {
        Vector3    object_pos = new Vector3(0, 0.5f, 0);
        Quaternion object_rot = new Quaternion(0, 0, 0, 0);

        simple_mesh.transform.position = object_pos;
        simple_mesh.transform.rotation = object_rot;
        simple_mesh.AddComponent <MeshFilter>();
        simple_mesh.AddComponent <MeshRenderer>();
        simple_mesh.GetComponent <MeshRenderer>().material = DefaultMaterial;
        vertex_data = null;
        indices     = null;

        int submesh = 0;

        foreach (Geometry g in dsf.geometry_library)
        {
            Vertices vertices = g.vertices;
            vertex_data = new Vector3[vertices.count];

            for (int i = 0; i < vertices.count; i++)
            {
                vertex_data[i] = new Vector3(vertices.values[i][0], vertices.values[i][1], vertices.values[i][2]);
            }

            indices = buildIndices(g.polylist, out var isTriangles);

            Mesh mesh = simple_mesh.GetComponent <MeshFilter>().mesh;
            mesh.name     = g.name;
            mesh.vertices = vertex_data;
            if (isTriangles)
            {
                mesh.SetIndices(indices, MeshTopology.Triangles, submesh);
            }
            else
            {
                mesh.SetIndices(indices, MeshTopology.Quads, submesh);
            }

            mesh.RecalculateNormals();
            submesh++;
        }
    }
Exemple #4
0
    public int FindCircleNum(int[,] md)
    {
        var mat = ConvertMultiDimensionalToJagged <int>(md); // utils.cs

        DSF dsu = new DSF(numRows);

        for (int r = 0; r < numRows; r++)
        {
            for (int c = 0; c < numCols; c++)
            {
                if (r != c && mat[r][c] == 1)
                {
                    dsu.Union(dsu.FindSet(r), dsu.FindSet(c));
                }
            }
        }

        return(dsu.Count);
    }