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


C# CelestialBody.GetWorldSurfacePosition方法代码示例

本文整理汇总了C#中CelestialBody.GetWorldSurfacePosition方法的典型用法代码示例。如果您正苦于以下问题:C# CelestialBody.GetWorldSurfacePosition方法的具体用法?C# CelestialBody.GetWorldSurfacePosition怎么用?C# CelestialBody.GetWorldSurfacePosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CelestialBody的用法示例。


在下文中一共展示了CelestialBody.GetWorldSurfacePosition方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetWorldSurfacePostion

 public static Vector3 GetWorldSurfacePostion(Vector3d geoPosition, CelestialBody body)
 {
     if(!body)
     {
         return Vector3.zero;
     }
     return body.GetWorldSurfacePosition(geoPosition.x, geoPosition.y, geoPosition.z);
 }
开发者ID:jediminer543,项目名称:BDArmory,代码行数:8,代码来源:VectorUtils.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: DrawWaypoint

        public static void DrawWaypoint(CelestialBody targetBody, double latitude, double longitude, double altitude, string id, int seed, float alpha = -1.0f)
        {
            // Translate to scaled space
            Vector3d localSpacePoint = targetBody.GetWorldSurfacePosition(latitude, longitude, altitude);
            Vector3d scaledSpacePoint = ScaledSpace.LocalToScaledSpace(localSpacePoint);

            // Don't draw if it's behind the camera
            Camera camera = MapView.MapIsEnabled ? PlanetariumCamera.Camera : FlightCamera.fetch.mainCamera;
            Vector3 cameraPos = ScaledSpace.ScaledToLocalSpace(camera.transform.position);
            if (Vector3d.Dot(camera.transform.forward, scaledSpacePoint.normalized) < 0.0)
            {
                return;
            }

            // Translate to screen position
            Vector3 screenPos = camera.WorldToScreenPoint(new Vector3((float)scaledSpacePoint.x, (float)scaledSpacePoint.y, (float)scaledSpacePoint.z));

            // Draw the marker at half-resolution (30 x 45) - that seems to match the one in the map view
            Rect markerRect = new Rect(screenPos.x - 15f, (float)Screen.height - screenPos.y - 45.0f, 30f, 45f);

            // Half-res for the icon too (16 x 16)
            Rect iconRect = new Rect(screenPos.x - 8f, (float)Screen.height - screenPos.y - 39.0f, 16f, 16f);

            if (alpha < 0.0f)
            {
                bool occluded = WaypointData.IsOccluded(targetBody, cameraPos, localSpacePoint, altitude);
                float desiredAlpha = occluded ? 0.3f : 1.0f * Config.opacity;
                if (lastAlpha < 0.0f)
                {
                    lastAlpha = desiredAlpha;
                }
                else if (lastAlpha < desiredAlpha)
                {
                    lastAlpha = Mathf.Clamp(lastAlpha + Time.deltaTime * 4f, lastAlpha, desiredAlpha);
                }
                else
                {
                    lastAlpha = Mathf.Clamp(lastAlpha - Time.deltaTime * 4f, desiredAlpha, lastAlpha);
                }
                alpha = lastAlpha;
            }

            // Draw the marker
            Graphics.DrawTexture(markerRect, GameDatabase.Instance.GetTexture("Squad/Contracts/Icons/marker", false), new Rect(0.0f, 0.0f, 1f, 1f), 0, 0, 0, 0, new Color(0.5f, 0.5f, 0.5f, 0.5f * (alpha - 0.3f) / 0.7f));

            // Draw the icon
            Graphics.DrawTexture(iconRect, ContractDefs.sprites[id].texture, new Rect(0.0f, 0.0f, 1f, 1f), 0, 0, 0, 0, SystemUtilities.RandomColor(seed, alpha));
        }
开发者ID:Kerbas-ad-astra,项目名称:WaypointManager,代码行数:48,代码来源:Util.cs

示例4: isInSafetyBubble

 //Adapted from KMP. Called from PlayerStatusWorker.
 public bool isInSafetyBubble(Vector3d worlPos, CelestialBody body)
 {
     //If not at Kerbin or past ceiling we're definitely clear
     if (body.name != "Kerbin")
     {
         return false;
     }
     Vector3d landingPadPosition = body.GetWorldSurfacePosition(-0.0971978130377757, 285.44237039111, 60);
     Vector3d runwayPosition = body.GetWorldSurfacePosition(-0.0486001121594686, 285.275552559723, 60);
     double landingPadDistance = Vector3d.Distance(worlPos, landingPadPosition);
     double runwayDistance = Vector3d.Distance(worlPos, runwayPosition);
     return runwayDistance < SAFETY_BUBBLE_DISTANCE || landingPadDistance < SAFETY_BUBBLE_DISTANCE;
 }
开发者ID:kevin-ye,项目名称:DarkMultiPlayer,代码行数:14,代码来源:VesselWorker.cs

示例5: DrawGroundMarker

 static bool DrawGroundMarker(CelestialBody body, Coordinates pos, Color c, float r = IconSize, Texture2D texture = null)
 {
     Vector3d center;
     Camera camera;
     if(MapView.MapIsEnabled)
     {
         //TODO: cache local center coordinates of the marker
         camera = PlanetariumCamera.Camera;
         center = body.position + (body.TerrainAltitude(pos.Lat, pos.Lon)+body.Radius) * body.GetSurfaceNVector(pos.Lat, pos.Lon);
     }
     else
     {
         camera = FlightCamera.fetch.mainCamera;
         center = body.GetWorldSurfacePosition(pos.Lat, pos.Lon, body.TerrainAltitude(pos.Lat, pos.Lon)+GLB.WaypointHeight);
         if(camera.transform.InverseTransformPoint(center).z <= 0) return false;
     }
     return !IsOccluded(center, body) &&
         DrawMarker(camera.WorldToScreenPoint(MapView.MapIsEnabled ? ScaledSpace.LocalToScaledSpace(center) : center), c, r, texture);
 }
开发者ID:Kerbas-ad-astra,项目名称:ThrottleControlledAvionics,代码行数:19,代码来源:NavigationPanel.cs

示例6: isInSafetyBubble

        private bool isInSafetyBubble(Vector3d pos, CelestialBody body, double altitude)
        {
            //Assume Kerbin if body isn't supplied for some reason
            if (body == null)
                body = FlightGlobals.Bodies.Find(b => b.name == "Kerbin");

            //If not at Kerbin or past ceiling we're definitely clear
            if (body.name != "Kerbin" || altitude > SAFETY_BUBBLE_CEILING)
                return false;

            //Cylindrical safety bubble -- project vessel position to a plane positioned at KSC with normal pointed away from surface
            Vector3d kscNormal = body.GetSurfaceNVector(-0.102668048654, -74.5753856554);
            Vector3d kscPosition = body.GetWorldSurfacePosition(-0.102668048654, -74.5753856554, 60);
            Vector3d landingPadPosition = body.GetWorldSurfacePosition(-0.0971978130377757, 285.44237039111, 60);
            Vector3d runwayPosition = body.GetWorldSurfacePosition(-0.0486001121594686, 285.275552559723, 60);
            double projectionDistance = Vector3d.Dot(kscNormal, (pos - kscPosition)) * -1;
            double landingPadDistance = Vector3d.Distance(pos, landingPadPosition);
            double runwayDistance = Vector3d.Distance(pos, runwayPosition);
            Vector3d projectedPos = pos + (Vector3d.Normalize(kscNormal) * projectionDistance);
            return Vector3d.Distance(kscPosition, projectedPos) < safetyBubbleRadius || runwayDistance < MIN_SAFETY_BUBBLE_DISTANCE || landingPadDistance < MIN_SAFETY_BUBBLE_DISTANCE;
        }
开发者ID:vosechu,项目名称:KerbalMultiPlayer,代码行数:21,代码来源:KMPManager.cs

示例7: Distance

 public float Distance(double latitude1, double longitude1, double altitude1, double latitude2, double longitude2, double altitude2, CelestialBody body)
 {
     // I did use great circle distance, but now I'm actually thinking a straight line might be best.
     Vector3d position1 = body.GetWorldSurfacePosition(latitude1, longitude1, altitude1);
     Vector3d position2 = body.GetWorldSurfacePosition(latitude2, longitude2, altitude2);
     return (float)Vector3d.Distance(position1, position2);
 }
开发者ID:stanbeard,项目名称:FinePrint,代码行数:7,代码来源:WaypointManager.cs

示例8: isInSafetyBubble

        private bool isInSafetyBubble(Vector3d pos, CelestialBody body, double altitude)
        {
            //Assume Kerbin if body isn't supplied for some reason
            if (body == null) body = FlightGlobals.Bodies.Find(b => b.name == "Kerbin");

            //If KSC out of range, syncing, not at Kerbin, or past ceiling we're definitely clear
            if (syncing || body.name != "Kerbin" || altitude > SAFETY_BUBBLE_CEILING)
                return false;

            //Cylindrical safety bubble -- project vessel position to a plane positioned at KSC with normal pointed away from surface
            Vector3d kscNormal = body.GetSurfaceNVector(-0.102668048654,-74.5753856554);
            Vector3d kscPosition = body.GetWorldSurfacePosition(-0.102668048654,-74.5753856554,60);
            double projectionDistance = Vector3d.Dot(kscNormal, (pos - kscPosition)) * -1;
            Vector3d projectedPos = pos + (Vector3d.Normalize(kscNormal)*projectionDistance);

            return Vector3d.Distance(kscPosition, projectedPos) < safetyBubbleRadius;
        }
开发者ID:krzys-h,项目名称:KerbalMultiPlayer,代码行数:17,代码来源:KMPManager.cs

示例9: Update

 public void Update(CelestialBody body, double latitude, double longitude, double altitude)
 {
     Update(body.GetWorldSurfacePosition(latitude, longitude, altitude));
 }
开发者ID:CliftonMarien,项目名称:MechJeb2,代码行数:4,代码来源:MechJebModuleTargetController.cs


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