Ejemplo n.º 1
0
 /// <summary>
 /// Constructor of the class.
 /// </summary>
 public HeatmapUnit(MeshRenderer renderer, HeatmapConfig conf)
 {
     this.renderer = renderer;
     this.conf     = conf;
     value         = conf.minHeatmapValue;
     this.renderer.material.color = conf.minHeatmapColor;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Script awakening.
        /// </summary>
        void Awake()
        {
            conf = GetComponent <HeatmapConfig>();

            if (conf.heatmapUnitObject == null)
            {
                Debug.LogError("No heatmap unit object defined! ");
            }

            // Get the time controller
            timeCtrl = FindObjectOfType <TimeController>();

            // Initialize the tracked element lists
            flashPedElements = new List <Tuple <GameObject, float> >();
            vehElements      = new List <Tuple <GameObject, float> >();
            generalElements  = new List <Tuple <GameObject, float> >();

            // HACK: For the Stockholm case.
            vehicleScores = new List <Tuple <VehicleContainer, ScoreContainer> >();

            // Get the number of elements for row Z
            numberOfZElements = Mathf.FloorToInt((conf.maxCoordinates.z - conf.minCoordinates.z)
                                                 / (float)conf.heatmapUnitSize);

            // Get the number of elements for row X
            numberOfXElements = Mathf.FloorToInt((conf.maxCoordinates.x - conf.minCoordinates.x)
                                                 / (float)conf.heatmapUnitSize);

            //Initialize the heatmap first array
            heatmapArray = new HeatmapUnit[numberOfZElements][];

            float halfStep = conf.heatmapUnitSize / 2f;

            //Instantiate each heatmap unit in the scene
            for (int z = 0; z < numberOfZElements; z++)
            {
                //Initialize the heatmap second array
                heatmapArray[z] = new HeatmapUnit[numberOfXElements];

                //Create a new row of heatmap units
                for (int x = 0; x < numberOfXElements; x++)
                {
                    var go = Instantiate(conf.heatmapUnitObject) as GameObject;

                    go.transform.parent = this.transform;

                    // HACK: For the Stockholm case.
                    go.transform.position = new Vector3(conf.minCoordinates.x + x * conf.heatmapUnitSize + halfStep, 100.0f,
                                                        conf.minCoordinates.z + z * conf.heatmapUnitSize + halfStep);

                    go.transform.localScale = new Vector3(conf.heatmapUnitSize, conf.heatmapUnitSize * 5, conf.heatmapUnitSize);

                    var rend = go.transform.GetComponent <MeshRenderer>();

                    heatmapArray[z][x] = new HeatmapUnit(rend, conf);
                }
            }
        }