Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (m_SphereMarching.cubeNumX != CubeCount)
        {
            m_SphereMarching = new SphereMarching(CubeCount, CubeCount, CubeCount);
        }

        m_SphereMarching.smoothEnable = smoothEnable;

        m_SphereMarching.sphere = new BoundingSphere
        {
            radius   = sphere.radius,
            position = sphere.transform.localPosition
        };
        m_SphereMarching.ReMaker();
        m_DynamicMesh.Clear();
        m_DynamicMesh.vertices  = m_SphereMarching.vertices;
        m_DynamicMesh.uv        = m_SphereMarching.uv;
        m_DynamicMesh.triangles = m_SphereMarching.triangles;
        m_DynamicMesh.normals   = m_SphereMarching.normal;
        if (!smoothEnable)
        {
            m_DynamicMesh.RecalculateNormals();
        }
    }
Example #2
0
 void Start()
 {
     m_MeshFilter     = this.GetComponent <MeshFilter>();
     m_SphereMarching = new SphereMarching(CubeCount, CubeCount, CubeCount);
     m_DynamicMesh    = new Mesh();
     m_DynamicMesh.MarkDynamic();
     m_MeshFilter.sharedMesh = m_DynamicMesh;
 }