X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fthreedee%2FThreeDModel.java;h=7245633aa0667b936a0d5307fc8b0b84f2b38136;hb=140e9d165f85c3d4f0435a311e091209313faa2a;hp=5123f7c83bf65d6ad557b49a96f5065da2ef262e;hpb=52bf9e8686c916be37a26a0b75340393d4478b05;p=GpsPrune.git diff --git a/tim/prune/threedee/ThreeDModel.java b/tim/prune/threedee/ThreeDModel.java index 5123f7c..7245633 100644 --- a/tim/prune/threedee/ThreeDModel.java +++ b/tim/prune/threedee/ThreeDModel.java @@ -15,15 +15,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; - public static final int MINIMUM_ALTITUDE_CAP = 100; // Constants for point types public static final byte POINT_TYPE_WAYPOINT = 1; @@ -63,21 +61,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 */ @@ -101,21 +94,11 @@ public class ThreeDModel _scaleFactor = _modelSize / _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 > _modelSize) { + // capped + _altFactor = _altFactor * _modelSize / maxScaledAlt; } // calculate lat/long lines _scaler.calculateLatLongLines(); @@ -137,8 +120,9 @@ public class ThreeDModel for (int i=0; i