Пример #1
0
        /// <summary>
        /// Calculates the texture for the specified model.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="mesh">
        /// The mesh.
        /// </param>
        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));
            }

            this.TextureCoordinates = texcoords;
            this.Material = MaterialHelper.CreateMaterial(this.Brush);
        }
Пример #2
0
        /// <summary>
        /// Calculates the texture for the specified model.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="mesh">
        /// The mesh.
        /// </param>
        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));
            }

            this.TextureCoordinates = texcoords;
            this.Material           = MaterialHelper.CreateMaterial(this.Brush);
        }
Пример #3
0
        /// <summary>
        /// Updates the model.
        /// </summary>
        private void UpdateModel()
        {
            var r = new TerrainModel();
            r.Load(this.Source);

            // r.Texture = new SlopeDirectionTexture(0);
            r.Texture = new SlopeTexture(8);

            // r.Texture = new MapTexture(@"D:\tmp\CraterLake.png") { Left = r.Left, Right = r.Right, Top = r.Top, Bottom = r.Bottom };
            this.visualChild.Content = r.CreateModel(2);
        }
Пример #4
0
        /// <summary>
        /// Updates the model.
        /// </summary>
        private void UpdateModel()
        {
            var r = new TerrainModel();

            r.Load(this.Source);

            // r.Texture = new SlopeDirectionTexture(0);
            r.Texture = new SlopeTexture(8);

            // r.Texture = new MapTexture(@"D:\tmp\CraterLake.png") { Left = r.Left, Right = r.Right, Top = r.Top, Bottom = r.Bottom };
            this.visualChild.Content = r.CreateModel(2);
        }
Пример #5
0
        /// <summary>
        /// Calculates the texture of the specified model.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="mesh">
        /// The mesh.
        /// </param>
        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 - this.Left) / (this.Right - this.Left);
                double v = (y - this.Top) / (this.Bottom - this.Top);
                texcoords.Add(new Point(u, v));
            }

            this.TextureCoordinates = texcoords;
        }
Пример #6
0
        /// <summary>
        /// Calculates the texture of the specified model.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="mesh">
        /// The mesh.
        /// </param>
        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 - this.Left) / (this.Right - this.Left);
                double v = (y - this.Top) / (this.Bottom - this.Top);
                texcoords.Add(new Point(u, v));
            }

            this.TextureCoordinates = texcoords;
        }
        /// <summary>
        /// Calculates the texture of the specified model.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="mesh">
        /// The mesh.
        /// </param>
        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));
            }

            this.TextureCoordinates = texcoords;
            this.Material = MaterialHelper.CreateMaterial(this.Brush);
        }
        /// <summary>
        /// Calculates the texture of the specified model.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="mesh">
        /// The mesh.
        /// </param>
        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));
            }

            this.TextureCoordinates = texcoords;
            this.Material           = MaterialHelper.CreateMaterial(this.Brush);
        }
Пример #9
0
 /// <summary>
 /// Calculates the texture of the specified model.
 /// </summary>
 /// <param name="model">
 /// The model.
 /// </param>
 /// <param name="mesh">
 /// The mesh.
 /// </param>
 public virtual void Calculate(TerrainModel model, MeshGeometry3D mesh)
 {
 }
Пример #10
0
 /// <summary>
 /// Calculates the texture of the specified model.
 /// </summary>
 /// <param name="model">
 /// The model.
 /// </param>
 /// <param name="mesh">
 /// The mesh.
 /// </param>
 public virtual void Calculate(TerrainModel model, MeshGeometry3D mesh)
 {
 }