void Awake() {
        if (Instance == null) {
            Instance = this;
        }
        //float terrainSizeRatio = terrainResolution / dimension;
        pixels = new Color[(dimension * dimension)];
        for (int i = 0; i < pixels.Length; i++) {
            //int x = i % (dimension);
            //int z = i / (dimension);

            //int positionX = (int)(terrainSizeRatio * x) - terrainOriginOffset;
            //int positionZ = (int)(terrainSizeRatio * z) - terrainOriginOffset;

            //Vector3 position = new Vector3(positionX + 1f, 0, positionZ + 1f);
            //var p = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            //p.transform.position = position;
            //p.isStatic = true;
            //p.name = "(" + x + ", " + z + ")";
            Color color = new Color(0, 0, 0, 0);
            pixels[i] = color;
        }

        tex = new Texture2D(dimension, dimension, TextureFormat.RGBA32, false);
        tex.filterMode = FilterMode.Point;
        tex.wrapMode = TextureWrapMode.Clamp;
        tex.SetPixels(pixels);
        tex.Apply();
    }
Example #2
0
    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        //float terrainSizeRatio = terrainResolution / dimension;
        pixels = new Color[(dimension * dimension)];
        for (int i = 0; i < pixels.Length; i++)
        {
            //int x = i % (dimension);
            //int z = i / (dimension);

            //int positionX = (int)(terrainSizeRatio * x) - terrainOriginOffset;
            //int positionZ = (int)(terrainSizeRatio * z) - terrainOriginOffset;

            //Vector3 position = new Vector3(positionX + 1f, 0, positionZ + 1f);
            //var p = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            //p.transform.position = position;
            //p.isStatic = true;
            //p.name = "(" + x + ", " + z + ")";
            Color color = new Color(0, 0, 0, 0);
            pixels[i] = color;
        }

        tex            = new Texture2D(dimension, dimension, TextureFormat.RGBA32, false);
        tex.filterMode = FilterMode.Point;
        tex.wrapMode   = TextureWrapMode.Clamp;
        tex.SetPixels(pixels);
        tex.Apply();
    }
Example #3
0
    public InfluenceMap(InfluenceType type, List <Region> regions, InfluenceMapManager influenceMapManager, float momentum, float decay)
    {
        MapType = type;

        Regions             = regions;
        InfluencesValues    = new float[Regions.Count];
        tempInfluenceValues = new float[Regions.Count];

        influenceSources = new List <InfluenceSource>();

        this.influenceMapManager = influenceMapManager;

        this.momentum = momentum;
        this.decay    = decay;
    }