예제 #1
0
        /// <summary>
        /// Updates the model.
        /// </summary>
        private void UpdateModel()
        {
            //var r = new TerrainModel();
            oTerrainModel = new TerrainModel();
            oTerrainModel.Load(this.Source);

            //r.Texture = new SlopeDirectionTexture(0);
            //r.Texture = new SlopeTexture(8);
            if (this.Source.Image == null)
            {
                SlopeTexture oTexture = new SlopeTexture(10);
                oTexture.Brush         = new SolidColorBrush(Colors.Gray);
                oTexture.Brush.Opacity = this.Source.Opacity;
                oTexture.Brush.Freeze();
                oTerrainModel.Texture = oTexture;
            }
            else
            {
                oTerrainModel.Texture = new MapTexture(this.Source.Image, this.Source.Opacity)
                {
                    Left = oTerrainModel.Left, Right = oTerrainModel.Right, Top = oTerrainModel.Top, Bottom = oTerrainModel.Bottom
                };
            }
            this.visualChild.Content = oTerrainModel.CreateModel(this.Source.Lod);
        }
예제 #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>
        /// 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;
        }
예제 #4
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 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);
        }
예제 #5
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)
 {
 }