Exemplo n.º 1
0
    void RecordData()
    {
        if (currentEEGCount > windowSize)
        {
            for (int i = windowSize - 2; i > 0; i--)
            {
                dataBuffer[i] = dataBuffer[i + 1];
            }
            dataBuffer[windowSize - 1] = EEGData.GetEEGData()[(int)channelToRecordFrom];
        }
        else
        {
            dataBuffer[currentEEGCount % windowSize] = EEGData.GetEEGData()[(int)channelToRecordFrom];
        }

        if (currentEEGCount < windowSize)
        {
            baselineArray[currentEEGCount] = EEGData.GetEEGData()[(int)channelToRecordFrom];
        }
        if (currentEEGCount == windowSize)
        {
            ProcessBaselinePowerSpectrum();
        }

        if ((currentEEGCount > windowSize) && ((currentEEGCount - windowSize) % 10 == 0))
        {
            ProcessData();
        }

        currentEEGCount++;
    }
Exemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     if (EEGData.GetEEGData()[1] != 0)
     {
         Vector3 currentPosition = cube.transform.position;
         Vector3 newPosition     = new Vector3(currentPosition.x, EEGData.GetRelativeFrequency(EEGData.EEG_BANDS.ALPHA) * maxHeight, currentPosition.z);
         cube.transform.position = Vector3.Lerp(currentPosition, newPosition, Time.deltaTime);
     }
 }
Exemplo n.º 3
0
 void RecordData()
 {
     lastEEGreceived    = currentEEGreceived;
     currentEEGreceived = EEGData.GetEEGData()[1];
     currentColour      = material.color;
     if (currentEEGreceived != lastEEGreceived)
     {
         newColour = new Color(1.0f - currentColour.r, 1.0f - currentColour.g, 1.0f - currentColour.b);
     }
     else
     {
         newColour = currentColour;
     }
     material.SetColor("_EmissionColor", Color.Lerp(currentColour, newColour, Time.deltaTime / Time.fixedDeltaTime));
 }
Exemplo n.º 4
0
    void RaiseTerrainUnderPointer()
    {
        RaycastHit hit   = pointerRenderer.GetDestinationHit();
        Vector3    point = hit.point;

        int   areax;
        int   areaz;
        float smoothing;
        int   terX = (int)((point.x / terrain.terrainData.size.x) * xResolution);
        int   terZ = (int)((point.z / terrain.terrainData.size.z) * zResolution);

        lenx += smooth;
        lenz += smooth;
        terX -= (lenx / 2);
        terZ -= (lenz / 2);
        if (terX < 0)
        {
            terX = 0;
        }
        if (terX > xResolution)
        {
            terX = xResolution;
        }
        if (terZ < 0)
        {
            terZ = 0;
        }
        if (terZ > zResolution)
        {
            terZ = zResolution;
        }

        float[,] heights = terrain.terrainData.GetHeights(terX, terZ, lenx, lenz);

        float rateMultiplier = 1f;

        if (EEGData.GetEEGData()[1] != 0)
        {
            rateMultiplier = GetRelativeAlpha();
        }

        float y = heights[lenx / 2, lenz / 2];

        y += maxRaiseRate * rateMultiplier;
        for (smoothing = 1; smoothing < smooth + 1; smoothing++)
        {
            float multiplier = smoothing / smooth;
            for (areax = (int)(smoothing / 2); areax < lenx - (smoothing / 2); areax++)
            {
                for (areaz = (int)(smoothing / 2); areaz < lenz - (smoothing / 2); areaz++)
                {
                    if ((areax > -1) && (areaz > -1) && (areax < xResolution) && (areaz < zResolution))
                    {
                        heights[areax, areaz] = Mathf.Clamp((float)y * multiplier, 0, 1);
                    }
                }
            }
        }
        lenx -= smooth;
        lenz -= smooth;

        UpdateObjectPositions(point, Mathf.Max(lenx, lenz), maxRaiseRate * rateMultiplier);

        terrain.terrainData.SetHeights(terX, terZ, heights);
        terrain.terrainData.RefreshPrototypes();
        TerrainCollider terrainCollider = terrain.GetComponent <TerrainCollider>();

        terrainCollider.terrainData = terrain.terrainData;
        terrain.Flush();
    }