Exemple #1
0
 public GeometryModel3D createRoadModel(Road road)
 {
     return(createRoadModel(road.Points, road.Width));
 }
Exemple #2
0
        public void Update()
        {
            // 更新地形
            if (_data == null)
            {
                return;
            }
            _model.Data = new double[_data.Length];
            for (int i = 0; i < _model.Height; i++)
            {
                for (int j = 0; j < _model.Width; j++)
                {
                    _model.Data[i * _model.Width + j] = _data[(_model.Height - i - 1) * _model.Width + j] * VerticalMagnification;
                }
            }
            _model.MinimumZ = _model.Data.Min();
            _model.MaximumZ = _model.Data.Max();
            switch (TextureType)
            {
            case TextureType.Elevation:
                var et = new ElevationTexture();
                if (ElevationBrush != null)
                {
                    et.Brush = ElevationBrush;
                }
                _model.Texture = et;
                break;

            case TextureType.Slope:
                var st = new SlopeTexture(18);
                if (SlopeBrush != null)
                {
                    st.Brush = SlopeBrush;
                }
                _model.Texture = st;
                break;
            }
            _visualChild.Content = _model.CreateModel(2);

            // 更新道路
            for (int i = 0; i < _roads.Count; i++)
            {
                var roadModel = new RoadModel
                {
                    RoadColor = RoadColor,
                    Offset    = _model.Offset
                };

                var road = new Road
                {
                    Width  = _roads[i].Width,
                    Points = new Point3D[_roads[i].Points.Length]
                };

                for (int j = 0; j < _roads[i].Points.Length; j++)
                {
                    road.Points[j]   = _roads[i].Points[j];
                    road.Points[j].Z = _roads[i].Points[j].Z * VerticalMagnification;
                }
                _roadChilds[i].Content = roadModel.createRoadModel(road);
            }
        }