public void CalculateHeight()
    {
        _heightMap = (float[, ])MyChladni.GetVibrations().Clone();
        if (_heightMap == null)
        {
            _heightMap = new float[100, 100];
            for (int i = 0; i < 100; i++)
            {
                for (int j = 0; j < 100; j++)
                {
                    _heightMap[i, j] = Random.Range(0.0f, 0.01f);
                }
            }
        }

        poly = new Vector3[_heightMap.LongLength];
        int ArrayLength1 = _heightMap.GetLength(0);
        int ArrayLength2 = _heightMap.GetLength(1);
        int idx          = 0;

        for (int i = 0; i < ArrayLength1; i++)
        {
            for (int j = 0; j < ArrayLength2; j++)
            {
                if (i == 0 || i == ArrayLength1 - 1 || j == 0 || j == ArrayLength2 - 1)
                {
                    poly[idx++] = new Vector3(i, -EdgeLength, j);
                }
                else
                {
                    poly[idx++] = new Vector3(i, _heightMap[i, j] * 2.0f * _amplitude, j);
                }
            }
        }
    }
예제 #2
0
    public void SetPattern(Chladni pChladni)
    {
        _heightMap = (float[, ])pChladni.GetVibrations().Clone();

        //RenderTexture rt = new RenderTexture(1920, 1080, 24);
        //mainCamera.targetTexture = rt;
        //_screenShot = new Texture2D(1080, 1080, TextureFormat.RGB24, false);
        //mainCamera.Render();
        //RenderTexture.active = rt;
        //_screenShot.ReadPixels(new Rect(420, 0, 1080, 1080), 0, 0);
        //_screenShot.Apply();
        //mainCamera.targetTexture = null;
        //RenderTexture.active = null;
        //Destroy(rt);

        //string filename = "meh";

        ////byte[] bytes = _screenShot.EncodeToPNG();
        ////System.IO.File.WriteAllBytes(filename, bytes);

        //Debug.Log(string.Format("Took screenshot to: {0}", filename));

        //GameObject.Find("Cartridge").GetComponent<MeshRenderer>().material.mainTexture = _screenShot;
    }