Пример #1
0
 void ShowCapturedOrbit()
 {
     if (_capturedBody)
     {
         _capturedBody.FindAndSetMostProperAttractor();
         _capturedBody.CalculateNewOrbitData();
         _capturedBody.DrawOrbit();
     }
 }
        void DrawOrbitInEditorFor(CelestialBody body)
        {
            int pointsCount = _simControl.sceneElementsDisplayParameters.orbitPointsCount;

            if (body.isActiveAndEnabled)
            {
                if (!Application.isPlaying && body.attractor != null && body.orbitData.isDirty)
                {
                    if (body.attractor.mass <= 0)
                    {
                        body.attractor.mass = 1e-007;                        //to avoid div by zero
                    }
                    body.CalculateNewOrbitData();
                }
                Handles.color = Color.white;
                var points = body.GetOrbitPointsDouble(pointsCount, false, _simControl.sceneElementsDisplayParameters.maxOrbitDistance);
                for (int i = 1; i < points.Length; i++)
                {
                    Handles.DrawLine((Vector3)points[i - 1], (Vector3)points[i]);
                }
                if (_simControl.sceneElementsDisplayParameters.drawOrbitsEclipticProjection && points.Length > 0)
                {
                    var point1 = points[0] - _simControl.eclipticNormal * CelestialBodyUtils.DotProduct(points[0], _simControl.eclipticNormal);
                    var point2 = Vector3d.zero;
                    Handles.color = Color.gray;
                    for (int i = 1; i < points.Length; i++)
                    {
                        point2 = points[i] - _simControl.eclipticNormal * CelestialBodyUtils.DotProduct(points[i], _simControl.eclipticNormal);
                        Handles.DrawLine((Vector3)point1, (Vector3)point2);
                        point1 = point2;
                    }
                }
            }
        }
        /// <summary>
        /// Draw orbit. All needed orbit data will be calculated if is not in playmode.
        /// Orbit points count is provided by SimControl
        /// </summary>
        /// <param name="body"></param>
        void DrawOrbitInEditorFor(CelestialBody body)
        {
            int pointsCount = (int)_simControl.orbitPointsCount;

            if (body.isActiveAndEnabled && !body.IsFixedPosition)
            {
                if (!Application.isPlaying)
                {
                    if (_draggingObject == null || body == _draggingObject)
                    {
                        body.CalculateNewOrbitData();
                    }
                }
                var points = body.GetOrbitPoints(pointsCount);
                for (int i = 1; i < points.Length; i++)
                {
                    Handles.DrawLine((Vector3)points[i - 1], (Vector3)points[i]);
                    //Handles.DrawDottedLine( (Vector3)points[i - 1], (Vector3)points[i], 12f ); //pretty expensive for performance
                }
            }
        }
		/// <summary>
		/// Draw orbit. All needed orbit data will be calculated if is not in playmode.
		/// Orbit points count is provided by SimControl
		/// </summary>
		/// <param name="body"></param>
		void DrawOrbitInEditorFor(CelestialBody body) {
			int pointsCount = (int)_simControl.orbitPointsCount;
			if (body.isActiveAndEnabled && !body.IsFixedPosition) {
				if (!Application.isPlaying) {
					if (_draggingObject == null || body == _draggingObject) {
						body.CalculateNewOrbitData();
					}
				}
				var points = body.GetOrbitPoints(pointsCount);
				for (int i = 1; i < points.Length; i++) {
					Handles.DrawLine((Vector3)points[i - 1], (Vector3)points[i]);
					//Handles.DrawDottedLine( (Vector3)points[i - 1], (Vector3)points[i], 12f ); //pretty expensive for performance
				}
			}
		}