public float GetAxisValue(AxisValue axis) { switch (axis) { case AxisValue.LeftStickHorizontal: return(ThisFrame.LeftStickAxes.x); case AxisValue.LeftStickVertical: return(ThisFrame.LeftStickAxes.y); case AxisValue.RightStickHorizontal: return(ThisFrame.RightStickAxes.x); case AxisValue.RightStickVertical: return(ThisFrame.RightStickAxes.y); case AxisValue.LeftTrigger: return(ThisFrame.LeftTriggerAxis); case AxisValue.RightTrigger: return(ThisFrame.RightTriggerAxis); default: throw new NotImplementedException("No assigned axis value for " + axis); } }
private void UpdateButtons() { LT.UpdateState(CheckPressureActive(NativeState.Triggers.Left)); RT.UpdateState(CheckPressureActive(NativeState.Triggers.Right)); LT_Value = FilterPressureValue(NativeState.Triggers.Left); RT_Value = FilterPressureValue(NativeState.Triggers.Right); LB.UpdateState(NativeState.Buttons.LeftShoulder == ButtonState.Pressed); RB.UpdateState(NativeState.Buttons.RightShoulder == ButtonState.Pressed); DPad_Left.UpdateState(NativeState.DPad.Left == ButtonState.Pressed); DPad_Right.UpdateState(NativeState.DPad.Right == ButtonState.Pressed); DPad_Down.UpdateState(NativeState.DPad.Down == ButtonState.Pressed); DPad_Up.UpdateState(NativeState.DPad.Up == ButtonState.Pressed); A.UpdateState(NativeState.Buttons.A == ButtonState.Pressed); B.UpdateState(NativeState.Buttons.B == ButtonState.Pressed); X.UpdateState(NativeState.Buttons.X == ButtonState.Pressed); Y.UpdateState(NativeState.Buttons.Y == ButtonState.Pressed); StickL.UpdateState(NativeState.Buttons.LeftStick == ButtonState.Pressed); StickR.UpdateState(NativeState.Buttons.RightStick == ButtonState.Pressed); StickL_Value = new AxisValue(FilterPressureValue(NativeState.ThumbSticks.Left.X), FilterPressureValue(NativeState.ThumbSticks.Left.Y)); StickR_Value = new AxisValue(FilterPressureValue(NativeState.ThumbSticks.Right.X), FilterPressureValue(NativeState.ThumbSticks.Right.Y)); Start.UpdateState(NativeState.Buttons.Start == ButtonState.Pressed); Back.UpdateState(NativeState.Buttons.Back == ButtonState.Pressed); Guide.UpdateState(NativeState.Buttons.Guide == ButtonState.Pressed); }
/// <summary> /// 获取摇杆的值 /// </summary> /// <param name="axis">摇杆id</param> public static AxisValue GetAxisValue(int axis) { AxisValue ret = null; if (!_axisDict.TryGetValue(axis, out ret)) { ret = new AxisValue(); _axisDict.Add(axis, ret); } return(ret); }
/// <summary> /// Returns Success while the virtual axis button is held down. /// <param name="axisName">The name of the axis.</param> /// <param name="axisValue">The name of the axis.</param> /// <param name="tolerance">The name of the axis.</param> /// </summary> public static bool IsAxisButtonTest(string axisName, AxisValue axisValue, float tolerance) { if (axisValue == AxisValue.Positive) { return(Input.GetAxisRaw(axisName) >= tolerance); } else { return(-Input.GetAxisRaw(axisName) >= tolerance); } }
private static float GetPreviousAxisValue(string axis) { if (!_previousAxes.TryGetValue(axis, out AxisValue value)) { value = new AxisValue { Value = 0.0f }; _previousAxes.Add(axis, value); } return(value.Value); }
public void Execute() { //calcualte relative change AxisValue relativeChange = new AxisValue(X, Y, Z) - ((IObject3D)objects[objects.Count - 1]).PivotPoint; foreach (IObject3D obj in objects) { pivotPoints.Add(obj.PivotPoint); obj.PivotPoint = new AxisValue(obj.PivotPoint.X + relativeChange.X, obj.PivotPoint.Y + relativeChange.Y, obj.PivotPoint.Z + relativeChange.Z); } Midget.Events.EventFactory.Instance.GenerateTransformationEvent(this, objects); }
public void Execute() { //calcualte relative change AxisValue relativeChange = new AxisValue(X, Y, Z) - ((IObject3D)objects[objects.Count - 1]).Translation; foreach (IObject3D obj in objects) { mementos.Add(obj.CreateMemento()); obj.Translate(obj.Translation.X + relativeChange.X, obj.Translation.Y + relativeChange.Y, obj.Translation.Z + relativeChange.Z); // change active objects' memento if (obj.Rigidity == Rigidity.Active) { obj.DynamicStartMemento = obj.CreateMemento(); } } Midget.Events.EventFactory.Instance.GenerateTransformationEvent(this, objects); }
public TransformationRequestEventArgs( ArrayList objects, AxisValue initPosition, Transformation transformation) : base(objects) { position = initPosition; transType = transformation; }
public static X3DTransform BarGraph(ChartData o) { double yscale = GetYScale(o) * 0.4; double graphScale = 0.2; double dataHeight = 3; X3DTransform p = new X3DTransform(); p.Translation = new Vector3(0, -graphScale * dataHeight / 2.0, 0); p.Scale = new Vector3(graphScale); X3DTransform legenda = new X3DTransform(); p.AddChild(legenda); legenda.Name = "legenda"; int xlength = o.x_values.Count; int zlength = o.z_values.Count; var offset = new Vector3(-((double)xlength) / 2, 0, 0); legenda.Translation = offset + new Vector3(xlength + 1, 3, 0); //title if (!string.IsNullOrEmpty(o.title)) { var titletxt = X3DTransform.AddTransFormWithShape(ShapeType.Text); p.AddChild(titletxt); titletxt.Translation = offset + new Vector3(((float)xlength) / 2.0f, -2, 0); titletxt.Scale = new Vector3(0.2); titletxt.Shape.Text = o.title; } if (o.z_values.Count > 1) { foreach (var val in o.z_values) { var z_idx = o.z_values.IndexOf(val); var li = GetLegendaLabel(val.value, z_idx, getColor(val.color), val.label); legenda.AddChild(li); li.Translation = new Vector3(0, -z_idx * 0.3, zlength); } } foreach (var m in o.data) { var value = m.y; var z_val = o.z_values.Find(i => i.value == m.z); var z_idx = 0; if (z_val == null && o.z_values.Count > 0) { z_val = o.z_values[0]; } if (z_val == null) { z_val = new AxisValue(); z_val.color = "1, 0, 0"; } else { z_idx = o.z_values.IndexOf(z_val); } z_idx = z_idx == -1 ? 0 : z_idx; var x_val = o.x_values.Find(i => i.value == m.x); var x_idx = o.x_values.IndexOf(x_val); var label = ""; if (o.x_values.Count > 0) { label = z_idx == 0 ? o.x_values[x_idx].label : null; } z_idx = o.z_values.Count - z_idx; //var z_val = o.z_values[m.z]; Vector3 color = new Vector3(1); p.AddChild(GetBar(z_idx, x_idx, value, dataHeight * value / yscale, getColor(z_val.color), label, 0, zlength, offset)); } return p; }
public void GenerateTransformationRequestEvent(object sender, System.Collections.ArrayList objects, AxisValue position, Transformation transformation) { if (TransformationRequest != null) { TransformationRequest(sender, new TransformationRequestEventArgs(objects, position, transformation)); } }
/// <summary> /// Returns Success while the virtual axis button is held down. /// <param name="axisName">The name of the axis.</param> /// <param name="axisValue">The name of the axis.</param> /// <param name="tolerance">The name of the axis.</param> /// </summary> public static bool IsAxisButtonTest (string axisName, AxisValue axisValue, float tolerance) { if (axisValue == AxisValue.Positive) return Input.GetAxisRaw(axisName) >= tolerance; else return -Input.GetAxisRaw(axisName) >= tolerance; }
public TransformationRequestEventArgs(ArrayList objects, AxisValue initPosition, Transformation transformation) : base(objects) { position = initPosition; transType = transformation; }
public void GenerateTransformationRequestEvent(object sender, System.Collections.ArrayList objects, AxisValue position, Transformation transformation) { if(TransformationRequest != null) { TransformationRequest(sender, new TransformationRequestEventArgs(objects,position,transformation)); } }