From 121fa02eaf6c1493a8a5f59dcb60d3679e2a6abe Mon Sep 17 00:00:00 2001 From: rodinia814 Date: Mon, 9 Jan 2012 03:36:14 +0000 Subject: [PATCH] DGP - changes to relative position; custom fin set points git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@320 180e2498-e6e9-4542-8430-84ac67f01cd8 --- .../file/rocksim/export/BasePartDTO.java | 28 +++++++++++-------- .../file/rocksim/export/CustomFinSetDTO.java | 4 ++- .../file/rocksim/export/FinSetDTO.java | 12 ++------ .../file/rocksim/export/RocketDesignDTO.java | 2 ++ 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/core/src/net/sf/openrocket/file/rocksim/export/BasePartDTO.java b/core/src/net/sf/openrocket/file/rocksim/export/BasePartDTO.java index 48a4d910..a76eb45c 100644 --- a/core/src/net/sf/openrocket/file/rocksim/export/BasePartDTO.java +++ b/core/src/net/sf/openrocket/file/rocksim/export/BasePartDTO.java @@ -6,6 +6,7 @@ import net.sf.openrocket.file.rocksim.importt.RocksimFinishCode; import net.sf.openrocket.file.rocksim.importt.RocksimHandler; import net.sf.openrocket.file.rocksim.importt.RocksimLocationMode; import net.sf.openrocket.rocketcomponent.ExternalComponent; +import net.sf.openrocket.rocketcomponent.FinSet; import net.sf.openrocket.rocketcomponent.RecoveryDevice; import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.rocketcomponent.StructuralComponent; @@ -47,7 +48,7 @@ public abstract class BasePartDTO { private double radialAngle = 0; @XmlElement(name = "LocationMode") private int locationMode = 0; - @XmlElement(name = "Len") + @XmlElement(name = "Len", required = false, nillable = false) private double len = 0d; @XmlElement(name = "FinishCode") private int finishCode = 0; @@ -60,18 +61,29 @@ public abstract class BasePartDTO { setCalcMass(ec.getComponentMass() * RocksimHandler.ROCKSIM_TO_OPENROCKET_MASS); setKnownCG(ec.getOverrideCGX() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH); setKnownMass(ec.getOverrideMass() * RocksimHandler.ROCKSIM_TO_OPENROCKET_MASS); - setLen(ec.getLength() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH); + if (! (ec instanceof FinSet)) { + setLen(ec.getLength() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH); + } setUseKnownCG(ec.isCGOverridden() || ec.isMassOverridden() ? 1 : 0); setName(ec.getName()); setXb(ec.getPositionValue() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH); + + //When the relative position is BOTTOM, the position location of the bottom edge of the component is + + //to the right of the bottom of the parent, and - to the left. + //But in Rocksim, it's + to the left and - to the right + if (ec.getRelativePosition().equals(RocketComponent.Position.BOTTOM)) { + setXb((-1 * ec.getPositionValue()) * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH); + } + else if (ec.getRelativePosition().equals(RocketComponent.Position.MIDDLE)) { + //Mapped to TOP, so adjust accordingly + setXb((ec.getPositionValue() + (ec.getParent().getLength() - ec.getLength()) /2)* RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH); + } + if (ec instanceof ExternalComponent) { ExternalComponent comp = (ExternalComponent) ec; setLocationMode(RocksimLocationMode.toCode(comp.getRelativePosition())); - if (comp.getRelativePosition().equals(RocketComponent.Position.BOTTOM)) { - setXb(-1 * getXb()); - } setDensity(comp.getMaterial().getDensity() * RocksimHandler.ROCKSIM_TO_OPENROCKET_BULK_DENSITY); setDensityType(RocksimDensityType.toCode(comp.getMaterial().getType())); String material = comp.getMaterial().getName(); @@ -86,9 +98,6 @@ public abstract class BasePartDTO { StructuralComponent comp = (StructuralComponent) ec; setLocationMode(RocksimLocationMode.toCode(comp.getRelativePosition())); - if (comp.getRelativePosition().equals(RocketComponent.Position.BOTTOM)) { - setXb(-1 * getXb()); - } setDensity(comp.getMaterial().getDensity() * RocksimHandler.ROCKSIM_TO_OPENROCKET_BULK_DENSITY); setDensityType(RocksimDensityType.toCode(comp.getMaterial().getType())); String material = comp.getMaterial().getName(); @@ -101,9 +110,6 @@ public abstract class BasePartDTO { RecoveryDevice comp = (RecoveryDevice) ec; setLocationMode(RocksimLocationMode.toCode(comp.getRelativePosition())); - if (comp.getRelativePosition().equals(RocketComponent.Position.BOTTOM)) { - setXb(-1 * getXb()); - } setDensity(comp.getMaterial().getDensity() * RocksimHandler.ROCKSIM_TO_OPENROCKET_SURFACE_DENSITY); setDensityType(RocksimDensityType.toCode(comp.getMaterial().getType())); String material = comp.getMaterial().getName(); diff --git a/core/src/net/sf/openrocket/file/rocksim/export/CustomFinSetDTO.java b/core/src/net/sf/openrocket/file/rocksim/export/CustomFinSetDTO.java index 99112c9d..f37c9fec 100644 --- a/core/src/net/sf/openrocket/file/rocksim/export/CustomFinSetDTO.java +++ b/core/src/net/sf/openrocket/file/rocksim/export/CustomFinSetDTO.java @@ -29,7 +29,9 @@ public class CustomFinSetDTO extends FinSetDTO { private String convertFreeFormPoints(Coordinate[] points) { StringBuilder sb = new StringBuilder(); - for (int i = 0; i < points.length; i++) { + + //Reverse the order for Rocksim + for (int i = points.length - 1; i >= 0; i--) { Coordinate point = points[i]; sb.append(point.x * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH).append(",") .append(point.y * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH).append("|"); diff --git a/core/src/net/sf/openrocket/file/rocksim/export/FinSetDTO.java b/core/src/net/sf/openrocket/file/rocksim/export/FinSetDTO.java index b97571c1..03ba5e37 100644 --- a/core/src/net/sf/openrocket/file/rocksim/export/FinSetDTO.java +++ b/core/src/net/sf/openrocket/file/rocksim/export/FinSetDTO.java @@ -5,7 +5,6 @@ import net.sf.openrocket.file.rocksim.importt.RocksimHandler; import net.sf.openrocket.rocketcomponent.EllipticalFinSet; import net.sf.openrocket.rocketcomponent.FinSet; import net.sf.openrocket.rocketcomponent.FreeformFinSet; -import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.rocketcomponent.TrapezoidFinSet; import javax.xml.bind.annotation.XmlAccessType; @@ -52,33 +51,28 @@ public class FinSetDTO extends BasePartDTO { public FinSetDTO(FinSet ec) { super(ec); - setCantAngle(ec.getCantAngle()); setFinCount(ec.getFinCount()); - setRootChord(ec.getLength() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH); + setCantAngle(ec.getCantAngle()); setTabDepth(ec.getTabHeight() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH); setTabLength(ec.getTabLength() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH); setTabOffset(ec.getTabShift() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH); setThickness(ec.getThickness() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH); - if (ec.getRelativePosition().equals(RocketComponent.Position.BOTTOM)) { - setXb(getXb() + getLen()); - } - setRadialAngle(ec.getBaseRotation()); setTipShapeCode(TipShapeCode.convertTipShapeCode(ec.getCrossSection())); if (ec instanceof TrapezoidFinSet) { TrapezoidFinSet tfs = (TrapezoidFinSet) ec; setShapeCode(0); + setRootChord(ec.getLength() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH); setSemiSpan(tfs.getHeight() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH); setTipChord(tfs.getTipChord() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH); setSweepDistance(tfs.getSweep() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH); - setLen(tfs.getLength()); } else if (ec instanceof EllipticalFinSet) { EllipticalFinSet efs = (EllipticalFinSet) ec; setShapeCode(1); + setRootChord(ec.getLength() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH); setSemiSpan(efs.getHeight() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH); - setLen(efs.getLength() *RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH); } else if (ec instanceof FreeformFinSet) { setShapeCode(2); diff --git a/core/src/net/sf/openrocket/file/rocksim/export/RocketDesignDTO.java b/core/src/net/sf/openrocket/file/rocksim/export/RocketDesignDTO.java index 9abc4464..85a04105 100644 --- a/core/src/net/sf/openrocket/file/rocksim/export/RocketDesignDTO.java +++ b/core/src/net/sf/openrocket/file/rocksim/export/RocketDesignDTO.java @@ -13,6 +13,8 @@ public class RocketDesignDTO { private String name; @XmlElement(name = "StageCount") private int stageCount = 1; + @XmlElement(name = "DisplayFlags") + private int displayFlags = 7; @XmlElement(name = "ViewType") private int viewType = 0; @XmlElement(name = "ViewStageCount") -- 2.39.5