Пример #1
0
        internal void DoUpdate(Vector3 v3)
        {
            if (_dcm == null)
            {
                return;
            }

            transform.position = _dcm._camera._moduleDockingNodeGameObject.transform.position;

            transform.rotation  = _dcm.part.transform.rotation * Quaternion.LookRotation(_dcm.cameraForward, _dcm.cameraUp);
            transform.position += _dcm._camera._moduleDockingNodeGameObject.transform.rotation * v3;

            _dcm._camera._moduleDockingNodeGameObject.transform.position = transform.position;
            _dcm._camera._moduleDockingNodeGameObject.transform.rotation = transform.rotation;

            DrawTools.DrawArrow(transform.position, transform.forward, Color.red);
        }
        private void OnRenderObjectEvent()
        {
            if (Camera.current != Camera.main || MapView.MapIsEnabled)
            {
                return;
            }

            if (CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.IVA &&
                vessel == FlightGlobals.ActiveVessel)
            {
                return;
            }

            if (vessel != FlightGlobals.ActiveVessel)
            {
                if (Vector3.Distance(FlightGlobals.ActiveVessel.transform.position, vessel.transform.position) >
                    PhysicsGlobals.Instance.VesselRangesDefault.subOrbital.unload)
                {
                    MarkersEnabled = false;
                    return;
                }
            }

            Profiler.BeginSample("FlightMarkersRenderDraw");

            DrawTools.DrawSphere(vessel.CoM, XKCDColors.Yellow, 1.0f * SphereScale);

            DrawTools.DrawSphere(vessel.rootPart.transform.position, XKCDColors.Green, 0.25f);

            _centerOfThrust = FindCenterOfThrust(vessel.rootPart);
            if (_centerOfThrust.Direction != Vector3.zero)
            {
                DrawTools.DrawSphere(_centerOfThrust.Position, XKCDColors.Magenta, 0.95f * SphereScale);
                DrawTools.DrawArrow(_centerOfThrust.Position, _centerOfThrust.Direction.normalized * ArrowLength, XKCDColors.Magenta);
            }

            if (vessel.staticPressurekPa > 0f)
            {
                _centerOfLift = FindCenterOfLift(vessel.rootPart, vessel.srf_velocity, vessel.altitude,
                                                 vessel.staticPressurekPa, vessel.atmDensity);
                _bodyLift = FindBodyLift(vessel.rootPart);
                _drag     = FindDrag(vessel.rootPart);

                var activeLift = LiftFlag.None;
                if (_centerOfLift.Total > CenterOfLiftCutoff)
                {
                    activeLift |= LiftFlag.SurfaceLift;
                }
                if (_bodyLift.Total > BodyLiftCutoff)
                {
                    activeLift |= LiftFlag.BodyLift;
                }

                var drawCombined = _combineLift && (activeLift & CombineFlags) == CombineFlags;

                if (drawCombined)
                {
                    _positionAvg.Reset();
                    _directionAvg.Reset();

                    if ((activeLift & LiftFlag.SurfaceLift) == LiftFlag.SurfaceLift)
                    {
                        _positionAvg.Add(_centerOfLift.Position);
                        _directionAvg.Add(_centerOfLift.Direction.normalized);
                    }

                    if ((activeLift & LiftFlag.BodyLift) == LiftFlag.BodyLift)
                    {
                        _positionAvg.Add(_bodyLift.Position);
                        _directionAvg.Add(_bodyLift.Direction.normalized);
                    }

                    DrawTools.DrawSphere(_positionAvg.Get(), XKCDColors.Purple, 0.9f * SphereScale);
                    DrawTools.DrawArrow(_positionAvg.Get(), _directionAvg.Get().normalized *ArrowLength, XKCDColors.Purple);
                }
                else
                {
                    if ((activeLift & LiftFlag.SurfaceLift) == LiftFlag.SurfaceLift)
                    {
                        DrawTools.DrawSphere(_centerOfLift.Position, XKCDColors.Blue, 0.9f * SphereScale);
                        DrawTools.DrawArrow(_centerOfLift.Position, _centerOfLift.Direction.normalized * ArrowLength, XKCDColors.Blue);
                    }

                    if ((activeLift & LiftFlag.BodyLift) == LiftFlag.BodyLift)
                    {
                        DrawTools.DrawSphere(_bodyLift.Position, XKCDColors.Cyan, 0.85f * SphereScale);
                        DrawTools.DrawArrow(_bodyLift.Position, _bodyLift.Direction.normalized * ArrowLength, XKCDColors.Cyan);
                    }
                }

                if (_drag.Total > DragCutoff)
                {
                    DrawTools.DrawSphere(_drag.Position, XKCDColors.Red, 0.8f * SphereScale);
                    DrawTools.DrawArrow(_drag.Position, _drag.Direction.normalized * ArrowLength, XKCDColors.Red);
                }
            }

            Profiler.EndSample();
        }