示例#1
0
        public override void Update(Microsoft.MapPoint.Rendering3D.Scene.SceneState sceneState)
        {
            if (needUpdate && newSegment != null)
            {
                CameraData data;
                if (sceneState.TryGetData <CameraData>(out data))
                {
                    double altitude = data.MetersAboveGround / 100.0;

                    List <Vertex.PositionColored> vertices = new List <Vertex.PositionColored>();

                    LatLonAlt position = LatLonAlt.CreateUsingDegrees(newSegment.StartPoint.Y, newSegment.StartPoint.X, altitude);
                    Vector3F  vec      = new Vector3F(position.GetVector());
                    vertices.Add(new Vertex.PositionColored(vec, lineColor.ToArgb()));

                    foreach (System.Windows.Point point in newSegment.OtherPoints)
                    {
                        position = LatLonAlt.CreateUsingDegrees(point.Y, point.X, altitude);
                        vec      = new Vector3F(position.GetVector());
                        vertices.Add(new Vertex.PositionColored(vec, lineColor.ToArgb()));
                    }

                    mesh = new MeshGraphicsObject <Vertex.PositionColored, ushort>(
                        GraphicsBufferUsage.Static,
                        GraphicsBufferUsage.Static,
                        vertices.Count,
                        vertices.Count,
                        true);

                    Material material = new Material {
                        AmbientColor = Color.White, DiffuseColor = Color.White, SpecularColor = Color.White
                    };
                    int id = mesh.Materials.Add(material);

                    mesh.Vertices.AddData(vertices.ToArray());

                    List <ushort> indexData = new List <ushort>();
                    for (int i = 0; i < newSegment.OtherPoints.Count + 1; i++)
                    {
                        indexData.Add((ushort)i);
                    }

                    mesh.Indices.AddData(indexData.ToArray(),
                                         PrimitiveType.LineStrip,
                                         id);

                    mesh.RenderState.Lighting.Enabled = false;
                    mesh.RenderState.Cull.Enabled     = false;

                    oldSegment = newSegment;
                    needUpdate = false;
                    host.NeedUpdate();
                }
            }

            base.Update(sceneState);
        }
        public override void Update(Microsoft.MapPoint.Rendering3D.Scene.SceneState sceneState)
        {
            if (needUpdate && newSegment != null)
            {
                CameraData data;
                if (sceneState.TryGetData<CameraData>(out data))
                {
                    double altitude = data.MetersAboveGround / 100.0;

                    List<Vertex.PositionColored> vertices = new List<Vertex.PositionColored>();

                    LatLonAlt position = LatLonAlt.CreateUsingDegrees(newSegment.StartPoint.Y, newSegment.StartPoint.X, altitude);
                    Vector3F vec = new Vector3F(position.GetVector());
                    vertices.Add(new Vertex.PositionColored(vec, lineColor.ToArgb()));

                    foreach (System.Windows.Point point in newSegment.OtherPoints)
                    {
                        position = LatLonAlt.CreateUsingDegrees(point.Y, point.X, altitude);
                        vec = new Vector3F(position.GetVector());
                        vertices.Add(new Vertex.PositionColored(vec, lineColor.ToArgb()));
                    }

                    mesh = new MeshGraphicsObject<Vertex.PositionColored, ushort>(
                        GraphicsBufferUsage.Static,
                        GraphicsBufferUsage.Static,
                        vertices.Count,
                        vertices.Count,
                        true);

                    Material material = new Material { AmbientColor = Color.White, DiffuseColor = Color.White, SpecularColor = Color.White };
                    int id = mesh.Materials.Add(material);

                    mesh.Vertices.AddData(vertices.ToArray());

                    List<ushort> indexData = new List<ushort>();
                    for (int i = 0; i < newSegment.OtherPoints.Count + 1; i++)
                    {
                        indexData.Add((ushort)i);
                    }

                    mesh.Indices.AddData(indexData.ToArray(),
                        PrimitiveType.LineStrip,
                        id);

                    mesh.RenderState.Lighting.Enabled = false;
                    mesh.RenderState.Cull.Enabled = false;

                    oldSegment = newSegment;
                    needUpdate = false;
                    host.NeedUpdate();
                }
            }

            base.Update(sceneState);
        }
示例#3
0
        private void AddDataSource(PointSet pointSet, Guid guid)
        {
            double altitude = host.Navigation.CameraPosition.Altitude / 20.0;

            step = 0.3;

            List <Vertex.PositionColored> vertices = BuildVertices(pointSet, altitude);

            MeshGraphicsObject <Vertex.PositionColored, ushort> mesh = new MeshGraphicsObject <Vertex.PositionColored, ushort>(
                GraphicsBufferUsage.Static,
                GraphicsBufferUsage.Static,
                vertices.Count,
                vertices.Count,
                true);

            Material material = new Material {
                AmbientColor = Color.White, DiffuseColor = Color.White, SpecularColor = Color.White
            };
            int id = mesh.Materials.Add(material);

            mesh.Vertices.AddData(vertices.ToArray());

            List <ushort> indexData = new List <ushort>();

            for (int i = 0; i < pointSet.Data.Count; i++)
            {
                indexData.Add((ushort)(i * 4));
                indexData.Add((ushort)(i * 4 + 1));
                indexData.Add((ushort)(i * 4 + 2));
                indexData.Add((ushort)(i * 4 + 3));
            }

            mesh.Indices.AddData(indexData.ToArray(),
                                 PrimitiveType.LineList,
                                 id);

            mesh.RenderState.Lighting.Enabled = false;
            mesh.RenderState.Cull.Enabled     = false;

            pointSet.Guid = guid;
            meshLayers.Add(new MeshLayer {
                LayerAltitude = altitude, Mesh = mesh, Guid = guid, IsVisible = true, ScalarField = pointSet, Step = step
            });
        }
示例#4
0
        private void AddDataSource(IDataSource2D <double> field, Guid guid)
        {
            double minT, maxT;

            //if (colorMapControl.PaletteType == PaletteType.FromMaxMin)
            //{
            //    minT = colorMapControl.MinValue;
            //    maxT = colorMapControl.MaxValue;
            //}
            //else
            //{
            MathHelper.GetMaxMin(field.Data, out maxT, out minT);

            //colorMapControl.MinValue = minT;
            //colorMapControl.MaxValue = maxT;
            //}

            double k = 1.0 / (maxT - minT);

            List <Vertex.PositionColored> vertices = new List <Vertex.PositionColored>();

            double altitude = layerHelper.GetNewAltitude();

            for (int i = 0; i < field.Width; i++)
            {
                for (int j = 0; j < field.Height; j++)
                {
                    float     x        = (float)field.Grid[i, j].X;
                    float     y        = (float)field.Grid[i, j].Y;
                    LatLonAlt position = LatLonAlt.CreateUsingDegrees(y, x, altitude);
                    Vector3F  vec      = new Vector3F(position.GetVector());
                    System.Windows.Media.Color color = palette.GetColor((field.Data[i, j] - minT) * k);
                    vertices.Add(new Vertex.PositionColored(vec, Color.FromArgb(opacity, color.R, color.G, color.B).ToArgb()));
                }
            }

            MeshGraphicsObject <Vertex.PositionColored, ushort> mesh = new MeshGraphicsObject <Vertex.PositionColored, ushort>(
                GraphicsBufferUsage.Static,
                GraphicsBufferUsage.Static,
                vertices.Count,
                vertices.Count * 6,
                true);

            Material material = new Material {
                AmbientColor = Color.White, DiffuseColor = Color.White, SpecularColor = Color.White
            };
            int id = mesh.Materials.Add(material);

            mesh.Vertices.AddData(vertices.ToArray());

            for (int i = 0; i < field.Width - 1; i++)
            {
                for (int j = 0; j < field.Height - 1; j++)
                {
                    mesh.Indices.AddData(

                        (ushort)(i * field.Height + j),
                        (ushort)(i * field.Height + j + 1),

                        (ushort)((i + 1) * field.Height + j),

                        PrimitiveType.TriangleList, id);

                    mesh.Indices.AddData(
                        (ushort)(i * field.Height + j + 1),
                        (ushort)((i + 1) * field.Height + j + 1),
                        (ushort)((i + 1) * field.Height + j),

                        PrimitiveType.TriangleList, id);
                }
            }


            mesh.RenderState.Lighting.Enabled       = false;
            mesh.RenderState.Alpha.Enabled          = true;
            mesh.RenderState.Alpha.AlphaTestEnable  = true;
            mesh.RenderState.Alpha.SourceBlend      = Blend.BothInvSourceAlpha;
            mesh.RenderState.Alpha.DestinationBlend = Blend.BothInvSourceAlpha;
            mesh.RenderState.Cull.Enabled           = false;

            meshLayers.Add(new MeshLayer {
                LayerAltitude = altitude, Mesh = mesh, Guid = guid, IsVisible = true, ScalarField = field
            });
        }
示例#5
0
        private void AddDataSource(IDataSource2D<double> field, Guid guid)
        {
            double minT, maxT;

            //if (colorMapControl.PaletteType == PaletteType.FromMaxMin)
            //{
            //    minT = colorMapControl.MinValue;
            //    maxT = colorMapControl.MaxValue;
            //}
            //else
            //{
            MathHelper.GetMaxMin(field.Data, out maxT, out minT);

            //colorMapControl.MinValue = minT;
            //colorMapControl.MaxValue = maxT;
            //}

            double k = 1.0 / (maxT - minT);

            List<Vertex.PositionColored> vertices = new List<Vertex.PositionColored>();

            double altitude = layerHelper.GetNewAltitude();

            for (int i = 0; i < field.Width; i++)
            {
                for (int j = 0; j < field.Height; j++)
                {
                    float x = (float)field.Grid[i, j].X;
                    float y = (float)field.Grid[i, j].Y;
                    LatLonAlt position = LatLonAlt.CreateUsingDegrees(y, x, altitude);
                    Vector3F vec = new Vector3F(position.GetVector());
                    System.Windows.Media.Color color = palette.GetColor((field.Data[i, j] - minT) * k);
                    vertices.Add(new Vertex.PositionColored(vec, Color.FromArgb(opacity, color.R, color.G, color.B).ToArgb()));
                }
            }

            MeshGraphicsObject<Vertex.PositionColored, ushort> mesh = new MeshGraphicsObject<Vertex.PositionColored, ushort>(
                GraphicsBufferUsage.Static,
                GraphicsBufferUsage.Static,
                vertices.Count,
                vertices.Count * 6,
                true);

            Material material = new Material { AmbientColor = Color.White, DiffuseColor = Color.White, SpecularColor = Color.White };
            int id = mesh.Materials.Add(material);

            mesh.Vertices.AddData(vertices.ToArray());

            for (int i = 0; i < field.Width - 1; i++)
            {
                for (int j = 0; j < field.Height - 1; j++)
                {

                    mesh.Indices.AddData(

                        (ushort)(i * field.Height + j),
                        (ushort)(i * field.Height + j + 1),

                        (ushort)((i + 1) * field.Height + j),

                        PrimitiveType.TriangleList, id);

                    mesh.Indices.AddData(
                        (ushort)(i * field.Height + j + 1),
                        (ushort)((i + 1) * field.Height + j + 1),
                        (ushort)((i + 1) * field.Height + j),

                        PrimitiveType.TriangleList, id);
                }
            }


            mesh.RenderState.Lighting.Enabled = false;
            mesh.RenderState.Alpha.Enabled = true;
            mesh.RenderState.Alpha.AlphaTestEnable = true;
            mesh.RenderState.Alpha.SourceBlend = Blend.BothInvSourceAlpha;
            mesh.RenderState.Alpha.DestinationBlend = Blend.BothInvSourceAlpha;
            mesh.RenderState.Cull.Enabled = false;

            meshLayers.Add(new MeshLayer { LayerAltitude = altitude, Mesh = mesh, Guid = guid, IsVisible = true, ScalarField = field });

        }
示例#6
0
        private void AddDataSource(IDataSource2D<double> field, Guid guid)
        {
            // Get data and min/max.
            double[,] data = field.Data;
            double minT, maxT;
            MathHelper.GetMaxMin(data, out maxT, out minT);


            double k = 1.0 / (maxT - minT);


            double altitude = layerAltitude;

            //TODO: Perform right calculation depending on grid
            step = 0.3;

            List<Vertex.PositionColored> vertices = new List<Vertex.PositionColored>();
            for (int i = 0; i < field.Width; i++)
            {
                for (int j = 0; j < field.Height; j++)
                {
                    float x = (float)field.Grid[i, j].X;
                    float y = (float)field.Grid[i, j].Y;
                    LatLonAlt position = LatLonAlt.CreateUsingDegrees(y + step, x + step, altitude);
                    Vector3F vec = new Vector3F(position.GetVector());
                    vertices.Add(new Vertex.PositionColored(vec, Color.Red.ToArgb()));

                    position = LatLonAlt.CreateUsingDegrees(y - step, x - step, altitude);
                    vec = new Vector3F(position.GetVector());
                    vertices.Add(new Vertex.PositionColored(vec, Color.Red.ToArgb()));

                    position = LatLonAlt.CreateUsingDegrees(y + step, x - step, altitude);
                    vec = new Vector3F(position.GetVector());
                    vertices.Add(new Vertex.PositionColored(vec, Color.Red.ToArgb()));

                    position = LatLonAlt.CreateUsingDegrees(y - step, x + step, altitude);
                    vec = new Vector3F(position.GetVector());
                    vertices.Add(new Vertex.PositionColored(vec, Color.Red.ToArgb()));

                }
            }



            MeshGraphicsObject<Vertex.PositionColored, ushort> mesh = new MeshGraphicsObject<Vertex.PositionColored, ushort>(
                GraphicsBufferUsage.Static,
                GraphicsBufferUsage.Static,
                vertices.Count,
                vertices.Count,
                true);

            Material material = new Material { AmbientColor = Color.White, DiffuseColor = Color.White, SpecularColor = Color.White };
            int id = mesh.Materials.Add(material);

            mesh.Vertices.AddData(vertices.ToArray());

            List<ushort> indexData = new List<ushort>();
            for (int i = 0; i < field.Width; i++)
            {
                for (int j = 0; j < field.Height; j++)
                {

                    indexData.Add((ushort)((i * field.Height + j) * 4));
                    indexData.Add((ushort)((i * field.Height + j) * 4 + 1));
                    indexData.Add((ushort)((i * field.Height + j) * 4 + 2));
                    indexData.Add((ushort)((i * field.Height + j) * 4 + 3));



                }
            }

            mesh.Indices.AddData(indexData.ToArray(),
                        PrimitiveType.LineList,
                        id);

            mesh.RenderState.Lighting.Enabled = false;
            mesh.RenderState.Cull.Enabled = false;

            meshLayers.Add(new MeshLayer { LayerAltitude = altitude, Mesh = mesh, Guid = guid, IsVisible = true, ScalarField = field, Step = step });
        }
示例#7
0
        private void AddDataSource(PointSet pointSet, Guid guid)
        {
            double altitude = host.Navigation.CameraPosition.Altitude / 20.0;
            step = 0.3;

            List<Vertex.PositionColored> vertices = BuildVertices(pointSet, altitude);

            MeshGraphicsObject<Vertex.PositionColored, ushort> mesh = new MeshGraphicsObject<Vertex.PositionColored, ushort>(
                GraphicsBufferUsage.Static,
                GraphicsBufferUsage.Static,
                vertices.Count,
                vertices.Count,
                true);

            Material material = new Material { AmbientColor = Color.White, DiffuseColor = Color.White, SpecularColor = Color.White };
            int id = mesh.Materials.Add(material);

            mesh.Vertices.AddData(vertices.ToArray());

            List<ushort> indexData = new List<ushort>();
            for (int i = 0; i < pointSet.Data.Count; i++)
            {
                indexData.Add((ushort)(i * 4));
                indexData.Add((ushort)(i * 4 + 1));
                indexData.Add((ushort)(i * 4 + 2));
                indexData.Add((ushort)(i * 4 + 3));
            }

            mesh.Indices.AddData(indexData.ToArray(),
                        PrimitiveType.LineList,
                        id);

            mesh.RenderState.Lighting.Enabled = false;
            mesh.RenderState.Cull.Enabled = false;

            pointSet.Guid = guid;
            meshLayers.Add(new MeshLayer { LayerAltitude = altitude, Mesh = mesh, Guid = guid, IsVisible = true, ScalarField = pointSet, Step = step });
        }
示例#8
0
        private void AddDataSource(IDataSource2D <double> field, Guid guid)
        {
            // Get data and min/max.
            double[,] data = field.Data;
            double minT, maxT;

            MathHelper.GetMaxMin(data, out maxT, out minT);


            double k = 1.0 / (maxT - minT);


            double altitude = layerAltitude;

            //TODO: Perform right calculation depending on grid
            step = 0.3;

            List <Vertex.PositionColored> vertices = new List <Vertex.PositionColored>();

            for (int i = 0; i < field.Width; i++)
            {
                for (int j = 0; j < field.Height; j++)
                {
                    float     x        = (float)field.Grid[i, j].X;
                    float     y        = (float)field.Grid[i, j].Y;
                    LatLonAlt position = LatLonAlt.CreateUsingDegrees(y + step, x + step, altitude);
                    Vector3F  vec      = new Vector3F(position.GetVector());
                    vertices.Add(new Vertex.PositionColored(vec, Color.Red.ToArgb()));

                    position = LatLonAlt.CreateUsingDegrees(y - step, x - step, altitude);
                    vec      = new Vector3F(position.GetVector());
                    vertices.Add(new Vertex.PositionColored(vec, Color.Red.ToArgb()));

                    position = LatLonAlt.CreateUsingDegrees(y + step, x - step, altitude);
                    vec      = new Vector3F(position.GetVector());
                    vertices.Add(new Vertex.PositionColored(vec, Color.Red.ToArgb()));

                    position = LatLonAlt.CreateUsingDegrees(y - step, x + step, altitude);
                    vec      = new Vector3F(position.GetVector());
                    vertices.Add(new Vertex.PositionColored(vec, Color.Red.ToArgb()));
                }
            }



            MeshGraphicsObject <Vertex.PositionColored, ushort> mesh = new MeshGraphicsObject <Vertex.PositionColored, ushort>(
                GraphicsBufferUsage.Static,
                GraphicsBufferUsage.Static,
                vertices.Count,
                vertices.Count,
                true);

            Material material = new Material {
                AmbientColor = Color.White, DiffuseColor = Color.White, SpecularColor = Color.White
            };
            int id = mesh.Materials.Add(material);

            mesh.Vertices.AddData(vertices.ToArray());

            List <ushort> indexData = new List <ushort>();

            for (int i = 0; i < field.Width; i++)
            {
                for (int j = 0; j < field.Height; j++)
                {
                    indexData.Add((ushort)((i * field.Height + j) * 4));
                    indexData.Add((ushort)((i * field.Height + j) * 4 + 1));
                    indexData.Add((ushort)((i * field.Height + j) * 4 + 2));
                    indexData.Add((ushort)((i * field.Height + j) * 4 + 3));
                }
            }

            mesh.Indices.AddData(indexData.ToArray(),
                                 PrimitiveType.LineList,
                                 id);

            mesh.RenderState.Lighting.Enabled = false;
            mesh.RenderState.Cull.Enabled     = false;

            meshLayers.Add(new MeshLayer {
                LayerAltitude = altitude, Mesh = mesh, Guid = guid, IsVisible = true, ScalarField = field, Step = step
            });
        }