X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fthreedee%2FThreeDModel.java;h=2c9ac97784e79f24e2c378766283720e354c8a15;hb=4d5796d02a15808311c09448d79e6e7d1de9d636;hp=929659bcd8ee92704bd0949b29d951f5579946a9;hpb=54b9d8bc8f0025ccf97a67d9dd217ef1f9cf082f;p=GpsPrune.git diff --git a/tim/prune/threedee/ThreeDModel.java b/tim/prune/threedee/ThreeDModel.java index 929659b..2c9ac97 100644 --- a/tim/prune/threedee/ThreeDModel.java +++ b/tim/prune/threedee/ThreeDModel.java @@ -14,17 +14,13 @@ public class ThreeDModel { private Track _track = null; private PointScaler _scaler = null; - private double _modelSize; - private int _altitudeCap = -1; private double _scaleFactor = 1.0; private double _altFactor = 1.0; - // TODO: How to store rods (lifts) in data? + // MAYBE: How to store rods (lifts) in data? private byte[] _pointTypes = null; private byte[] _pointHeights = null; - private static final double DEFAULT_MODEL_SIZE = 10.0; - /** Minimum altitude cap */ - public static final int MINIMUM_ALTITUDE_CAP = 100; + private static final double MODEL_SIZE = 10.0; // Constants for point types public static final byte POINT_TYPE_WAYPOINT = 1; @@ -37,21 +33,8 @@ public class ThreeDModel * @param inTrack Track object */ public ThreeDModel(Track inTrack) - { - this(inTrack, DEFAULT_MODEL_SIZE); - } - - - /** - * Constructor - * @param inTrack Track object - * @param inSize model size - */ - public ThreeDModel(Track inTrack, double inSize) { _track = inTrack; - _modelSize = inSize; - if (_modelSize <= 0.0) _modelSize = DEFAULT_MODEL_SIZE; } @@ -64,21 +47,16 @@ public class ThreeDModel return _track.getNumPoints(); } - /** - * Set the altitude cap - * @param inAltitudeCap altitude range to cap to (ignored if less than data range) + * @param inFactor altitude exaggeration factor (default 1.0) */ - public void setAltitudeCap(int inAltitudeCap) + public void setAltitudeFactor(double inFactor) { - _altitudeCap = inAltitudeCap; - if (_altitudeCap < MINIMUM_ALTITUDE_CAP) - { - _altitudeCap = MINIMUM_ALTITUDE_CAP; + if (inFactor >= 1.0) { + _altFactor = inFactor; } } - /** * Scale all points and calculate factors */ @@ -94,29 +72,19 @@ public class ThreeDModel if (_scaler.getMaximumHoriz() > _scaler.getMaximumVert()) { // scale limited by longitude - _scaleFactor = _modelSize / _scaler.getMaximumHoriz(); + _scaleFactor = MODEL_SIZE / _scaler.getMaximumHoriz(); } else { // scale limited by latitude - _scaleFactor = _modelSize / _scaler.getMaximumVert(); + _scaleFactor = MODEL_SIZE / _scaler.getMaximumVert(); } } - // calculate altitude scale factor - _altFactor = 1.0; - if (_scaler.getMaximumAlt() >= 0) - { - // limit by altitude cap or by data range? - if (_scaler.getMaximumAlt() > _altitudeCap) - { - // data is bigger than cap - _altFactor = _modelSize / _scaler.getMaximumAlt(); - } - else - { - // capped - _altFactor = _modelSize / _altitudeCap; - } + // cap altitude scale factor if it's too big + double maxScaledAlt = _scaler.getMaxScaledAlt() * _altFactor; + if (maxScaledAlt > MODEL_SIZE) { + // capped + _altFactor = _altFactor * MODEL_SIZE / maxScaledAlt; } // calculate lat/long lines _scaler.calculateLatLongLines(); @@ -138,7 +106,8 @@ public class ThreeDModel for (int i=0; i