/// <summary> /// PRONAV /// </summary> /// <param name="target"></param> /// <returns>Heading we need to aim at</returns> public Vector3D Navigate(HaE_Entity target) { Vector3D targetpos = target.entityInfo.Position; if (target.entityInfo.HitPosition.HasValue) { targetpos = target.entityInfo.HitPosition.Value; } Vector3D myVel = controller.control.GetShipVelocities().LinearVelocity; Vector3D rangeVec = targetpos - controller.control.GetPosition(); Vector3D closingVel = target.entityInfo.Velocity - myVel; Vector3D accel = CalculateAccel(rangeVec, closingVel); accel += -controller.control.GetNaturalGravity(); //Gravity term double maxForwardAccel = ThrustUtils.GetForwardThrust(controller.thrusters, controller.control); maxForwardAccel /= controller.control.CalculateShipMass().PhysicalMass; double forwardAccel = maxForwardAccel; double accelMag = accel.Normalize(); forwardAccel -= accelMag; forwardAccel = MathHelperD.Clamp(forwardAccel, 0, maxForwardAccel); accel *= accelMag; accel += Vector3D.Normalize(rangeVec) * forwardAccel; return(accel); }
private void ApplyThrustPercentage(double percentage) { if (percentage > 0 && percentage != currentThrustAmount) { ThrustUtils.SetThrustPercentage(thrusters, (float)percentage); currentThrustAmount = (float)percentage; } else if (percentage <= 0 && currentThrustAmount != 0) { ThrustUtils.SetThrustPercentage(thrusters, 0); currentThrustAmount = 0; } }
public void Update() { if (!_targetUpdated) { _target = InterpolateTarget(); } Vector3D aimVector = Navigate(_target); GyroUtils.PointInDirection(_gyros, _gyros[0].WorldMatrix, aimVector); aimVector.Normalize(); ThrustUtils.SetThrustBasedDot(_thrusters, aimVector); UpdatePayload(); }
private Vector3D Navigate(Vector3D targetpos) { Vector3D currentPos = _gyros[0].GetPosition(); Vector3D myVel = currentPos - _previousPosition; Vector3D targetVel = targetpos - _previousTargetPosition; Vector3D myFThrust = ThrustUtils.GetThrustSum(_thrusters); Vector3D rangeVec = targetpos - _gyros[0].GetPosition(); Vector3D closingVel = targetVel - myVel; Vector3D accel = CalculateAccel(rangeVec, closingVel); double accelMag = accel.Normalize(); _previousTargetPosition = targetpos; _previousTargetSpeed = targetVel; _previousPosition = currentPos; accel *= accelMag; accel += rangeVec; return(accel); }
public void LaunchForward() { ThrustUtils.SetThrustBasedDot(thrusters, control.WorldMatrix.Forward); }
public void ApplyThrust(Vector3D dir) { ThrustUtils.SetThrustBasedDot(thrusters, dir, 2.5); }
public void BoostForward(float amount) { ThrustUtils.SetThrust(thrusters, control.WorldMatrix.Forward, amount); }