예제 #1
0
    void Refresh()
    {
        // refresh for a new mesh object
        vert.Clear();
        tri.Clear();
        uv.Clear();
        norm.Clear();

        // new sketch mesh object
        line = (GameObject)Instantiate(Resources.Load(prefab), Vector3.zero, Quaternion.identity);

        if (prefab == "SketchMeshThreePrefab")
        {
            // assign mesh
            mesh = new Mesh();
            line.GetComponent <MeshFilter> ().mesh = mesh;
            // assign material, texture, color
            line.GetComponent <MeshRenderer> ().material.color       = col;
            line.GetComponent <MeshRenderer> ().material.mainTexture = lineTexture;
        }
        else if (prefab == "Metaball")
        {
            // assign mesh
            mesh = new Mesh();
            line.transform.Find("StaticMesh").GetComponent <MeshFilter> ().mesh = mesh;
            // assign material, texture, color
            line.transform.Find("StaticMesh").GetComponent <MeshRenderer> ().material.color       = col;
            line.transform.Find("StaticMesh").GetComponent <MeshRenderer> ().material.mainTexture = lineTexture;
            // metaball
            seed = line.GetComponent <StaticMetaballSeed> ();
            // scale in overall to fit to VR scene
            line.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
        }

        points        = new List <Vector3>();
        lineWidthList = new List <float>();

        offsetsQuat = new List <Quaternion>();
        offsetsQuat.Add(Quaternion.identity);

        offsetsVec = new List <Vector3>();
        offsetsVec.Add(new Vector3(0, 0, 0));
    }