protected void HandleStatus(Message msg)
        {
            GenericStringPayload payload = JsonUtility.FromJson <GenericStringPayload>(msg.payload);

            bool value = bool.Parse(payload.payload);

            switch (payload.source)
            {
            case "Intensity":
                activeIntensity = value;
                // check last Detent
                if (activeIntensity && currentIntensity >= 0)
                {
                    //go to last detent
                    ArmStimulation.StimulateArm(
                        Part.OutwardsWrist,
                        Side.Right,
                        inDetentR,
                        current
                        );

                    targetIntensity = currentIntensity;
                }
                break;

            case "Color":
                activeColor = value;
                break;

            case "Thermo":
                activeThermo = value;
                break;
            }
        }
コード例 #2
0
        protected void HandleBoxTouchMsg(Message msg)
        {
            GenericStringPayload payload = JsonUtility.FromJson <GenericStringPayload>(msg.payload);

            float  t   = float.Parse(payload.payload);
            string src = payload.source;

            int width = (int)Mathf.Lerp(
                offsetTouchShoulder,
                src.Equals("Cube") ? touchShoulder : couchTouchShoulder,
                t * growthFactor);

            int width1 = (int)Mathf.Lerp(
                offsetTouchWrist,
                src.Equals("Cube") ? touchWrist : couchTouchWrist,
                t * growthFactor);

            if (t > 0)
            {
                Debug.Log("Touching: " + (t * growthFactor));
            }

            ArmStimulation.StimulateArm(
                //Part.Triceps,
                Part.Shoulder,
                Side.Right,
                width,
                currentShoulder
                );

            ArmStimulation.StimulateArm(
                Part.Wrist,
                Side.Right, // Wrist Extensor Right
                width1,
                currentWrist
                );

            stopTime    = DateTime.Now.AddMilliseconds(500);
            stimulating = true;
        }
コード例 #3
0
        protected void HandleBoxMovingMsg(Message msg)
        {
            GenericStringPayload payload = JsonUtility.FromJson <GenericStringPayload>(msg.payload);

            float t = float.Parse(payload.payload);

            Debug.Log("Moving:" + t);

            string src = payload.source;

            int width = (int)Mathf.Lerp(
                src.Equals("Cube") ? moveOffsetShoulder : moveCouchOffsetShoulder,
                src.Equals("Cube") ? moveShoulder : moveCouchShoulder,
                t);
            int width1 = (int)Mathf.Lerp(
                src.Equals("Cube") ? moveOffsetWrist : moveCouchOffsetWrist,
                src.Equals("Cube") ? moveWrist : moveCouchWrist,
                t);

            ArmStimulation.StimulateArm(
                //Part.Triceps,
                Part.Shoulder,
                Side.Right,
                width,
                currentShoulder
                );

            ArmStimulation.StimulateArm(
                Part.Wrist,
                Side.Right,
                //Side.Left, // Wrist extensor
                width1,
                currentWrist
                );

            stopTime = DateTime.Now.AddMilliseconds(500);
        }
        protected void HandleDial(Message msg)
        {
            GenericStringPayload payload = JsonUtility.FromJson <GenericStringPayload>(msg.payload);

            float t = float.Parse(payload.payload);

            //print(payload.source + ":" + t);

            int width = 0;

            switch (payload.source)
            {
            case "Intensity":
                if (t > 1 && activeIntensity)
                {
                    width = (int)Mathf.Lerp(0, inwardsR, t);
                    ArmStimulation.StimulateArm(
                        Part.InwardsWrist,
                        Side.Right,
                        width,
                        current
                        );
                    stimulatingIntensity = true;
                }
                else if (t < 0 && activeIntensity)
                {
                    width = (int)Mathf.Lerp(0, outwardsR, -t);
                    ArmStimulation.StimulateArm(
                        Part.OutwardsWrist,
                        Side.Right,
                        width,
                        current
                        );
                    stimulatingIntensity = true;
                }
                else if (stimulatingIntensity)
                {
                    stimulatingIntensity = false;
                    ArmStimulation.StimulateArm(
                        Part.InwardsWrist,
                        Side.Right,
                        0,
                        0
                        );
                    ArmStimulation.StimulateArm(
                        Part.OutwardsWrist,
                        Side.Right,
                        0,
                        0
                        );
                }
                break;

            case "Color":

                if (t > 1 && activeColor)
                {
                    width = (int)Mathf.Lerp(0, inwardsL, t);
                    ArmStimulation.StimulateArm(
                        Part.InwardsWrist,
                        Side.Left,
                        width,
                        current
                        );
                    stimulatingColor = true;
                }
                else if (t < 0 && activeColor)
                {
                    width = (int)Mathf.Lerp(0, outwardsL, -t);
                    ArmStimulation.StimulateArm(
                        Part.OutwardsWrist,
                        Side.Left,
                        width,
                        current
                        );
                    stimulatingColor = true;
                }
                else if (stimulatingColor)
                {
                    ArmStimulation.StimulateArm(
                        Part.InwardsWrist,
                        Side.Left,
                        0,
                        0
                        );
                    ArmStimulation.StimulateArm(
                        Part.OutwardsWrist,
                        Side.Left,
                        0,
                        0
                        );

                    stimulatingColor = false;
                }
                break;

            case "Thermo":

                if (t > 1 && activeThermo)
                {
                    width = (int)Mathf.Lerp(0, inwardsR, t);
                    ArmStimulation.StimulateArm(
                        Part.InwardsWrist,
                        Side.Right,
                        width,
                        current
                        );
                    stimulatingIntensity = true;
                }
                else if (t < 0 && activeThermo)
                {
                    width = (int)Mathf.Lerp(0, outwardsR, -t);
                    ArmStimulation.StimulateArm(
                        Part.OutwardsWrist,
                        Side.Right,
                        width,
                        current
                        );
                    stimulatingIntensity = true;
                }
                else if (stimulatingIntensity)
                {
                    stimulatingIntensity = false;
                    ArmStimulation.StimulateArm(
                        Part.InwardsWrist,
                        Side.Right,
                        0,
                        0
                        );
                    ArmStimulation.StimulateArm(
                        Part.OutwardsWrist,
                        Side.Right,
                        0,
                        0
                        );
                }
                break;
            }
        }