本文整理汇总了C#中Vessel.GetSrfVelocity方法的典型用法代码示例。如果您正苦于以下问题:C# Vessel.GetSrfVelocity方法的具体用法?C# Vessel.GetSrfVelocity怎么用?C# Vessel.GetSrfVelocity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vessel
的用法示例。
在下文中一共展示了Vessel.GetSrfVelocity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetVelocity
/// <summary>
/// Returns the velocity of the reference frame in world-space.
/// </summary>
public static Vector3d GetVelocity(ReferenceFrame referenceFrame, Vessel vessel)
{
switch (referenceFrame) {
case ReferenceFrame.Orbital:
case ReferenceFrame.Maneuver:
return Vector3d.zero;
// Relative to the surface velocity vector
case ReferenceFrame.Surface:
return ((Vector3d)vessel.GetObtVelocity ()) - ((Vector3d)vessel.GetSrfVelocity ());
// Relative to the target's velocity vector, or relative to the orbit if there is no target
case ReferenceFrame.Target:
throw new NotImplementedException ();
// Relative to the negative surface normal of the target docking port, or relative to the target if the target is not a docking port
case ReferenceFrame.Docking:
throw new NotImplementedException ();
default:
throw new ArgumentException ("No such reference frame");
}
}
示例2: FixedUpdate
void FixedUpdate()
{
time = Planetarium.GetUniversalTime();
fixedDeltaTime = TimeWarp.fixedDeltaTime;
vesselName = null;
engineName = null;
vessel = FlightGlobals.ActiveVessel;
if (wireVessel != vessel)
{
if (wireVessel != null) wireVessel.OnFlyByWire -= FlyByWire;
wireVessel = vessel;
if (wireVessel != null) wireVessel.OnFlyByWire += FlyByWire;
}
if (vessel == null) return;
vesselName = vessel.vesselName;
var engine = vessel.GetActiveParts().SelectMany(part => part.Modules.OfType<ModuleEngines>()).FirstOrDefault();
if (engine == null) return;
engineName = engine.name;
finalThrust = engine.finalThrust;
fuelFlowGui = engine.fuelFlowGui;
status = engine.status;
statusL2 = engine.statusL2;
thrustPercentage = engine.thrustPercentage;
currentThrottle = engine.currentThrottle;
EngineIgnited = engine.EngineIgnited;
maxThrust = engine.maxThrust;
minThrust = engine.minThrust;
requestedThrottle = engine.requestedThrottle;
requestedThrust = engine.requestedThrust;
useEngineResponseTime = engine.useEngineResponseTime;
engineAccelerationSpeed = engine.engineAccelerationSpeed;
engineDecelerationSpeed = engine.engineDecelerationSpeed;
useVelocityCurve = engine.useVelocityCurve;
com = vessel.findWorldCenterOfMass();
up = (com - vessel.mainBody.position).normalized;
east = vessel.mainBody.getRFrmVel(com).normalized;
north = -Vector3.Cross(up, east);
var headingDir = vessel.GetSrfVelocity();
headingDir -= Vector3.Dot(headingDir, up) * up;
if (headingDir.sqrMagnitude > 0.5f)
{
headingDir = headingDir.normalized;
heading = Mathf.Acos(Vector3.Dot(north, headingDir)) * Mathf.Rad2Deg;
if (Vector3.Dot(east, headingDir) < 0) heading = -heading;
}
var pitchDir = vessel.GetSrfVelocity();
if (pitchDir.sqrMagnitude > 0.5f)
{
pitchDir = pitchDir.normalized;
pitch = Mathf.Acos(Vector3.Dot(up, pitchDir)) * Mathf.Rad2Deg;
}
//if (useCamera)
//{
// var q = vessel.VesselSAS.lockedHeading;
// var forward = q * Vector3.up;
// q = Quaternion.LookRotation(forward, up);
// vessel.VesselSAS.LockHeading(q);
//}
thrustMultiplier = thrustPercentage / 100f;
thrustEfficiency = 1;
if (useVelocityCurve) thrustEfficiency *= engine.velocityCurve.Evaluate((float)vessel.srf_velocity.magnitude);
up = (vessel.findWorldCenterOfMass() - vessel.mainBody.position).normalized;
thrustDirection = Vector3.zero;
foreach (var thrust in engine.thrustTransforms) thrustDirection += thrust.forward;
if (engine.thrustTransforms.Count > 0) thrustDirection = thrustDirection.normalized;
thrustEfficiency *= Vector3.Dot(-thrustDirection, up);
//if (desire)
//{
// desireCrank = Mathf.Round((desiredThrottle * thrustPercentage / 100f - currentThrottle) * 10000f) / 10000f;
// if (desireCrank > 0) desireCrank /= engineAccelerationSpeed * fixedDeltaTime;
// else if (desireCrank < 0) desireCrank /= engineDecelerationSpeed * fixedDeltaTime;
// if (currentThrottle + desireCrank >= 1) desireCrank = 1;
// else if (currentThrottle + desireCrank <= 0) desireCrank = 0;
// else if (desireCrank > 0) desireCrank = currentThrottle + desireCrank * desireCrank;
// else if (desireCrank < 0) desireCrank = currentThrottle - desireCrank * desireCrank;
// else desireCrank = desiredThrottle;
// desireCrank = Mathf.Clamp01(desireCrank * 100f / thrustPercentage);
//}
var deadzone = 0.01f;
var ascend = Mathf.Clamp01((Input.GetAxis("joy0.9") - deadzone) / (1.0f - deadzone));
var descend = Mathf.Clamp01((Input.GetAxis("joy0.8") - deadzone) / (1.0f - deadzone));
if (ascend > 0 || descend > 0 || mode == Mode.CONTROLLED)
{
mode = Mode.CONTROLLED;
desiredVelocity = (ControlMap(ascend) - ControlMap(descend)) * 30f;
}
//.........这里部分代码省略.........
示例3: Waypoint
public Waypoint(Vessel v)
{
longitude = v.longitude;
latitude = v.latitude;
altitude = v.altitude;
velocity = v.GetSrfVelocity();
orientation = v.rigidbody.rotation;
recordTime = Planetarium.GetUniversalTime();
}