Skip to content

Commit

Permalink
wheel alignment tool, cfg Strut values removed, rotor trim cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
snjo committed May 21, 2014
1 parent 9b86aef commit 4e8513e
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Firespitter/engine/FSrotorTrim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public class FSrotorTrim : PartModule
public float steerAmount = 20f;
[KSPField]
public float hoverHeatModifier = 5f;
[KSPField]
public string rootPart = "copterEngineMain";
//[KSPField]
//public string rootPart = "copterEngineMain";

[KSPField(guiActive = true, guiName = "Steering", isPersistant = true)]
public bool steeringEnabled = false;
Expand Down
82 changes: 67 additions & 15 deletions Firespitter/wheel/FSwheelAlignment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,27 @@ public class FSwheelAlignment : PartModule
int textureSize = 1;
float lineLength = 5f;

Vector3 anglePointForwardHorizontal;
Vector3 anglePointForwardVertical;
Vector3 anglePointBackHorizontal;
Vector3 anglePointBackVertical;
Vector3 anglePointUpX;
Vector3 anglePointUpZ;

Vector3 centerPoint;
Vector3 guidePointForward;
Vector3 guidePointBack;
Vector3 guidePointUp;

Vector3 wheelPointForward;
Vector3 wheelPointBack;
Vector3 wheelPointUp;

float forwardAngleHorizontal;
float forwardAngleVertical;
float upAngleX;
float upAngleZ;

[KSPField]
public bool showToggle = true;

Expand Down Expand Up @@ -105,21 +126,14 @@ private void updateLinePositions()
{
if (wheel != null)
{
Vector3 anglePointForwardHorizontal;
Vector3 anglePointForwardVertical;
Vector3 anglePointBackHorizontal;
Vector3 anglePointBackVertical;
Vector3 anglePointUpX;
Vector3 anglePointUpZ;

Vector3 centerPoint = wheel.transform.position;
Vector3 guidePointForward = wheel.transform.position + Vector3.forward.normalized * lineLength;
Vector3 guidePointBack = wheel.transform.position - Vector3.forward.normalized * lineLength;
Vector3 guidePointUp = wheel.transform.position + Vector3.up.normalized * lineLength;

Vector3 wheelPointForward = wheel.transform.position + wheel.transform.forward.normalized * lineLength;
Vector3 wheelPointBack = wheel.transform.position - wheel.transform.forward.normalized * lineLength;
Vector3 wheelPointUp = wheel.transform.position + wheel.transform.up.normalized * lineLength;
centerPoint = wheel.transform.position;
guidePointForward = wheel.transform.position + Vector3.forward.normalized * lineLength;
guidePointBack = wheel.transform.position - Vector3.forward.normalized * lineLength;
guidePointUp = wheel.transform.position + Vector3.up.normalized * lineLength;

wheelPointForward = wheel.transform.position + wheel.transform.forward.normalized * lineLength;
wheelPointBack = wheel.transform.position - wheel.transform.forward.normalized * lineLength;
wheelPointUp = wheel.transform.position + wheel.transform.up.normalized * lineLength;

if (Vector3.Distance(wheelPointForward, guidePointForward) < Vector3.Distance(wheelPointForward, guidePointBack))
{
Expand Down Expand Up @@ -158,6 +172,44 @@ private void updateLinePositions()
wheelLine.SetPosition(1, centerPoint);
wheelLine.SetPosition(2, wheelPointForward);
wheelLine.SetPosition(3, wheelPointBack);

Vector3 forwardLineHorizontal = new Vector3(anglePointForwardHorizontal.x, centerPoint.y, anglePointForwardHorizontal.z) - centerPoint;
forwardAngleHorizontal = Vector3.Angle(Vector3.forward, forwardLineHorizontal);
Vector3 forwardLineVertical = new Vector3(centerPoint.x, anglePointForwardVertical.y, anglePointForwardVertical.z) - centerPoint;
forwardAngleVertical = Vector3.Angle(Vector3.forward, forwardLineVertical);

Vector3 upLineX = new Vector3(anglePointUpX.x, anglePointUpX.y, centerPoint.z) - centerPoint;
upAngleX = Vector3.Angle(Vector3.up, upLineX);
Vector3 upLineZ = new Vector3(centerPoint.x, anglePointUpZ.y, anglePointUpZ.z) - centerPoint;
upAngleZ = Vector3.Angle(Vector3.up, upLineZ);

}
}

private float clampAngle(float angle)
{
if (angle > 180f) angle = 180f - angle;
if (angle > 90f) angle = 180f - angle;
return angle;
}

private void drawAngleText(Vector3 worldPosition, float value)
{
Vector3 labelPos = Camera.main.WorldToScreenPoint(worldPosition);
GUI.Label(new Rect(labelPos.x, Screen.height - labelPos.y - 15f, 100f, 100f), ((int)(clampAngle(value))).ToString());

}

public void OnGUI()
{
if (showGuides)
{
drawAngleText(anglePointForwardHorizontal, forwardAngleHorizontal);
drawAngleText(anglePointForwardVertical, forwardAngleVertical);
drawAngleText(anglePointBackHorizontal, forwardAngleHorizontal);
drawAngleText(anglePointBackVertical, forwardAngleVertical);
drawAngleText(anglePointUpX, upAngleX);
drawAngleText(anglePointUpZ, upAngleZ);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PART

// --- general parameters ---
name = FSoblongNoseIntake
module = Strut
module = Part
author = Snjo

// --- asset parameters ---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PART

// --- general parameters ---
name = FSoblongNose
module = Strut
module = Part
author = Snjo

// --- asset parameters ---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PART

// --- general parameters ---
name = FSoblongTail
module = Strut
module = Part
author = Snjo

// --- asset parameters ---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PART

// --- general parameters ---
name = FSengineMount
module = Strut
module = Part
author = Snjo

// --- asset parameters ---
Expand Down
Binary file modified For release/Firespitter/Plugins/Firespitter.dll
Binary file not shown.

0 comments on commit 4e8513e

Please sign in to comment.