Exemplo n.º 1
0
    //handler for http request, draws reconstruction
    void HandleReconstructionDownload(AsyncOperation op)
    {
        UnityWebRequestAsyncOperation aop = (UnityWebRequestAsyncOperation)op;

        try
        {
            if (aop.webRequest.downloadHandler.data.Length == 0)
            {
                Debug.Log("Empty file");
            }
            else
            {
                Debug.Log("Reconstruction dowloaded");
                //Debug.Log(aop.webRequest.downloadHandler.text);

                meshClass result = JsonUtility.FromJson <meshClass>(aop.webRequest.downloadHandler.text);
                result.initialize();

                GameObject model = GameObject.Find("ReconstructionObject");
                MeshFilter mf    = model.GetComponent <MeshFilter>();
                mf.mesh.Clear();

                mf.mesh.vertices  = result.vertices;
                mf.mesh.triangles = result.faces;
                mf.mesh.colors    = result.colours;

                //mf.mesh = mesh;

                Debug.Log("Mesh drawn");
            }
        }
        catch (ArgumentException e)
        {
            Debug.Log("Something wrong with the reconstruction");
            Debug.Log("Please restart");
        }
    }
Exemplo n.º 2
0
    //handler for http request
    void HandleModelDownload(AsyncOperation op)
    {
        UnityWebRequestAsyncOperation aop = (UnityWebRequestAsyncOperation)op;

        meshClass result = JsonUtility.FromJson <meshClass>(aop.webRequest.downloadHandler.text);

        result.initialize();

        Mesh mesh = new Mesh();

        // GetComponent<MeshFilter>().mesh = mesh;

        /*Debug.Log(result.vertices[0][0]);
        *  Debug.Log(result.vertices[0][1]);
        *  Debug.Log(result.vertices[0][2]);*/
        mesh.vertices = result.vertices;
        //mesh.uv = newUV;

        /*Debug.Log(result.faces[0]);
        *  Debug.Log(result.faces[1]);
        *  Debug.Log(result.faces[2]);*/
        mesh.triangles = result.faces;

        mesh.uv = result.uv;

        // mesh.colors = result.colours;
        GameObject model = GameObject.Find("ReconstructionObject");
        MeshFilter mf    = model.GetComponent <MeshFilter>();

        mesh.RecalculateNormals();
        mf.mesh = mesh;


        DownloadTexture();
        //Debug.Log(aop.webRequest.downloadHandler.text);
    }