DGP - updated Rocksim export to support clusters
This commit is contained in:
parent
dc2690df2f
commit
c329a7d789
@ -35,7 +35,7 @@ public abstract class Warning {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
return (o.getClass() == this.getClass());
|
return o != null && (o.getClass() == this.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,12 +64,12 @@ public class BodyTubeDTO extends BasePartDTO {
|
|||||||
super(inner);
|
super(inner);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BodyTubeDTO(BodyTube bt) {
|
protected BodyTubeDTO(BodyTube bt) {
|
||||||
super(bt);
|
super(bt);
|
||||||
|
|
||||||
setEngineOverhang(bt.getMotorOverhang() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
|
setEngineOverhang(bt.getMotorOverhang() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||||
setId(bt.getInnerRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
setID(bt.getInnerRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||||
setOd(bt.getOuterRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
setOD(bt.getOuterRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||||
setMotorDia((bt.getMotorMountDiameter() / 2) * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
setMotorDia((bt.getMotorMountDiameter() / 2) * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||||
setMotorMount(bt.isMotorMount());
|
setMotorMount(bt.isMotorMount());
|
||||||
|
|
||||||
@ -103,23 +103,22 @@ public class BodyTubeDTO extends BasePartDTO {
|
|||||||
} else if (rocketComponents instanceof FinSet) {
|
} else if (rocketComponents instanceof FinSet) {
|
||||||
attachedParts.add(new FinSetDTO((FinSet) rocketComponents));
|
attachedParts.add(new FinSetDTO((FinSet) rocketComponents));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getOd() {
|
public double getOD() {
|
||||||
return od;
|
return od;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOd(double theOd) {
|
public void setOD(double theOd) {
|
||||||
od = theOd;
|
od = theOd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getId() {
|
public double getID() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(double theId) {
|
public void setID(double theId) {
|
||||||
id = theId;
|
id = theId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import net.sf.openrocket.file.rocksim.RocksimCommonConstants;
|
|||||||
import net.sf.openrocket.rocketcomponent.BodyTube;
|
import net.sf.openrocket.rocketcomponent.BodyTube;
|
||||||
import net.sf.openrocket.rocketcomponent.Bulkhead;
|
import net.sf.openrocket.rocketcomponent.Bulkhead;
|
||||||
import net.sf.openrocket.rocketcomponent.CenteringRing;
|
import net.sf.openrocket.rocketcomponent.CenteringRing;
|
||||||
|
import net.sf.openrocket.rocketcomponent.ClusterConfiguration;
|
||||||
import net.sf.openrocket.rocketcomponent.EngineBlock;
|
import net.sf.openrocket.rocketcomponent.EngineBlock;
|
||||||
import net.sf.openrocket.rocketcomponent.InnerTube;
|
import net.sf.openrocket.rocketcomponent.InnerTube;
|
||||||
import net.sf.openrocket.rocketcomponent.MassObject;
|
import net.sf.openrocket.rocketcomponent.MassObject;
|
||||||
@ -12,6 +13,7 @@ import net.sf.openrocket.rocketcomponent.RocketComponent;
|
|||||||
import net.sf.openrocket.rocketcomponent.Streamer;
|
import net.sf.openrocket.rocketcomponent.Streamer;
|
||||||
import net.sf.openrocket.rocketcomponent.Transition;
|
import net.sf.openrocket.rocketcomponent.Transition;
|
||||||
import net.sf.openrocket.rocketcomponent.TubeCoupler;
|
import net.sf.openrocket.rocketcomponent.TubeCoupler;
|
||||||
|
import net.sf.openrocket.util.Coordinate;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
@ -29,13 +31,21 @@ public class InnerBodyTubeDTO extends BodyTubeDTO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public InnerBodyTubeDTO(InnerTube bt) {
|
public InnerBodyTubeDTO(InnerTube bt) {
|
||||||
|
this(bt, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InnerBodyTubeDTO(InnerTube bt, boolean deep) {
|
||||||
super(bt);
|
super(bt);
|
||||||
setEngineOverhang(bt.getMotorOverhang() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
|
setEngineOverhang(bt.getMotorOverhang() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||||
setId(bt.getInnerRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
setID(bt.getInnerRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||||
setOd(bt.getOuterRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
setOD(bt.getOuterRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||||
setMotorDia((bt.getMotorMountDiameter() / 2) * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
setMotorDia((bt.getMotorMountDiameter() / 2) * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||||
setMotorMount(bt.isMotorMount());
|
setMotorMount(bt.isMotorMount());
|
||||||
|
setInsideTube(true);
|
||||||
|
setRadialAngle(bt.getRadialDirection());
|
||||||
|
setRadialLoc(bt.getRadialPosition() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||||
|
|
||||||
|
if (deep) {
|
||||||
List<RocketComponent> children = bt.getChildren();
|
List<RocketComponent> children = bt.getChildren();
|
||||||
for (int i = 0; i < children.size(); i++) {
|
for (int i = 0; i < children.size(); i++) {
|
||||||
RocketComponent rocketComponents = children.get(i);
|
RocketComponent rocketComponents = children.get(i);
|
||||||
@ -61,6 +71,32 @@ public class InnerBodyTubeDTO extends BodyTubeDTO {
|
|||||||
attachedParts.add(new MassObjectDTO((MassObject) rocketComponents));
|
attachedParts.add(new MassObjectDTO((MassObject) rocketComponents));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setInsideTube(true);
|
}
|
||||||
|
|
||||||
|
//Do the cluster. For now this splits the cluster into separate tubes, which is how Rocksim represents it.
|
||||||
|
//The import (from Rocksim to OR) could be augmented to be more intelligent and try to determine if the
|
||||||
|
//co-located tubes are a cluster.
|
||||||
|
if (bt.getClusterConfiguration().getClusterCount() > 1) {
|
||||||
|
handleCluster(bt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleCluster(InnerTube it) {
|
||||||
|
|
||||||
|
Coordinate[] coords = {Coordinate.NUL};
|
||||||
|
coords = it.shiftCoordinates(coords);
|
||||||
|
for (int x = 0; x < coords.length; x++) {
|
||||||
|
InnerTube copy = (InnerTube) it.copy();
|
||||||
|
copy.setClusterConfiguration(ClusterConfiguration.SINGLE);
|
||||||
|
copy.setClusterRotation(0.0);
|
||||||
|
copy.setClusterScale(1.0);
|
||||||
|
copy.setRadialShift(coords[x].y, coords[x].z);
|
||||||
|
copy.setName(copy.getName() + " #" + (x + 1));
|
||||||
|
attachedParts.add(copy(copy));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private InnerBodyTubeDTO copy(InnerTube it) {
|
||||||
|
return new InnerBodyTubeDTO(it, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user