コード例 #1
0
    void InitNormals(ref Vector3[] v, ref Vector3[] n)
    {
        if (mNormalsParent == null)
        {
            mNormalsParent      = new GameObject();
            mNormalsParent.name = "Normals";
            mNormalsParent.transform.SetParent(transform);
            mNormalsParent.transform.localScale    = Vector3.one;
            mNormalsParent.transform.localPosition = Vector3.zero;

            if (!showNormals)
            {
                mNormalsParent.SetActive(false);
            }
        }

        GameObject prefabBoundPoint = Resources.Load("Prefabs\\MeshPoint") as GameObject;

        mNormals = new BindedPoint[v.Length];
        for (int i = 0; i < v.Length; i++)
        {
            GameObject o = GameObject.Instantiate(prefabBoundPoint);
            o.transform.SetParent(mNormalsParent.transform);
            o.name = "Normal" + i;

            mNormals[i] = o.transform.GetComponentInChildren <BindedPoint>();
            mNormals[i].SetRadius(0.1f);             // Radius of the sphere
            mNormals[i].SetNormalWidth(0.002f);      // Width of the normal line
            mNormals[i].SetNormalHeight(0.5f);       // Height of the normal line
            mNormals[i].SetId(i);
            mNormals[i].MoveTo(v[i], v[i] + 1.0f * n[i]);
            mNormals[i].transform.hasChanged = false;

            vertexLocations.Add(o.transform); // add the vertex locations
            mNormals[i].onMove = UpdateMesh;

            if (i % numRows == 0)
            {
                o.AddComponent <Translatable>();
            }
            else
            {
                mNormals[i].gameObject.layer = 0;
                mNormals[i].GetComponent <MeshRenderer>().material.color = Color.black;
            }
        }
    }
コード例 #2
0
ファイル: QuadMesh.cs プロジェクト: a305/School_Projects
    void InitNormals(Vector3[] v, Vector3[] n)
    {
        if (mNormalsParent == null)
        {
            mNormalsParent      = new GameObject();
            mNormalsParent.name = "Normals";
            mNormalsParent.transform.SetParent(transform);
            mNormalsParent.transform.localScale    = Vector3.one;
            mNormalsParent.transform.localPosition = Vector3.zero;

            if (!showNormals)
            {
                mNormalsParent.SetActive(false);
            }
        }

        GameObject prefabBoundPoint = Resources.Load("Prefabs\\MeshPoint") as GameObject;

        mNormals = new BindedPoint[v.Length];
        for (int i = 0; i < v.Length; i++)
        {
            GameObject o = GameObject.Instantiate(prefabBoundPoint);
            o.transform.SetParent(mNormalsParent.transform);
            o.name = "Normal" + i;
            o.AddComponent <Translatable>();
            mNormals[i] = o.transform.GetComponentInChildren <BindedPoint>();
            mNormals[i].SetRadius(0.1f);             // Radius of the sphere
            mNormals[i].SetNormalWidth(0.002f);      // Width of the normal line
            mNormals[i].SetNormalHeight(0.5f);       // Height of the normal line
            mNormals[i].SetId(i);

            vertexLocations.Add(o.transform); // vertexlocations initialized
            mNormals[i].onMove = UpdateMesh;
        }
        UpdateNormals(v, n);
    }