示例#1
0
 public bool Operate(int axis, int length, int speed, bool isContinue)
 {
     if (CanOperate(axis) || isContinue)
     {
         decimal resolution = AxisSet.GetResolution(axis);
         if (Contra.StepLength != 0 && !IsMove(axis))
         {
             if (!CheckSoftLimit(axis, length, Contra.StepLength))
             {
                 return(false);
             }
             CtrlCard.Sym_RelativeMove(axis, (int)((length > 0 ? Contra.StepLength : (0 - Contra.StepLength)) * resolution), speed, (int)AxisSet.GetSpeed(axis), (double)Contra.AddSpeedTime);
             form.isM21    = false;
             form.isEndM21 = false;
             moveState     = 0;
         }
         else if (!IsMove(axis))
         {
             if (!CheckSoftLimit(axis, length, length))
             {
                 return(false);
             }
             CtrlCard.Sym_RelativeMove(axis, length, Contra.StartSpeed, speed, Contra.AddSpeedTime);
             form.isM21    = false;
             form.isEndM21 = false;
             moveState     = 0;
         }
         isOperate = true;
         return(true);
     }
     return(false);
 }
示例#2
0
 void Update()
 {
             #if UNITY_EDITOR
     if (UnityEditor.EditorApplication.isPlaying)
     {
         return;
     }
     if (axisOrder != lastAxisOrder)
     {
         lastAxisOrder = axisOrder;
         SetAxisOrder(axisOrder);
     }
     if (captureRotations)
     {
         captureRotations = false;
         int     idx     = (int)axisOrder;
         AxisSet thisSet = axisSets [idx];
         thisSet.rotations [0] = thisSet.rings [0].localRotation;
         thisSet.rotations [1] = thisSet.rings [1].localRotation;
         thisSet.rotations [2] = thisSet.rings [2].localRotation;
         thisSet.rotations [3] = jet.localRotation;
         thisSet.jetPosition   = jet.localPosition;
     }
             #endif
 }
        public AxisSet GetAxis()
        {
            try
            {
                var axisSet            = new AxisSet();
                var state              = Joystick.GetCurrentState();
                int currentButtonIndex = 0;

                AddAxisFromArray(ref axisSet, ref currentButtonIndex, state.AccelerationSliders);
                AddAxisFromArray(ref axisSet, ref currentButtonIndex, state.ForceSliders);
                AddAxisFromArray(ref axisSet, ref currentButtonIndex, state.Sliders);
                AddAxisFromArray(ref axisSet, ref currentButtonIndex, state.VelocitySliders);
                AddAxis(ref axisSet, ref currentButtonIndex, state.X);
                AddAxis(ref axisSet, ref currentButtonIndex, state.Y);
                AddAxis(ref axisSet, ref currentButtonIndex, state.Z);
                AddAxis(ref axisSet, ref currentButtonIndex, state.RotationX);
                AddAxis(ref axisSet, ref currentButtonIndex, state.RotationY);
                AddAxis(ref axisSet, ref currentButtonIndex, state.RotationZ);
                AddAxis(ref axisSet, ref currentButtonIndex, state.VelocityX);
                AddAxis(ref axisSet, ref currentButtonIndex, state.VelocityY);
                AddAxis(ref axisSet, ref currentButtonIndex, state.VelocityZ);
                AddAxis(ref axisSet, ref currentButtonIndex, state.AngularVelocityX);
                AddAxis(ref axisSet, ref currentButtonIndex, state.AngularVelocityY);
                AddAxis(ref axisSet, ref currentButtonIndex, state.AngularVelocityZ);
                AddAxis(ref axisSet, ref currentButtonIndex, state.AccelerationX);
                AddAxis(ref axisSet, ref currentButtonIndex, state.AccelerationY);
                AddAxis(ref axisSet, ref currentButtonIndex, state.AccelerationZ);
                AddAxis(ref axisSet, ref currentButtonIndex, state.AngularAccelerationX);
                AddAxis(ref axisSet, ref currentButtonIndex, state.AngularAccelerationY);
                AddAxis(ref axisSet, ref currentButtonIndex, state.AngularAccelerationZ);
                AddAxis(ref axisSet, ref currentButtonIndex, state.ForceX);
                AddAxis(ref axisSet, ref currentButtonIndex, state.ForceY);
                AddAxis(ref axisSet, ref currentButtonIndex, state.ForceZ);
                AddAxis(ref axisSet, ref currentButtonIndex, state.TorqueX);
                AddAxis(ref axisSet, ref currentButtonIndex, state.TorqueY);
                AddAxis(ref axisSet, ref currentButtonIndex, state.TorqueZ);

                return(axisSet);

                // Local Utility Functions
                void AddAxis(ref AxisSet set, ref int buttonIndex, int value)
                {
                    set.SetAxis(currentButtonIndex, value);
                    buttonIndex += 1;
                }

                void AddAxisFromArray(ref AxisSet set, ref int buttonIndex, int[] axis)
                {
                    foreach (var ax in axis)
                    {
                        set.SetAxis(currentButtonIndex, ax);
                        buttonIndex += 1;
                    }
                }
            }
            catch (SharpDXException e)
            {
                return(new AxisSet());
            }
        }
示例#4
0
    void UpdateRotation(int slider)
    {
        AxisSet   axes = axisSets [(int)axisOrder];
        Transform ring = axes.rings [slider];

        ring.localRotation = axes.rotations [slider];

        ring.Rotate(axes.axes [slider] * sliders [slider].value * 360f);
    }
    public static bool AreRotationsEquivalent(AxisSet axes, AxisSet rotOrder, EulerAngles a, EulerAngles b, bool debug = false)
    {
        AxisSet equivOrder = Conversions.ToEquivelentRotationOrder(axes, new AxisSet("XY-Z", true), rotOrder);

        Quaternion qe    = Conversions.ToQuaternion(equivOrder, a);
        Quaternion qback = Conversions.ToQuaternion(equivOrder, b);

        return(AreQuaternionsEquivalent(qe, qback, debug));
    }
示例#6
0
        private bool CanOperate(int axis)
        {
            bool isZero       = IOHelper.IsZero();
            bool isStop       = IOHelper.IsStopButton();
            bool isNotWarning = IsNotWarning();
            bool isNotIgnore  = AxisSet.IsNotIgnore(axis);

            return((!isZero || axis == 4) && !isStop && isNotWarning && !isOperate && isNotIgnore);
        }
示例#7
0
    void ResetRotations()
    {
        AxisSet thisSet = axisSets [(int)axisOrder];

        thisSet.rings [0].localRotation = thisSet.rotations [0];
        thisSet.rings [1].localRotation = thisSet.rotations [1];
        thisSet.rings [2].localRotation = thisSet.rotations [2];
        jet.localRotation = thisSet.rotations [3];
        jet.localPosition = thisSet.jetPosition;
    }
示例#8
0
        public AxisSet GetAxis()
        {
            var axisSet = new AxisSet();

            Controller.GetState(out var state);

            axisSet.SetAxis(0, ScaleAxis(state.Gamepad.LeftThumbX));
            axisSet.SetAxis(1, ScaleAxis(state.Gamepad.LeftThumbY));
            axisSet.SetAxis(2, ScaleAxis(state.Gamepad.RightThumbX));
            axisSet.SetAxis(3, ScaleAxis(state.Gamepad.RightThumbY));
            axisSet.SetAxis(4, ScaleTrigger(state.Gamepad.LeftTrigger));
            axisSet.SetAxis(5, ScaleTrigger(state.Gamepad.RightTrigger));

            return(axisSet);
        }
示例#9
0
        private int GetMovePosition(string axisType, Nullable <decimal> infoValue, decimal lastPosition, decimal logPosition, bool flag, bool flag2, out decimal jianxi)
        {
            decimal value = logPosition;

            jianxi = 0;
            if (infoValue.HasValue)
            {
                value += infoValue.Value;
                if (isG90)
                {
                    value -= lastPosition;
                }
            }
            decimal resolution = AxisSet.GetResolution(axisType);

            value = Contra.GetRealValue(axisType, value, AxisSet, flag, flag2, out jianxi);
            return(Convert.ToInt32(value * 1000 / resolution));
        }
    // Run the tests
    void Start()
    {
        Debug.Assert(AreVectorsEquivalent(
                         Conversions.ConvertPosition("+X+Y-Z", "+Y-Z+X", new Vector3(1, 2, 3)),
                         new Vector3(-3, 1, -2)
                         ));

        Debug.Assert(AreVectorsEquivalent(
                         Conversions.ConvertPosition("-Z-X+Y", "+X-Z+Y", new Vector3(1, 2, 3)),
                         new Vector3(-3, 2, 1)
                         ));

        Debug.Assert(
            Conversions.ToQuaternion(new AxisSet("-Z-X-Y", true), new EulerAngles(30, 10, 20)) == Quaternion.Euler(10, 20, 30)
            );

        Debug.Assert(ExpectException(() => new AxisSet("-Z-XZ", false)));
        Debug.Assert(ExpectException(() => new AxisSet("-Z-ZY", false)));
        Debug.Assert(ExpectException(() => new AxisSet("X--YZ", false)));
        Debug.Assert(ExpectException(() => new AxisSet("-+XYZ", false)));
        Debug.Assert(ExpectException(() => new AxisSet("-+XUZ", false)));
        Debug.Assert(ExpectException(() => new AxisSet("-Z-ZY", true)));

        Debug.Assert(ExpectException(() => new CoordinateFrame("XYZ", "XXZ")));
        Debug.Assert(ExpectException(() => new CoordinateFrame("XYX", "XYZ")));

        // Cases that failed before fixing the floating point math issue
        {
            EulerAngles e  = new EulerAngles(170, 90, -27);
            EulerAngles to = Conversions.ConvertEulerOrder(Frames.Unity.RotationOrder, Frames.Unity.RotationOrder, e);
            Debug.Assert(AreRotationsEquivalent(Frames.Unity.RotationOrder, e, to));
        }

        {
            AxisSet     ro   = new AxisSet("-X-Y-X", true);
            EulerAngles e    = new EulerAngles(0, 90, 210);
            EulerAngles to   = Conversions.ConvertEulerOrder(Frames.Unity.RotationOrder, ro, e);
            EulerAngles back = Conversions.ConvertEulerOrder(ro, Frames.Unity.RotationOrder, to);

            Debug.Assert(AreRotationsEquivalent(Frames.Unity.RotationOrder, e, back));
        }

        StartCoroutine(RunConversionTests());
    }
示例#11
0
    public void SetAxisOrder(AxisOrder order)
    {
        sliderDown      = -1;
        sliderMouse [0] = sliderMouse [1] = sliderMouse [2] = false;

        AxisSet axes = axisSets [(int)order];

        rollRing  = axes.rings [0];
        pitchRing = axes.rings [1];
        yawRing   = axes.rings [2];

        rollRing.GetComponent <ColorSetter> ().SetMaterial(materials [0]);
        pitchRing.GetComponent <ColorSetter> ().SetMaterial(materials [1]);
        yawRing.GetComponent <ColorSetter> ().SetMaterial(materials [2]);

        axisOrder = order;
        ResetRotations();
        ResetSliders();
    }
示例#12
0
 public override void Validate()
 {
     base.Validate();
     if (AxisSet != null)
     {
         AxisSet.Validate();
     }
     if (IOSet != null)
     {
         IOSet.Validate();
     }
     if (OtherSet != null)
     {
         OtherSet.Validate();
     }
     if (AbsolutePosSet != null)
     {
         AbsolutePosSet.Validate();
     }
     if (ButtonSet != null)
     {
         ButtonSet.Validate();
     }
 }
 // Checks whether or not the vectors are equivalent, affording some epsilon
 // for vectors representing euler rotations in particular.
 public static bool AreRotationsEquivalent(AxisSet rotOrder, EulerAngles a, EulerAngles b, bool debug = false)
 {
     return(AreRotationsEquivalent(new AxisSet("XY-Z", false), rotOrder, a, b, debug));
 }
示例#14
0
 public void Operate(int axis, int length)
 {
     Operate(axis, length, (int)AxisSet.GetSpeed(axis));
 }
示例#15
0
 private bool CanOperate(int axis)
 {
     return((!IOHelper.IsZero() || axis == 4) && !IOHelper.IsStopButton() && IsNotWarning() && !isOperate && AxisSet.IsNotIgnore(axis));
 }
示例#16
0
 public bool Operate(int axis, int length, int speed, bool isContinue)
 {
     if (CanOperate(axis) || isContinue)
     {
         if (Contra.StepLength != 0 && !IsMove(axis))
         {
             CtrlCard.Sym_RelativeMove(axis, length > 0 ? Contra.StepLength : (0 - Contra.StepLength), speed, (int)AxisSet.GetSpeed(axis), (double)Contra.AddSpeedTime);
         }
         else if (!IsMove(axis))
         {
             CtrlCard.Sym_RelativeMove(axis, length, Contra.StartSpeed, speed, Contra.AddSpeedTime);
         }
         isOperate = true;
         return(true);
     }
     return(false);
 }