public override void drive(FlightControl control) { _drive(control); control.yaw *= _sensetivity.value; control.pitch *= _sensetivity.value; control.roll *= _sensetivity.value; }
protected override void onDrive(FlightCtrlState s) { if(_vessel == null) return; game.FlightControl control = new game.FlightControl(); control.update(s); _vessel.updateState(this.vessel); _protocol.requestControl(_vessel, control); control.apply(s); }
public FlightControl copy() { FlightControl ret = new FlightControl(); ret.throttle = throttle; ret.yaw = yaw; ret.pitch = pitch; ret.roll = roll; ret.dx = dx; ret.dy = dy; ret.dz = dz; return ret; }
public FlightControl copy() { FlightControl ret = new FlightControl(); ret.throttle = throttle; ret.yaw = yaw; ret.pitch = pitch; ret.roll = roll; ret.dx = dx; ret.dy = dy; ret.dz = dz; return(ret); }
protected override void onDrive(FlightCtrlState s) { if (_vessel == null) { return; } game.FlightControl control = new game.FlightControl(); control.update(s); _vessel.updateState(this.vessel); _protocol.requestControl(_vessel, control); control.apply(s); }
public void onControl(FlightControl control) { attitude.drive(control); }
private void _drive(FlightControl c) { double rollDelta = Math.Abs(vessel.rotation.roll - _lastRoll); if (rollDelta > Math.PI) rollDelta = 2 * Math.PI - rollDelta; if (rollDelta > Math.PI / 36) { _controller.reset(); _lastRoll = vessel.rotation.roll; } Quaternion delta = vessel.rotation.inverse * target; Vector3 err = new Vector3((delta.pitch > Math.PI) ? (delta.pitch - 2 * Math.PI) : delta.pitch, (delta.yaw > Math.PI) ? (delta.yaw - 2 * Math.PI) : delta.yaw, (delta.roll > Math.PI) ? (delta.roll - 2 * Math.PI) : delta.roll); err = new Vector3(controlPitch == Control.KillRotation ? 0 : err.x, controlYaw == Control.KillRotation ? 0 : err.y, controlRoll == Control.KillRotation ? 0 : err.z); Vector3 torque = vessel.body.torque; Vector3 inertia = vessel.body.angularMomentum.sign * vessel.body.angularMomentum * vessel.body.angularMomentum * (torque * vessel.body.momentumOfInertia).invert; err += inertia; err *= vessel.body.momentumOfInertia * torque.invert; Vector3 act = _controller.compute(err, vessel.mainBody.universe.fixedDeltaTime); double precision = (Math.Min(vessel.body.torque.x, vessel.body.torque.y) * 20.0 / vessel.body.momentumOfInertia.magnitude).clamp(0.5, 10); double driveLimit = (err.magnitude * driveFactor / precision).clamp(0, 1); act = act.clamp(-driveLimit, driveLimit); act = _act + (act - _act) * (vessel.mainBody.universe.fixedDeltaTime / Tf); setControls(act, c, driveLimit); _act = new Vector3(c.pitch, c.yaw, c.roll); }
private void setControls(Vector3 act, FlightControl c, double driveLimit) { control(act.z, driveLimit, controlRoll, ref c.roll); control(act.x, driveLimit, controlPitch, ref c.pitch); control(act.y, driveLimit, controlYaw, ref c.yaw); }
public abstract void drive(FlightControl c);