Ejemplo n.º 1
0
        private void FingerForceDataReceivedHandler(Dictionary <Finger, double> fingerData)
        {
            if (m_isRunning)
            {
                NetOutMessage outMessage = new NetOutMessage();
                outMessage.WriteInt32((int)MessageType.Command.Data);

                foreach (Finger finger in fingerData.Keys)
                {
                    int    fingerNumber = (int)finger;
                    double value        = fingerData[finger] - m_appState.GetCurrentHandData().GetFingerBaseForce(finger);
                    if (value < 0.0)
                    {
                        value = 0.0;
                    }

                    BarGraph fingerGraph = GetFingerGraph(finger);
                    double   maxForce    = m_appState.GetCurrentHandData().GetFingerMaxForce(finger);
                    float    plotValue   = 0.0f;
                    if (!double.IsNaN(maxForce))
                    {
                        plotValue = (float)(value / maxForce * 100);
                        fingerGraph.PlotY(plotValue);
                    }

                    outMessage.WriteInt32(fingerNumber);
                    outMessage.WriteFloat(plotValue);
                }

                m_udpHelper.Send(outMessage, m_appState.HololensIP, Constants.NETWORK_PORT);
            }
        }
Ejemplo n.º 2
0
        private void SetForceScalingModeValue(bool newValue)
        {
            for (int i = 0; i < fingerForceGraphs.Count; i++)
            {
                fingerForceGraphs[i].gameObject.SetActive(!newValue);
            }

            for (int i = 0; i < noteActivatorControllers.Count; i++)
            {
                noteActivatorControllers[i].SetActive(!newValue);
            }

            for (int i = 0; i < forceScalingNoteActivators.Count; i++)
            {
                forceScalingNoteActivators[i].SetActive(newValue);
            }

            m_guitarHeroGameController.forceScalingMode = newValue;

            NetOutMessage outMessage = new NetOutMessage();

            outMessage.WriteInt32((int)MessageType.Command.Control);
            outMessage.WriteInt32((int)MessageType.ControlType.ChangeForceScalingMode);
            outMessage.WriteInt32(forceScalingModeToggle.isOn ? 1 : 0);

            m_udpHelper.Send(outMessage, m_appState.HololensIP, Constants.NETWORK_PORT);
        }
Ejemplo n.º 3
0
        private void NoteSpawnedHandler(Note noteSpawned, Vector3 locationInNoteLane)
        {
            NetOutMessage outMessage = new NetOutMessage();

            outMessage.WriteInt32((int)MessageType.Command.Control);
            if (forceScalingModeToggle.isOn)
            {
                outMessage.WriteInt32((int)MessageType.ControlType.SpawnForceScalingNote);
            }
            else
            {
                outMessage.WriteInt32((int)MessageType.ControlType.SpawnNote);
            }

            outMessage.WriteInt32(noteSpawned.noteLaneIndex);
            outMessage.WriteFloat(noteSpawned.duration);
            outMessage.WriteVector3(locationInNoteLane);

            if (forceScalingModeToggle.isOn)
            {
                outMessage.WriteFloat(noteSpawner.noteScales[noteSpawned.noteLaneIndex]);
            }

            m_udpHelper.Send(outMessage, m_appState.HololensIP, Constants.NETWORK_PORT);
        }
Ejemplo n.º 4
0
        private void Update()
        {
            if (m_isRunning)
            {
                m_measurementTimer += Time.deltaTime;
                if (m_measurementTimer >= m_measurementDuration)
                {
                    m_currentFingerIndex = GetNextFingerIndex();
                    if (m_currentFingerIndex != -1)
                    {
                        m_measurementTimer = 0.0f;

                        UpdateIndicators();
                        UpdateTargetForceLines();

                        NetOutMessage message = new NetOutMessage();
                        message.WriteInt32((int)MessageType.Command.Control);
                        message.WriteInt32((int)MessageType.ControlType.Start);
                        message.WriteInt32(m_currentFingerIndex);
                        for (int i = 0; i < 5; i++)
                        {
                            message.WriteInt32(i);
                            message.WriteDouble(GetFingerGraph((Finger)i).targetValue);
                        }
                        m_udpHelper.Send(message, m_appState.HololensIP, Constants.NETWORK_PORT);
                    }
                    else
                    {
                        StopMeasurement();
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private void FingerForceDataReceivedHandler(Dictionary <Finger, double> fingerData)
        {
            if (m_isRunning)
            {
                double val = 0;
                foreach (Finger finger in fingerData.Keys)
                {
                    double value = fingerData[finger] - m_appState.GetCurrentHandData().GetFingerBaseForce(finger);
                    if (value < 0.0)
                    {
                        value = 0.0;
                    }

                    Toggle fingerToggle = GetFingerToggle(finger);
                    if (fingerToggle != null && fingerToggle.isOn)
                    {
                        val += value;
                    }
                }

                lineGraph.Plot(m_forceTrackTime, val, Constants.FORCE_PLOT_SERIES_NAME);

                if (!string.IsNullOrEmpty(m_appState.HololensIP))
                {
                    NetOutMessage outMessage = new NetOutMessage();
                    outMessage.WriteInt32((int)MessageType.Command.Data);
                    outMessage.WriteFloat(m_forceTrackTime);
                    outMessage.WriteFloat((float)val);
                    m_udpHelper.Send(outMessage, m_appState.HololensIP, Constants.NETWORK_PORT);
                }
            }
        }
Ejemplo n.º 6
0
        private void SongStoppedPlayingHandler()
        {
            NetOutMessage outMessage = new NetOutMessage();

            outMessage.WriteInt32((int)MessageType.Command.Control);
            outMessage.WriteInt32((int)MessageType.ControlType.StopSong);

            m_udpHelper.Send(outMessage, m_appState.HololensIP, Constants.NETWORK_PORT);
        }
Ejemplo n.º 7
0
        private void StartMeasurement()
        {
            m_isRunning = true;

            // Disable the start button if we're running the measurements.
            // Enable the stop button as a result.
            startButton.interactable = false;
            stopButton.interactable  = true;

            m_forceTrackTime = 0.0f;

            lineGraph.ClearPlot(Constants.FORCE_PLOT_SERIES_NAME);

            NetOutMessage outMessage = new NetOutMessage();

            outMessage.WriteInt32((int)MessageType.Command.Control);
            outMessage.WriteInt32((int)MessageType.ControlType.Start);

            List <Finger> fingersToPress = new List <Finger>();

            for (int i = 0; i < 5; i++)
            {
                Finger temp   = (Finger)i;
                Toggle toggle = GetFingerToggle(temp);
                if (toggle.isOn)
                {
                    fingersToPress.Add(temp);
                }
            }

            outMessage.WriteInt32(fingersToPress.Count);
            for (int i = 0; i < fingersToPress.Count; i++)
            {
                outMessage.WriteInt32((int)fingersToPress[i]);
            }

            double totalMaxForce = 0.0;

            foreach (Finger finger in Constants.FINGER_LIST)
            {
                totalMaxForce += m_appState.GetCurrentHandData().GetFingerMaxForce(finger) - m_appState.GetCurrentHandData().GetFingerBaseForce(finger);
            }
            lineGraph.maxY = (float)totalMaxForce;

            outMessage.WriteDouble(totalMaxForce);
            outMessage.WriteFloat(m_appState.StaticPhaseDuration);
            outMessage.WriteFloat(m_appState.IncreasingPhaseDuration);
            outMessage.WriteFloat(m_appState.PlateauPhaseDuration);
            outMessage.WriteFloat(m_appState.DecreasingPhaseDuration);
            outMessage.WriteFloat(m_appState.StaticEndPhaseDuration);
            outMessage.WriteDouble(GetPlateauPhaseValue());

            m_udpHelper.Send(outMessage, m_appState.HololensIP, Constants.NETWORK_PORT);
        }
Ejemplo n.º 8
0
        private void MusicPlayToggleValueChanged(bool newValue)
        {
            if (newValue)
            {
                NetOutMessage message = new NetOutMessage();
                message.WriteInt32((int)MessageType.Command.ModeSet);
                message.WriteInt32((int)MessageType.Mode.MusicPlay);

                m_udpHelper.Send(message, m_appState.HololensIP, Constants.NETWORK_PORT);

                SetMode(AppMode.MusicPlay);
            }
        }
Ejemplo n.º 9
0
        public void StopRun()
        {
            m_guitarHeroGameController.songPlayer.StopCurrentSong();

            noteSpawner.DeleteAllNotes();

            NetOutMessage outMessage = new NetOutMessage();

            outMessage.WriteInt32((int)MessageType.Command.Control);
            outMessage.WriteInt32((int)MessageType.ControlType.StopSong);

            m_udpHelper.Send(outMessage, m_appState.HololensIP, Constants.NETWORK_PORT);

            startButton.interactable = true;
            stopButton.interactable  = false;
        }
Ejemplo n.º 10
0
        private async void InternalSend(NetOutMessage message, string destIP, int destPort)
        {
            HostName partnerHostName = new HostName(destIP);

            using (IOutputStream stream = await m_udpSocket.GetOutputStreamAsync(partnerHostName, destPort.ToString()))
            {
                using (DataWriter writer = new DataWriter(stream))
                {
                    byte[] data = message.GetMessageBytes();

                    writer.WriteInt32(data.Length);
                    writer.WriteBytes(data);

                    await writer.StoreAsync();
                }
            }
        }
Ejemplo n.º 11
0
        private void StopMeasurement()
        {
            m_isRunning = false;

            // Enable the start button after stopping the measurement.
            // Disable the stop button as a result.
            startButton.interactable = true;
            stopButton.interactable  = false;

            UpdateIndicators();
            ResetGraphs();

            NetOutMessage message = new NetOutMessage();

            message.WriteInt32((int)MessageType.Command.Control);
            message.WriteInt32((int)MessageType.ControlType.Stop);
            m_udpHelper.Send(message, m_appState.HololensIP, Constants.NETWORK_PORT);
        }
Ejemplo n.º 12
0
        private void InternalSend(NetOutMessage message, string ip, int port)
        {
            IPAddress ipAddress = null;

            if (!IPAddress.TryParse(ip, out ipAddress))
            {
                return;
            }

            IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, port);

            byte[] messageBytes = message.GetMessageBytes();

            NetOutMessage modifiedMessage = new NetOutMessage();

            modifiedMessage.WriteInt32(messageBytes.Length);
            modifiedMessage.WriteBytes(messageBytes);

            m_udpClient.Send(modifiedMessage.GetMessageBytes(), modifiedMessage.GetMessageBytes().Length, ipEndPoint);
        }
Ejemplo n.º 13
0
        private void UpdateForceIndicator(int index)
        {
            Finger finger = (Finger)index;

            float  forceLeeway     = GetForceLeewayValue();
            double maxFingerForce  = m_appState.GetCurrentHandData().GetFingerMaxForce(finger) - m_appState.GetCurrentHandData().GetFingerBaseForce(finger);
            float  forcePercentage = GetFingerForcePercentage(index);

            float targetValue = (float)maxFingerForce * forcePercentage;

            float forceThresholdMin = Mathf.Clamp((float)maxFingerForce * (forcePercentage - forceLeeway / 2.0f), (float)m_appState.GetCurrentHandData().GetFingerBaseForce(finger), (float)maxFingerForce);
            float forceThresholdMax = Mathf.Clamp((float)maxFingerForce * (forcePercentage + forceLeeway / 2.0f), (float)m_appState.GetCurrentHandData().GetFingerBaseForce(finger), (float)maxFingerForce);

            m_fingerInputController.fingerForceMinThresholds[index] = forceThresholdMin;
            m_fingerInputController.fingerForceMaxThresholds[index] = forceThresholdMax;

            fingerForceGraphs[index].minTargetValue = Mathf.FloorToInt((float)(forceThresholdMin / maxFingerForce) * 100.0f);
            fingerForceGraphs[index].maxTargetValue = Mathf.FloorToInt((float)(forceThresholdMax / maxFingerForce) * 100.0f);

            forceScalingNoteActivators[index].GetComponent <ForceScalingNoteActivatorController>().SetForceRangePercentage((float)(forceThresholdMin / maxFingerForce) * 100.0f, (float)(forceThresholdMax / maxFingerForce) * 100.0f);

            noteSpawner.noteScales[index] = forcePercentage;

            NetOutMessage outMessage = new NetOutMessage();

            outMessage.WriteInt32((int)MessageType.Command.Control);
            outMessage.WriteInt32((int)MessageType.ControlType.InitVisualizations);

            for (int i = 0; i < 5; i++)
            {
                outMessage.WriteInt32(i);

                outMessage.WriteFloat(fingerForceGraphs[i].minTargetValue);
                outMessage.WriteFloat(fingerForceGraphs[i].maxTargetValue);
            }

            m_udpHelper.Send(outMessage, m_appState.HololensIP, Constants.NETWORK_PORT);
        }
Ejemplo n.º 14
0
        private void StartMeasurement()
        {
            m_remainingFingers.Clear();
            for (int i = 0; i < 5; i++)
            {
                m_remainingFingers.Add((Finger)i);
            }

            m_currentFingerIndex = GetNextFingerIndex();
            if (m_currentFingerIndex < 0)
            {
                return;
            }

            m_isRunning = true;

            // Disable the start button if we're running the measurements.
            // Enable the stop button as a result.
            startButton.interactable = false;
            stopButton.interactable  = true;

            m_measurementTimer = 0.0f;

            UpdateIndicators();
            UpdateTargetForceLines();

            NetOutMessage message = new NetOutMessage();

            message.WriteInt32((int)MessageType.Command.Control);
            message.WriteInt32((int)MessageType.ControlType.Start);
            message.WriteInt32(m_currentFingerIndex);
            for (int i = 0; i < 5; i++)
            {
                message.WriteInt32(i);
                message.WriteDouble(GetFingerGraph((Finger)i).targetValue);
            }
            m_udpHelper.Send(message, m_appState.HololensIP, Constants.NETWORK_PORT);
        }
Ejemplo n.º 15
0
        private void FingerForceDataReceivedHandler(Dictionary <Finger, double> fingerData)
        {
            NetOutMessage outMessage = new NetOutMessage();

            outMessage.WriteInt32((int)MessageType.Command.Data);

            foreach (Finger finger in fingerData.Keys)
            {
                outMessage.WriteInt32((int)finger);

                double adjustedForceValue = fingerData[finger] - m_appState.GetCurrentHandData().GetFingerBaseForce(finger);
                double adjustedMaxValue   = m_appState.GetCurrentHandData().GetFingerMaxForce(finger) - m_appState.GetCurrentHandData().GetFingerBaseForce(finger);
                float  percentage         = (float)(adjustedForceValue / adjustedMaxValue * 100.0f);

                fingerForceGraphs[(int)finger].value = Mathf.FloorToInt(percentage);

                outMessage.WriteFloat(percentage);

                int fingerIndex = (int)finger;
                forceScalingNoteActivators[fingerIndex].GetComponent <ForceScalingNoteActivatorController>().SetForcePercentage(percentage);
            }

            m_udpHelper.Send(outMessage, m_appState.HololensIP, Constants.NETWORK_PORT);
        }
Ejemplo n.º 16
0
 public void Send(NetOutMessage message, string destIP, int destPort)
 {
     InternalSend(message, destIP, destPort);
 }