Пример #1
0
		void DrawAlignmentIndicator()
		{
			if(fireTransforms == null || fireTransforms[0] == null) return;

			Transform refTransform = EditorLogic.RootPart.GetReferenceTransform();

			Vector3 fwdPos = fireTransforms[0].position + (5 * fireTransforms[0].forward);
			BDGUIUtils.DrawLineBetweenWorldPositions(fireTransforms[0].position, fwdPos, 4, Color.green);

			Vector3 referenceDirection = refTransform.up;
			Vector3 refUp = -refTransform.forward;
			Vector3 refRight = refTransform.right;

			Vector3 refFwdPos = fireTransforms[0].position + (5 * referenceDirection);
			BDGUIUtils.DrawLineBetweenWorldPositions(fireTransforms[0].position, refFwdPos, 2, Color.white);

			BDGUIUtils.DrawLineBetweenWorldPositions(fwdPos, refFwdPos, 2, XKCDColors.Orange);

			Vector2 guiPos;
			if(BDGUIUtils.WorldToGUIPos(fwdPos, out guiPos))
			{
				Rect angleRect = new Rect(guiPos.x, guiPos.y, 100, 200);

				Vector3 pitchVector = (5 *Vector3.ProjectOnPlane(fireTransforms[0].forward, refRight));
				Vector3 yawVector = (5 * Vector3.ProjectOnPlane(fireTransforms[0].forward, refUp));

				BDGUIUtils.DrawLineBetweenWorldPositions(fireTransforms[0].position + pitchVector, fwdPos, 3, Color.white);
				BDGUIUtils.DrawLineBetweenWorldPositions(fireTransforms[0].position + yawVector, fwdPos, 3, Color.white);

				float pitch = Vector3.Angle(pitchVector, referenceDirection);
				float yaw = Vector3.Angle(yawVector, referenceDirection); 

				string convergeDistance;

				Vector3 projAxis = Vector3.Project(refTransform.position - fireTransforms[0].transform.position, refRight);
				float xDist = projAxis.magnitude;
				float convergeAngle = 90 - Vector3.Angle(yawVector, refTransform.up);
				if(Vector3.Dot(fireTransforms[0].forward, projAxis) > 0)
				{
					convergeDistance = "Converge: "+Mathf.Round((xDist * Mathf.Tan(convergeAngle*Mathf.Deg2Rad))).ToString()+"m";
				}
				else
				{
					convergeDistance = "Diverging";
				}

				string xAngle = "X: " + Vector3.Angle(fireTransforms[0].forward, pitchVector).ToString("0.00");
				string yAngle = "Y: " + Vector3.Angle(fireTransforms[0].forward, yawVector).ToString("0.00");

				GUI.Label(angleRect, xAngle+"\n"+ yAngle + "\n"+convergeDistance);
			}
		}
Пример #2
0
        void OnGUI()
        {
            if (pilotEnabled && vessel.isActiveVessel)
            {
                if (BDArmorySettings.DRAW_DEBUG_LABELS)
                {
                    GUI.Label(new Rect(200, 800, 400, 400), debugString);
                }

                if (BDArmorySettings.DRAW_DEBUG_LINES)
                {
                    if (command == PilotCommands.Follow)
                    {
                        BDGUIUtils.DrawLineBetweenWorldPositions(vesselTransform.position, commandPosition, 2, Color.red);
                    }
                }
            }
        }
Пример #3
0
        void OnGUI()
        {
            if (HighLogic.LoadedSceneIsFlight && !MapView.MapIsEnabled && BDArmorySettings.GAME_UI_ENABLED && !delayedEnabling)
            {
                if (cameraEnabled && vessel.isActiveVessel && FlightGlobals.ready)
                {
                    //window
                    if (activeCam == this && TargetingCamera.ReadyForUse)
                    {
                        camWindowRect = GUI.Window(125452, camWindowRect, CamWindow, string.Empty, HighLogic.Skin.window);
                        BDGUIUtils.UseMouseEventInRect(camWindowRect);
                    }

                    //locked target icon
                    if (groundStabilized)
                    {
                        BDGUIUtils.DrawTextureOnWorldPos(groundTargetPosition, BDArmorySettings.Instance.greenPointCircleTexture, new Vector3(20, 20), 0);
                    }
                    else
                    {
                        BDGUIUtils.DrawTextureOnWorldPos(targetPointPosition, BDArmorySettings.Instance.greenCircleTexture, new Vector3(18, 18), 0);
                    }
                }

                if (BDArmorySettings.DRAW_DEBUG_LABELS)
                {
                    GUI.Label(new Rect(500, 500, 500, 500), "Slew rate: " + finalSlewSpeed);
                }

                if (BDArmorySettings.DRAW_DEBUG_LINES)
                {
                    if (groundStabilized)
                    {
                        BDGUIUtils.DrawLineBetweenWorldPositions(cameraParentTransform.position, groundTargetPosition, 2, Color.red);
                    }
                    else
                    {
                        BDGUIUtils.DrawLineBetweenWorldPositions(cameraParentTransform.position, targetPointPosition, 2, Color.red);
                    }
                }
            }
        }
Пример #4
0
		void OnGUI()
		{
			if(weaponState == WeaponStates.Enabled && vessel && !vessel.packed && vessel.isActiveVessel && BDArmorySettings.DRAW_AIMERS && !aiControlled & !MapView.MapIsEnabled)
			{
				float size = 30;
				
				Vector3 reticlePosition;
				if(BDArmorySettings.AIM_ASSIST && vessel.srf_velocity.sqrMagnitude < Mathf.Pow(750,2))
				{
					if(targetAcquired && (slaved || yawRange < 1 || maxPitch-minPitch < 1))
					{
						reticlePosition = pointingAtPosition+fixedLeadOffset;

						if(!slaved)
						{
							BDGUIUtils.DrawLineBetweenWorldPositions(pointingAtPosition, reticlePosition, 2, new Color(0, 1, 0, 0.6f));
						}

						BDGUIUtils.DrawTextureOnWorldPos(pointingAtPosition, BDArmorySettings.Instance.greenDotTexture, new Vector2(6, 6), 0);

						if(atprAcquired)
						{
							BDGUIUtils.DrawTextureOnWorldPos(targetPosition, BDArmorySettings.Instance.openGreenSquare, new Vector2(20, 20), 0);
						}
					}
					else
					{
						reticlePosition = bulletPrediction;
					}
				}
				else
				{
					reticlePosition = pointingAtPosition;
				}
				

				
				Texture2D texture;
				if(Vector3.Angle(pointingAtPosition-transform.position, finalAimTarget-transform.position) < 1f)
				{
					texture = BDArmorySettings.Instance.greenSpikedPointCircleTexture;
				}
				else
				{
					texture = BDArmorySettings.Instance.greenPointCircleTexture;
				}
				BDGUIUtils.DrawTextureOnWorldPos (reticlePosition, texture, new Vector2 (size, size), 0);

				if(BDArmorySettings.DRAW_DEBUG_LINES)
				{
					if(targetAcquired)
					{
						BDGUIUtils.DrawLineBetweenWorldPositions(fireTransforms[0].position, targetPosition, 2, Color.blue);
					}
				}
			}

			if(HighLogic.LoadedSceneIsEditor && BDArmorySettings.showWeaponAlignment)
			{
				DrawAlignmentIndicator();
			}
		}