Some adjustments to coordtrans

This commit is contained in:
SiboVG 2023-08-23 17:15:51 +02:00
parent 855adcab13
commit b1c8bbc895
2 changed files with 13 additions and 10 deletions

View File

@ -64,8 +64,8 @@ public class CoordTransform {
* @param origYOffs the y-offset of the origin of the OBJ coordinate system, <b>in the OpenRocket coordinate system</b>
* @param origZOffs the z-offset of the origin of the OBJ coordinate system, <b>in the OpenRocket coordinate system</b>
*/
public static CoordTransform generateUsingLongitudinalAndForwardAxes(Axis axialAxis, Axis forwardAxis,
double origXOffs, double origYOffs, double origZOffs) {
public static CoordTransform generateUsingAxialAndForwardAxes(Axis axialAxis, Axis forwardAxis,
double origXOffs, double origYOffs, double origZOffs) {
if (axialAxis == null || forwardAxis == null) {
throw new IllegalArgumentException("Axes cannot be null");
}
@ -74,6 +74,8 @@ public class CoordTransform {
throw new IllegalArgumentException("Axes must be different");
}
Axis depthAxis = Axis.getThirdAxis(axialAxis, forwardAxis);
Axis xAxis = null;
Axis yAxis = null;
Axis zAxis = null;
@ -96,14 +98,15 @@ public class CoordTransform {
case Z_MIN -> zAxis = Axis.Y_MIN;
}
Axis depthAxis = Axis.getThirdAxis(axialAxis, forwardAxis);
switch (depthAxis) {
case X -> xAxis = Axis.Z;
case X_MIN -> xAxis = Axis.Z_MIN;
case Y -> yAxis = Axis.Z;
case Y_MIN -> yAxis = Axis.Z_MIN;
case Z -> zAxis = Axis.Z;
case Z_MIN -> zAxis = Axis.Z_MIN;
// OpenRocket uses left-handed coordinate system, so invert the axis
case X -> xAxis = Axis.Z_MIN;
case X_MIN -> xAxis = Axis.Z;
case Y -> yAxis = Axis.Z_MIN;
case Y_MIN -> yAxis = Axis.Z;
case Z -> zAxis = Axis.Z_MIN;
case Z_MIN -> zAxis = Axis.Z;
}
if (xAxis == null || yAxis == null || zAxis == null) {

View File

@ -223,7 +223,7 @@ public class OBJOptionChooser extends JPanel {
opts.setScaling((float) scalingModel.getValue());
opts.setLOD((ObjUtils.LevelOfDetail) LOD.getSelectedItem());
CoordTransform transformer = CoordTransform.generateUsingLongitudinalAndForwardAxes(
CoordTransform transformer = CoordTransform.generateUsingAxialAndForwardAxes(
(Axis) axialCombo.getSelectedItem(), (Axis) forwardCombo.getSelectedItem(),
rocket.getLength(), 0, 0);
opts.setTransformer(transformer);