当前位置: 首页>>代码示例>>C#>>正文


C# CelestialBody.GetAltitude方法代码示例

本文整理汇总了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);
        }
开发者ID:BahamutoD,项目名称:VesselMover,代码行数:12,代码来源:VesselSpawn.cs

示例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);
     }
 }
开发者ID:Opice,项目名称:DarkMultiPlayer,代码行数:52,代码来源:VesselUtil.cs

示例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;
 }
开发者ID:nixnocent,项目名称:InfernalRobotics,代码行数:22,代码来源:Part.cs

示例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);
        }
开发者ID:BahamutoD,项目名称:VesselMover,代码行数:13,代码来源:VesselMove.cs


注:本文中的CelestialBody.GetAltitude方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。