X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Fscenegraph%2Fcontrolpoint%2FPipeControlPoint.java;h=ecaeb7ae7c41d2b70017d4de433dfac968270ecc;hb=refs%2Fchanges%2F59%2F3059%2F1;hp=b14b298bcf26d0060ea91ec09521f740fc596b45;hpb=68bb44ea41644141aaaf7467ac3d201678e31db3;p=simantics%2F3d.git diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java index b14b298b..ecaeb7ae 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java @@ -32,6 +32,7 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { private Type type; private boolean fixed = true; private boolean rotate = false; + private boolean reverse = false; private boolean deletable = true; private boolean sub = false; @@ -88,11 +89,19 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { return rotate; } - public void setRotate(boolean rotate) { this.rotate = rotate; } + @GetPropertyValue(name="Reverse",tabId="Debug",value="reverse") + public boolean isReverse() { + return reverse; + } + + public void setReverse(boolean reverse) { + this.reverse = reverse; + } + public void setSub(boolean sub) { this.sub = sub; } @@ -230,6 +239,7 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { private Double offset; private Double rotationAngle; + private Boolean reversed; @GetPropertyValue(name="Length",tabId="Debug",value="length") public double getLength() { @@ -268,6 +278,11 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { return rotationAngle; } + @GetPropertyValue(name="Reversed",tabId="Debug",value="reversed") + public Boolean getReversed() { + return reversed; + } + public void setTurnAngle(Double turnAngle) { if (Double.isInfinite(turnAngle) || Double.isNaN(turnAngle)) { return; @@ -303,6 +318,11 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { firePropertyChanged("rotationAngle"); } + public void setReversed(Boolean reversed) { + this.reversed = reversed; + firePropertyChanged("rotationAngle"); + } + public Vector3d getSizeChangeOffsetVector(Vector3d dir) { Quat4d q; if (rotationAngle == null) @@ -353,7 +373,7 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { return type.name(); } - public Quat4d getControlPointOrientationQuat(double angle) { + public Quat4d getControlPointOrientationQuat(double angle) { if (turnAxis == null) { Vector3d dir = getPathLegDirection(Direction.NEXT); @@ -367,11 +387,33 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { dir.normalize(); return getControlPointOrientationQuat(dir, turnAxis, angle); } - } + } + + public Quat4d getControlPointOrientationQuat(double angle, boolean reversed) { + + if (turnAxis == null) { + Vector3d dir = getPathLegDirection(Direction.NEXT); + if (dir.lengthSquared() > MathTools.NEAR_ZERO) + dir.normalize(); + Quat4d q = getControlPointOrientationQuat(dir, angle); + if (reversed) { + Quat4d q2 = new Quat4d(); + q2.set(new AxisAngle4d(MathTools.Y_AXIS, Math.PI)); + q.mulInverse(q2); + } + return q; + } else { + Vector3d dir = getPathLegDirection(Direction.PREVIOUS); + dir.negate(); + if (dir.lengthSquared() > MathTools.NEAR_ZERO) + dir.normalize(); + return getControlPointOrientationQuat(dir, turnAxis, angle); + } + } - public static Quat4d getControlPointOrientationQuat(Vector3d dir, double angle) { + public static Quat4d getControlPointOrientationQuat(Vector3d dir, double angle) { if (dir.lengthSquared() < MathTools.NEAR_ZERO) return MathTools.getIdentityQuat();