예제 #1
0
        public override void Calculate(TerrainModel model, MeshGeometry3D mesh)
        {
            var texcoords = new PointCollection();

            foreach (var p in mesh.Positions)
            {
                double x = p.X + model.Offset.X;
                double y = p.Y + model.Offset.Y;
                double u = (x - Left) / (Right - Left);
                double v = (y - Top) / (Bottom - Top);
                texcoords.Add(new Point(u, v));
            }
            TextureCoordinates = texcoords;
        }
예제 #2
0
        public void LoadFromData(double[] elevations, int width, double left, double right, double top, double bottom)
        {
            var r = new TerrainModel();

            r.ElevationRate = ElevationRate;
            r.LoadFromData(elevations, width, left, right, top, bottom);
            switch (Texture)
            {
            case TextureType.Elevation:
                r.Texture = new ElevationTexture(Brush, 8);
                break;

            case TextureType.Slope:
                r.Texture = new SlopeTexture(Brush, 8);
                break;
            }
            visualChild.Content = r.CreateModel(2);
        }
예제 #3
0
        public override void Calculate(TerrainModel model, MeshGeometry3D mesh)
        {
            var normals   = MeshGeometryHelper.CalculateNormals(mesh);
            var texcoords = new PointCollection();

            for (int i = 0; i < normals.Count; i++)
            {
                double slopedir = Math.Atan2(normals[i].Y, normals[i].X) * 180 / Math.PI;
                if (slopedir < 0)
                {
                    slopedir += 360;
                }
                double u = slopedir / 360;
                texcoords.Add(new Point(u, u));
            }
            TextureCoordinates = texcoords;
            Material           = MaterialHelper.CreateMaterial(Brush);
        }
예제 #4
0
        public void UpdateModel()
        {
            var r = new TerrainModel();

            r.ElevationRate = ElevationRate;
            r.Load(Source);
            switch (Texture)
            {
            case TextureType.Elevation:
                r.Texture = new ElevationTexture(Brush, 8);

                break;

            case TextureType.Slope:
                r.Texture = new SlopeTexture(Brush, 8);
                break;
            }

            visualChild.Content = r.CreateModel(2);
        }
예제 #5
0
        public override void Calculate(TerrainModel model, MeshGeometry3D mesh)
        {
            var normals   = MeshGeometryHelper.CalculateNormals(mesh);
            var texcoords = new PointCollection();
            var up        = new Vector3D(0, 0, 1);

            for (int i = 0; i < normals.Count; i++)
            {
                double slope = Math.Acos(Vector3D.DotProduct(normals[i], up)) * 180 / Math.PI;
                double u     = slope / 40;
                if (u > 1)
                {
                    u = 1;
                }
                if (u < 0)
                {
                    u = 0;
                }
                texcoords.Add(new Point(u, u));
            }
            TextureCoordinates = texcoords;
            Material           = MaterialHelper.CreateMaterial(Brush);
        }
예제 #6
0
 public virtual void Calculate(TerrainModel model, MeshGeometry3D mesh)
 {
 }