Exemplo n.º 1
0
        public WindStruct WindAt(float x, float y)
        {
            float bltrDifference = m_heightMapGenerator.HeightAt(x + 1, y + 1) - m_heightMapGenerator.HeightAt(x - 1, y - 1);
            float brtlDifference = m_heightMapGenerator.HeightAt(x + 1, y - 1) - m_heightMapGenerator.HeightAt(x - 1, y + 1);

            return(new WindStruct
            {
                angle = Mathf.Atan((bltrDifference + brtlDifference) / (bltrDifference - brtlDifference)),
                strength = 1f
            });
        }
Exemplo n.º 2
0
    public void SetTexture()
    {
        if (meshRenderer == null)
        {
            return;
        }
        if (texWidth <= 0 || texLength <= 0)
        {
            return;
        }
        if (texScale == 0f)
        {
            return;
        }

        Texture2D tex = new Texture2D(texWidth, texLength);

        for (int i = 0; i < texWidth; i++)
        {
            for (int j = 0; j < texLength; j++)
            {
                tex.SetPixel(i, j, colors.Evaluate(hmGenerator.HeightAt(((float)i) / texWidth, ((float)j) / texLength)));
            }
        }

        tex.Apply();
        tex.wrapMode   = TextureWrapMode.Clamp;
        tex.filterMode = FilterMode.Point;
        tex.name       = "Procedural texture";

        meshRenderer.sharedMaterial.mainTexture = tex;
    }
Exemplo n.º 3
0
 public float HeightAt(float x, float y)
 {
     return(generatorA.HeightAt(x, y) * generatorB.HeightAt(x, y));
 }