本文整理汇总了C#中CelestialBody.GetAltitude方法的典型用法代码示例。如果您正苦于以下问题:C# CelestialBody.GetAltitude方法的具体用法?C# CelestialBody.GetAltitude怎么用?C# CelestialBody.GetAltitude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CelestialBody
的用法示例。
在下文中一共展示了CelestialBody.GetAltitude方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WorldPositionToGeoCoords
public static Vector3d WorldPositionToGeoCoords(Vector3d worldPosition, CelestialBody body)
{
if(!body)
{
return Vector3d.zero;
}
double lat = body.GetLatitude(worldPosition);
double longi = body.GetLongitude(worldPosition);
double alt = body.GetAltitude(worldPosition);
return new Vector3d(lat,longi,alt);
}
示例2: RaycastGround
public static DMPRaycastPair RaycastGround(double latitude, double longitude, CelestialBody body)
{
//We can only find the ground on bodies that actually *have* ground and if we are in flight near the origin
if (!HighLogic.LoadedSceneIsFlight || FlightGlobals.fetch.activeVessel == null || body.pqsController == null)
{
return new DMPRaycastPair(-1f, Vector3.up);
}
//Math functions take radians.
double latRadians = latitude * Mathf.Deg2Rad;
double longRadians = longitude * Mathf.Deg2Rad;
//Radial vector
Vector3d surfaceRadial = new Vector3d(Math.Cos(latRadians) * Math.Cos(longRadians), Math.Sin(latRadians), Math.Cos(latRadians) * Math.Sin(longRadians));
double surfaceHeight = body.pqsController.GetSurfaceHeight(surfaceRadial) - body.pqsController.radius;
Vector3d origin = body.GetWorldSurfacePosition(latitude, longitude, surfaceHeight + 500);
//Only return the surface if it's really close.
double highestHit = double.NegativeInfinity;
Vector3 rotatedVector = Vector3.up;
if (Vector3d.Distance(FlightGlobals.fetch.activeVessel.GetWorldPos3D(), origin) < 2500)
{
//Down vector
Vector3d downVector = -body.GetSurfaceNVector(latitude, longitude);
//Magic numbers!
LayerMask groundMask = 33792;
RaycastHit[] raycastHits = Physics.RaycastAll(origin, downVector, 1000f, groundMask);
foreach (RaycastHit raycastHit in raycastHits)
{
if (raycastHit.collider == null)
{
//I don't think this is technically possible, but unity's weird enough that we should probably check this anyway.
continue;
}
if (raycastHit.collider.name == body.name)
{
continue;
}
double hitAltitude = body.GetAltitude(raycastHit.point);
if ((hitAltitude > highestHit) && (!body.ocean || hitAltitude > 0))
{
highestHit = hitAltitude;
rotatedVector = Quaternion.Inverse(body.rotation) * raycastHit.normal;
}
}
}
if (highestHit == double.NegativeInfinity)
{
return new DMPRaycastPair(-1f, Vector3.up);
}
else
{
return new DMPRaycastPair(highestHit, rotatedVector);
}
}
示例3: traceTrans
public static string traceTrans(string prev, Transform tr, CelestialBody body = null)
{
string tmp;
if (body != null)
{
tmp = prev + "." + tr.name + " - (" + body.GetLatitude(tr.position) + ", " + body.GetLongitude(tr.position) + ", " + body.GetAltitude(tr.position) + ")\n";
}
else
{
tmp = prev + "." + tr.name + " - (" + tr.position + ", " + tr.rotation + ")\n";
}
Component[] comps = tr.gameObject.GetComponents<Component>();
foreach (Component comp in comps)
{
tmp += "\t" + comp.GetType().Name + " - " + comp.name + "\n";
}
for (int i = 0; i < tr.childCount; i++)
{
tmp += traceTrans(prev + "." + tr.name, tr.GetChild(i), body);
}
return tmp;
}
示例4: WorldPositionToGeoCoords
Vector3d WorldPositionToGeoCoords(Vector3d worldPosition, CelestialBody body)
{
if(!body)
{
Debug.LogWarning ("WorldPositionToGeoCoords body is null");
return Vector3d.zero;
}
double lat = body.GetLatitude(worldPosition);
double longi = body.GetLongitude(worldPosition);
double alt = body.GetAltitude(worldPosition);
return new Vector3d(lat,longi,alt);
}