Implement launch velocity into AirStart extension
This commit is contained in:
parent
00a7b7edc7
commit
7aca75f053
@ -398,7 +398,8 @@ simedtdlg.IntensityDesc.High = High
|
|||||||
simedtdlg.IntensityDesc.Veryhigh = Very high
|
simedtdlg.IntensityDesc.Veryhigh = Very high
|
||||||
simedtdlg.IntensityDesc.Extreme = Extreme
|
simedtdlg.IntensityDesc.Extreme = Extreme
|
||||||
|
|
||||||
SimulationExtension.airstart.name = Air-start ({alt})
|
SimulationExtension.airstart.name.alt = Air-start ({alt})
|
||||||
|
SimulationExtension.airstart.name.altvel = Air-start ({alt}, {vel})
|
||||||
SimulationExtension.javacode.name = Java code
|
SimulationExtension.javacode.name = Java code
|
||||||
SimulationExtension.javacode.name.none = none
|
SimulationExtension.javacode.name.none = none
|
||||||
SimulationExtension.javacode.desc = Add a custom SimulationListener to the simulation
|
SimulationExtension.javacode.desc = Add a custom SimulationListener to the simulation
|
||||||
|
@ -18,8 +18,15 @@ public class AirStart extends AbstractSimulationExtension {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
String name = trans.get("SimulationExtension.airstart.name");
|
String name;
|
||||||
return L10N.replace(name, "{alt}", UnitGroup.UNITS_DISTANCE.toStringUnit(getLaunchAltitude()));
|
if (getLaunchVelocity() > 0.01) {
|
||||||
|
name = trans.get("SimulationExtension.airstart.name.altvel");
|
||||||
|
} else {
|
||||||
|
name = trans.get("SimulationExtension.airstart.name.alt");
|
||||||
|
}
|
||||||
|
name = L10N.replace(name, "{alt}", UnitGroup.UNITS_DISTANCE.toStringUnit(getLaunchAltitude()));
|
||||||
|
name = L10N.replace(name, "{vel}", UnitGroup.UNITS_VELOCITY.toStringUnit(getLaunchVelocity()));
|
||||||
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getLaunchAltitude() {
|
public double getLaunchAltitude() {
|
||||||
@ -31,11 +38,21 @@ public class AirStart extends AbstractSimulationExtension {
|
|||||||
fireChangeEvent();
|
fireChangeEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getLaunchVelocity() {
|
||||||
|
return config.getDouble("launchVelocity", 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLaunchVelocity(double launchVelocity) {
|
||||||
|
config.put("launchVelocity", launchVelocity);
|
||||||
|
fireChangeEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private class AirStartListener extends AbstractSimulationListener {
|
private class AirStartListener extends AbstractSimulationListener {
|
||||||
@Override
|
@Override
|
||||||
public void startSimulation(SimulationStatus status) throws SimulationException {
|
public void startSimulation(SimulationStatus status) throws SimulationException {
|
||||||
status.setRocketPosition(new Coordinate(0, 0, getLaunchAltitude()));
|
status.setRocketPosition(new Coordinate(0, 0, getLaunchAltitude()));
|
||||||
|
status.setRocketVelocity(status.getRocketOrientationQuaternion().rotate(new Coordinate(0, 0, getLaunchVelocity())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,21 @@ public class AirStartConfigurator extends AbstractSwingSimulationExtensionConfig
|
|||||||
BasicSlider slider = new BasicSlider(m.getSliderModel(0, 1000));
|
BasicSlider slider = new BasicSlider(m.getSliderModel(0, 1000));
|
||||||
panel.add(slider, "w 75lp, wrap");
|
panel.add(slider, "w 75lp, wrap");
|
||||||
|
|
||||||
|
|
||||||
|
panel.add(new JLabel("Launch velocity:"));
|
||||||
|
|
||||||
|
m = new DoubleModel(extension, "LaunchVelocity", UnitGroup.UNITS_VELOCITY, 0);
|
||||||
|
|
||||||
|
spin = new JSpinner(m.getSpinnerModel());
|
||||||
|
spin.setEditor(new SpinnerEditor(spin));
|
||||||
|
panel.add(spin, "w 65lp!");
|
||||||
|
|
||||||
|
unit = new UnitSelector(m);
|
||||||
|
panel.add(unit, "w 25");
|
||||||
|
|
||||||
|
slider = new BasicSlider(m.getSliderModel(0, 150));
|
||||||
|
panel.add(slider, "w 75lp, wrap");
|
||||||
|
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user