X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fthreedee%2FThreeDModel.java;h=ddf91623b717309daf1bb3bfcd82dadefe850097;hb=7f5ed2be62905bd37717376dc22d09e5ea7edb4d;hp=db748c0bd825ccc917c87a6664ca94781c40196a;hpb=23959e65a6a0d581e657b07186d18b7a1ac5afeb;p=GpsPrune.git diff --git a/tim/prune/threedee/ThreeDModel.java b/tim/prune/threedee/ThreeDModel.java index db748c0..ddf9162 100644 --- a/tim/prune/threedee/ThreeDModel.java +++ b/tim/prune/threedee/ThreeDModel.java @@ -1,6 +1,5 @@ package tim.prune.threedee; -import tim.prune.data.Altitude; import tim.prune.data.DataPoint; import tim.prune.data.PointScaler; import tim.prune.data.Track; @@ -14,20 +13,17 @@ 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? + private double _externalScaleFactor = 1.0; + // 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; - public static final byte POINT_TYPE_NORMAL_POINT = 2; + public static final byte POINT_TYPE_WAYPOINT = 1; + public static final byte POINT_TYPE_NORMAL_POINT = 2; + public static final byte POINT_TYPE_SEGMENT_START = 3; /** @@ -35,21 +31,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; } @@ -62,20 +45,23 @@ 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; } } + /** + * @param inSize size of model + */ + public void setModelSize(double inSize) + { + _externalScaleFactor = inSize; + } /** * Scale all points and calculate factors @@ -84,40 +70,16 @@ public class ThreeDModel { // Use PointScaler to sort out x and y values _scaler = new PointScaler(_track); - _scaler.scale(); - // Calculate scale factor to fit within box - _scaleFactor = 1.0; - if (_scaler.getMaximumHoriz() > 0.0 || _scaler.getMaximumVert() > 0.0) - { - if (_scaler.getMaximumHoriz() > _scaler.getMaximumVert()) - { - // scale limited by longitude - _scaleFactor = _modelSize / _scaler.getMaximumHoriz(); - } - else - { - // scale limited by latitude - _scaleFactor = _modelSize / _scaler.getMaximumVert(); - } - } - // calculate altitude scale factor - _altFactor = 1.0; - if (_scaler.getMaximumAlt() >= 0) + _scaler.scale(); // Add 10% border + + // cap altitude scale factor if it's too big + double maxAlt = _scaler.getAltitudeRange() * _altFactor; + if (maxAlt > 0.5) { - // 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; - } + // capped + //System.out.println("Capped alt factor from " + _altFactor + " to " + (_altFactor * 0.5 / maxAlt)); + _altFactor = _altFactor * 0.5 / maxAlt; } - // calculate lat/long lines - _scaler.calculateLatLongLines(); // calculate point types and height codes calculatePointTypes(); @@ -136,8 +98,9 @@ public class ThreeDModel for (int i=0; i