コード例 #1
0
        private void ProcessRotationalTriggers()
        {
            Quaternion historicRot = GetHistoricValue(TwistThresholdMillis);
            Quaternion diff        = Quaternion.Inverse(historicRot) * Rotation;
            Vector3    diffNegPos  = RotationProvider.RotAsPosNeg(diff);

            //Checks for twist trigger to the right
            if (diffNegPos.z > TwistTriggerThreshold[2])
            {
                MessageBroker.BroadcastAll("OnTwist", new TwistEvent()
                {
                    Type = TwistTriggerTypes.ScrewRight, initialRot = historicRot, Milliseconds = TwistThresholdMillis
                });
            }
            else if (diffNegPos.z < -TwistTriggerThreshold[2])
            {
                MessageBroker.BroadcastAll("OnTwist", new TwistEvent()
                {
                    Type = TwistTriggerTypes.ScrewLeft, initialRot = historicRot, Milliseconds = TwistThresholdMillis
                });
            }

            if (diffNegPos.x < -TwistTriggerThreshold[0])
            {
                MessageBroker.BroadcastAll("OnTwist", new TwistEvent()
                {
                    Type = TwistTriggerTypes.Up, initialRot = historicRot, Milliseconds = TwistThresholdMillis
                });
            }
            else if (diffNegPos.x > TwistTriggerThreshold[0])
            {
                MessageBroker.BroadcastAll("OnTwist", new TwistEvent()
                {
                    Type = TwistTriggerTypes.Down, initialRot = historicRot, Milliseconds = TwistThresholdMillis
                });
            }

            // ----- IMPORTANT -------------
            //Remove the next elements in the Queue otherwise it will continue triggering the same event
        }
コード例 #2
0
 public RotationProvider()
 {
     instance         = this;
     instance.ShowGUI = false;
     instance.IsReceivingDataFromIMU = false;
 }