Skip to content

Commit

Permalink
Merge pull request #913 from taniwha/launchclamp_el_compat
Browse files Browse the repository at this point in the history
Pre-rotate the anchor transform
  • Loading branch information
drewcassidy authored Oct 5, 2020
2 parents 2fbfe71 + 7a29651 commit aaaa4d0
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion Source/Restock/ModuleRestockLaunchClamp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class ModuleRestockLaunchClamp : LaunchClamp
public LaunchClampGirderFactory girderFactory;

private int _girderSegments;
private Quaternion towerRot;

private Material _girderMaterial;
private Matrix4x4[] _girderMatrices;
Expand Down Expand Up @@ -63,12 +64,28 @@ public override void OnLoad(ConfigNode node)
girderFactory.Initialize(girderMesh, girderSegmentHeight, maxSegments);
}
}

if (node.HasValue ("towerRot"))
{
string rot = node.GetValue ("towerRot");
towerRot = KSPUtil.ParseQuaternion (rot);
}

_girderSegments = 1;

base.OnLoad(node);
}

public void RotateTower ()
{
// transforms found in OnLoad
float height = Vector3.Distance (towerAnchor.position, towerStretch.position);
//Debug.Log($"[ModuleRestockLaunchClamp] RotateTower: {height} {towerRot}");
towerPivot.localRotation = towerRot;
towerAnchor.localRotation = towerRot;
towerAnchor.position = towerStretch.position - towerStretch.up * height;
}

public override void OnStart(StartState state)
{
base.OnStart(state);
Expand Down Expand Up @@ -144,4 +161,4 @@ private void UpdateGirderMesh(int girderSegments)
girderMeshFilter.mesh = girderFactory.makeGirder(girderSegments);
}
}
}
}

0 comments on commit aaaa4d0

Please sign in to comment.