public void InteractiveObjectButton_UpdateEvent(NeoAxis.Component sender, float delta) { var _this = sender as Component_ButtonInSpace; if (_this != null) { var indicator = _this.GetComponent("Indicator") as Component_MeshInSpace; if (indicator != null) { indicator.Color = _this.Activated ? new ColorValue(0, 1, 0) : new ColorValue(0.5, 0.5, 0.5); } var buttonOffset = _this.Components.GetByPath("Button\\Attach Transform Offset") as Component_TransformOffset; if (buttonOffset != null) { var offsetPushed = 0.01; var offsetDefault = 0.05; var coef = 0.0; if (_this.Clicking && _this.ClickingTotalTime != 0) { var timeFactor = MathEx.Saturate(_this.ClickingCurrentTime / _this.ClickingTotalTime); if (timeFactor < 0.5) { coef = timeFactor * 2; } else { coef = (1.0f - timeFactor) * 2; } } var offset = MathEx.Lerp(offsetDefault, offsetPushed, coef); buttonOffset.PositionOffset = new Vector3(offset, 0, 0); } } }
public void InputProcessing_SimulationStep(NeoAxis.Component obj) { var sender = (NeoAxis.Component_InputProcessing)obj; //get access to the ship var ship = sender.Parent; if (ship == null) { return; } //control the ship var body = ship.GetComponent <Component_RigidBody2D>(); if (body != null) { //keyboard //fly front if (sender.IsKeyPressed(EKeys.W) || sender.IsKeyPressed(EKeys.Up) || sender.IsKeyPressed(EKeys.NumPad8)) { var dir = body.TransformV.Rotation.GetForward().ToVector2(); body.ApplyForce(dir * 1.0); } //fly back if (sender.IsKeyPressed(EKeys.S) || sender.IsKeyPressed(EKeys.Down) || sender.IsKeyPressed(EKeys.NumPad2)) { var dir = body.TransformV.Rotation.GetForward().ToVector2(); body.ApplyForce(dir * -1.0); } //turn left if (sender.IsKeyPressed(EKeys.A) || sender.IsKeyPressed(EKeys.Left) || sender.IsKeyPressed(EKeys.NumPad4)) { body.ApplyTorque(1.0); } //turn right if (sender.IsKeyPressed(EKeys.D) || sender.IsKeyPressed(EKeys.Right) || sender.IsKeyPressed(EKeys.NumPad6)) { body.ApplyTorque(-1.0); } //movement by joystick axes if (Math.Abs(sender.JoystickAxes[0]) >= 0.01) { body.ApplyTorque(-sender.JoystickAxes[0]); } if (Math.Abs(sender.JoystickAxes[1]) >= 0.01) { var dir = body.TransformV.Rotation.GetForward().ToVector2(); body.ApplyForce(dir * sender.JoystickAxes[1]); } //JoystickAxes //JoystickButtons //JoystickPOVs //JoystickSliders //IsJoystickButtonPressed //GetJoystickAxis //GetJoystickPOV //GetJoystickSlider } }
public void Box_UpdateEvent(NeoAxis.Component sender, float delta) { var obj = Owner.Parent as Component_MeshInSpace; if (obj != null) { var offset = new Vector2(Math.Cos(Time.Current), Math.Sin(Time.Current)); obj.SetPosition(new Vector3(2.91991239547747 + offset.X, 6.21684634298425 + offset.Y, -0.5)); } }
protected override void OnRemovedFromParent(NeoAxis.Component oldParent) { DestroyLoadedObject(); base.OnRemovedFromParent(oldParent); if (instance == this) { instance = null; } }
protected override void OnEnabledInSimulation() { parent_comp = this.Parent; parent_inputproc = parent_comp?.GetComponent <Component_InputProcessing>(); if (parent_inputproc == null) { return; } parent_inputproc.InputMessageEvent += inputProcess; Component_Scene.First.RenderEvent += SceneRenderEvent; }
public void _UpdateEvent(NeoAxis.Component sender, float delta) { var object1 = sender.Components["Sphere"] as Component_MeshInSpace; if (object1 != null) { object1.Color = new ColorValue(0.5, 0.75 + Math.Sin(Time.Current) * 0.25, 0.5); } var material2 = sender.Components["Box\\Material"] as Component_Material; if (material2 != null) { material2.Emissive = new ColorValuePowered(0, (1.0 + Math.Sin(Time.Current)) * 5, 0); } var material3 = sender.Components["Cylinder\\Material"] as Component_Material; if (material3 != null) { material3.PropertySet("Multiplier", new ColorValue(1, 1, 1.0 + (1.0 + Math.Sin(Time.Current)) * 5)); } }
public void InteractiveObjectButton_UpdateEvent(NeoAxis.Component sender, float delta) { var _this = sender as Component_RegulatorSwitchInSpace; if (_this != null) { var indicatorMin = _this.GetComponent("Indicator Min") as Component_MeshInSpace; if (indicatorMin != null) { indicatorMin.Color = _this.Value.Value <= _this.ValueRange.Value.Minimum ? new ColorValue(1, 0, 0) : new ColorValue(0.5, 0.5, 0.5); } var indicatorMax = _this.GetComponent("Indicator Max") as Component_MeshInSpace; if (indicatorMax != null) { indicatorMax.Color = _this.Value.Value >= _this.ValueRange.Value.Maximum ? new ColorValue(0, 1, 0) : new ColorValue(0.5, 0.5, 0.5); } var button = _this.GetComponent("Button"); if (button != null) { var offset = button.GetComponent <Component_TransformOffset>(); if (offset != null) { var angle = _this.GetValueAngle() - 90; offset.RotationOffset = new Angles(angle, 0, 0).ToQuaternion(); } } var markerMin = _this.GetComponent("Marker Min"); if (markerMin != null) { var offset = markerMin.GetComponent <Component_TransformOffset>(); if (offset != null) { var angle = _this.AngleRange.Value.Minimum - 90; var angleR = MathEx.DegreeToRadian(angle); offset.PositionOffset = new Vector3(0.01, Math.Cos(angleR) * 0.04, Math.Sin(-angleR) * 0.04); offset.RotationOffset = new Angles(angle, 0, 0).ToQuaternion(); } } var markerMax = _this.GetComponent("Marker Max"); if (markerMax != null) { var offset = markerMax.GetComponent <Component_TransformOffset>(); if (offset != null) { var angle = _this.AngleRange.Value.Maximum - 90; var angleR = MathEx.DegreeToRadian(angle); offset.PositionOffset = new Vector3(0.01, Math.Cos(angleR) * 0.04, Math.Sin(-angleR) * 0.04); offset.RotationOffset = new Angles(angle, 0, 0).ToQuaternion(); } } var markerCurrent = _this.GetComponent("Marker Current"); if (markerCurrent != null) { var offset = markerCurrent.GetComponent <Component_TransformOffset>(); if (offset != null) { var angle = _this.GetValueAngle() - 90; var angleR = MathEx.DegreeToRadian(angle); offset.PositionOffset = new Vector3(0.06, Math.Cos(angleR) * 0.04, Math.Sin(-angleR) * 0.04); offset.RotationOffset = new Angles(angle, 0, 0).ToQuaternion(); } } } }
public void Box_UpdateEvent(NeoAxis.Component sender, float delta) { }
public void InputProcessing_SimulationStep(NeoAxis.Component obj) { var sender = (NeoAxis.Component_InputProcessing)obj; //get car object var car = Owner.Parent.Parent; if (car == null) { return; } //get control data double throttle = 0; if (sender.IsKeyPressed(EKeys.W) || sender.IsKeyPressed(EKeys.Up) || sender.IsKeyPressed(EKeys.NumPad8)) { throttle += 1; } if (sender.IsKeyPressed(EKeys.S) || sender.IsKeyPressed(EKeys.Down) || sender.IsKeyPressed(EKeys.NumPad2)) { throttle -= 1; } double steering = 0; if (sender.IsKeyPressed(EKeys.A) || sender.IsKeyPressed(EKeys.Left) || sender.IsKeyPressed(EKeys.NumPad4)) { steering -= 1; } if (sender.IsKeyPressed(EKeys.D) || sender.IsKeyPressed(EKeys.Right) || sender.IsKeyPressed(EKeys.NumPad6)) { steering += 1; } var brake = sender.IsKeyPressed(EKeys.Space); //get front constraints var frontConstraints = new List <Component_Constraint>(); { var right = car.GetComponent("Front Right Constraint") as Component_Constraint; if (right != null) { frontConstraints.Add(right); } var left = car.GetComponent("Front Left Constraint") as Component_Constraint; if (left != null) { frontConstraints.Add(left); } } //get back constraints var backConstraints = new List <Component_Constraint>(); { var right = car.GetComponent("Back Right Constraint") as Component_Constraint; if (right != null) { backConstraints.Add(right); } var left = car.GetComponent("Back Left Constraint") as Component_Constraint; if (left != null) { backConstraints.Add(left); } } //!!!!engine bug fix. motor doesn't wake up rigid body if (throttle != 0 || brake) { var body = car.GetComponent("Collision Body") as Component_RigidBody; if (body != null) { body.RigidBody.Activate(); } } //update front constraints foreach (var constraint in frontConstraints) { if (brake) { constraint.AngularAxisXMotorTargetVelocity = 0; constraint.AngularAxisXMotorMaxForce = 10; } else { constraint.AngularAxisXMotorTargetVelocity = 15.0 * -throttle; constraint.AngularAxisXMotorMaxForce = throttle != 0 ? 0.5 : 0; } constraint.AngularAxisZServoTarget = constraint.AngularAxisZLimitHigh.Value * steering; constraint.AngularAxisZMotorTargetVelocity = 1; constraint.AngularAxisZMotorMaxForce = 10; } //update back constraints foreach (var constraint in backConstraints) { constraint.AngularAxisZMotorTargetVelocity = 0; constraint.AngularAxisZMotorMaxForce = brake ? 10 : 0; } }