예제 #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);
        }
예제 #2
0
        public override void Update(Microsoft.MapPoint.Rendering3D.Scene.SceneState sceneState)
        {
            if (meshLayers.Count != 0)
            {
                CameraData data;
                if (sceneState.TryGetData<CameraData>(out data))
                {
                    double altitude = data.MetersAboveGround / 100.0;
                    bool needUpdate = false;
                    foreach (MeshLayer meshLayer in meshLayers)
                    {
                        if (meshLayer.LayerAltitude != altitude)
                        {
                            needUpdate = true;
                            if (meshLayer.ScalarField is PointSet)
                            {
                                PointSet pointSet = meshLayer.ScalarField as PointSet;
                                meshLayer.Mesh.Vertices.Clear();
                                meshLayer.Mesh.Vertices.AddData(BuildVertices(pointSet, altitude).ToArray());
                                meshLayer.LayerAltitude = altitude;
                                continue;
                            }
                        }
                    }
                    if (needUpdate)
                        host.NeedUpdate();
                    /*
                    if (mlayer != null && mlayer.LayerAltitude!=altitude)
                    {
                        
                    }*/


                }
            }


            base.Update(sceneState);
        }
예제 #3
0
 public override void Render(Microsoft.MapPoint.Rendering3D.Scene.SceneState sceneState)
 {
     if (meshLayers.Count != 0)
     {
         CameraData data;
         if (sceneState.TryGetData<CameraData>(out data))
         {
             RenderQueues renderQueues = sceneState.GetData<RenderQueues>();
             lock (meshLayers)
             {
                 for (int i = 0; i < meshLayers.Count; i++)
                 {
                     if (meshLayers[i].IsVisible)
                     {
                         renderQueues.AddAlphaRenderable(data.Snapshot.Position.Altitude - meshLayers[i].LayerAltitude, meshLayers[i].Mesh);
                     }
                 }
             }
         }
     }
 }
예제 #4
0
 public override void Render(Microsoft.MapPoint.Rendering3D.Scene.SceneState sceneState)
 {
     if (meshLayers.Count != 0)
     {
         CameraData data;
         if (sceneState.TryGetData<CameraData>(out data))
         {
             RenderQueues renderQueues = sceneState.GetData<RenderQueues>();
             foreach (MeshLayer meshLayer in meshLayers)
             {
                 if (meshLayer.IsVisible)
                 {
                     renderQueues.AddRenderable(meshLayer.Mesh);
                 }
             }
         }
     }
 }