Ejemplo n.º 1
0
    // Function for changing the colour of a whole array at once
    void MultipleObjectColourChange(List<GameObject> objects, int lowestBinNum, PColour mainColour)
    {
        // Set oarticular bins to colours so there are multiple colours in the scene at once
        if (lowestBinNum + objects.Count <= fftInt.avgBins.Length)
        {
            // loop through the array and run the ChasngeColour method
            for (int i = 0; i < objects.Count; i++)
            {
                if (i < 15)
                {
                    ChangeColour(objects[i], i + lowestBinNum, PColour.blue);
                }
                else if (i < 30)
                {
                    ChangeColour(objects[i], i + lowestBinNum, PColour.red);
                }
                else if (i > 30)
                {
                    ChangeColour(objects[i], i + lowestBinNum, PColour.green);
                }

            }
        }
        else
        {
            Debug.LogError("Not enough bins to support the highest bin number, The highest number the LowestBinNum can be is:" + (fftInt.avgBins.Length - objects.Count));
        }
    }
Ejemplo n.º 2
0
 // Method to change the colour of a light
 void LightColour(GameObject light, int binNum, PColour colour)
 {
     // Check there is a light
     if (light != null)
     {   // Set a light vairables to the components
         Light objectLight = light.GetComponent<Light>();
         // Set a new colour
         Color newColour = new Color();
         // Use switch to change the colour using the Pcolour enum
         switch (colour)
         {
             case PColour.red:
                 newColour = Color.red;
                 break;
             case PColour.green:
                 newColour = Color.green;
                 break;
             case PColour.blue:
                 newColour = Color.blue;
                 break;
             default:
                 break;
         }
         // Change the colour
         objectLight.color = newColour;
     }
 }
Ejemplo n.º 3
0
    // Changing lights in an array
    void MultipleLightObjectChange(List<GameObject> lights, int lowestBinNum, PColour colour)
    {
        if (lowestBinNum + lights.Count <= fftInt.avgBins.Length)
        {
            // loop through the array and run the ChangeColour method
            for (int i = 0; i < lights.Count; i++)
            {

                LightColour(lights[i], i + lowestBinNum, colour );
            }
        }
        else
        {
            Debug.LogError("Not enough bins to support the highest bin number, The highest number the LowestBinNum can be is:" + (fftInt.avgBins.Length - lights.Count));
        }
    }
Ejemplo n.º 4
0
    // Change the main colour of an object
    void ChangeColour(GameObject objectInScene, int binNum, PColour mainColour)
    {
        // Get the objects renderer
        Renderer objectRenderer = objectInScene.GetComponent<Renderer>();
        // New colour of the object using bins
        Color newColour = new Color(fftInt.avgBins[binNum], fftInt.avgBins[binNum], fftInt.avgBins[binNum], fftInt.avgBins[binNum]);
        // Switch to check what colour the user wants to use
        switch(mainColour)
        {
            case PColour.red:
                newColour.r = newColour.r * colourMultiplier;
                break;

            case PColour.green:
                newColour.g = newColour.g * colourMultiplier;
                break;
            case PColour.blue:
                newColour.b = newColour.b * colourMultiplier;
                break;
            default:
                break;
        }

        // Change the colour of the object
        objectRenderer.material.color =   newColour;
    }