zoukankan      html  css  js  c++  java
  • [WorldWind学习]20.修改ShapeFileLayer类及托管D3D文字绘制方法

    PluginSDKShapeFileLayer.cs Line:1027
    char[] fieldDataChars = dbfReader.ReadChars(fieldHeaders[j].FieldLength);
    string fieldData = new string( fieldDataChars );

    byte[] fieldDataChars = dbfReader.ReadBytes(fieldHeaders[j].FieldLength);
    string fieldData = System.Text.Encoding.Default.GetString( fieldDataChars );

     

     1 if(m_LabelList.Count > 0)
     2 {
     3     System.Drawing.Color iconColor = System.Drawing.Color.FromArgb(m_IconOpacity, 255, 255, 255);
     4     foreach(Shapefile_Point p in m_LabelList)
     5     {
     6         Vector3 cartesianPoint = MathEngine.SphericalToCartesian(p.Y, p.X, drawArgs.WorldCamera.WorldRadius + drawArgs.WorldCamera.TerrainElevation);
     7         if(!drawArgs.WorldCamera.ViewFrustum.ContainsPoint(cartesianPoint) ||MathEngine.SphericalDistanceDegrees(p.Y, p.X, drawArgs.WorldCamera.Latitude.Degrees, drawArgs.WorldCamera.Longitude.Degrees) > 90.0)
     8         continue;
     9         Vector3 projectedPoint = drawArgs.WorldCamera.Project(cartesianPoint - referenceCenter);
    10         
    11         m_Sprite.Begin(SpriteFlags.AlphaBlend);
    12         if(m_IconTexture != null)
    13         {
    14             float xscale = (float)m_IconWidth / m_IconTextureDescription.Width;
    15             float yscale = (float)m_IconHeight / m_IconTextureDescription.Height;
    16             m_Sprite.Transform = Matrix.Scaling(xscale,yscale,0);
    17             m_Sprite.Transform *= Matrix.Translation(projectedPoint.X, projectedPoint.Y, 0);
    18             m_Sprite.Draw( m_IconTexture,
    19                 new Vector3( m_IconWidth>>1, m_IconHeight>>1,0),
    20                 Vector3.Empty,
    21                 iconColor.ToArgb() );
    22 
    23             // Reset transform to prepare for text rendering later
    24             m_Sprite.Transform = Matrix.Identity;
    25         }
    26 
    27         if(m_ShapeTileArgs.ShowLabels && m_ShapeTileArgs.DataKey != null)
    28         {    
    29             // Render label
    30             if(p.Tag != null)
    31             {
    32                 // Render name field
    33                 const int labelWidth = 1000; // Dummy value needed for centering the text
    34                 if(m_IconTexture==null)
    35                 {
    36                     // Center over target as we have no bitmap
    37                     Rectangle rect = new Rectangle(
    38                         (int)projectedPoint.X - (labelWidth>>1), 
    39                         (int)(projectedPoint.Y - (drawArgs.defaultDrawingFont.Description.Height >> 1)),
    40                         labelWidth, 
    41                         drawArgs.screenHeight );
    42 
    43                     drawArgs.defaultDrawingFont.DrawText(m_Sprite, p.Tag.ToString(), rect, DrawTextFormat.Center, m_ShapeTileArgs.LabelColor);
    44                 }
    45                 else
    46                 {
    47                     // Adjust text to make room for icon
    48                     int spacing = (int)(m_IconWidth * 0.3f);
    49                     if(spacing>10)
    50                         spacing = 10;
    51                     int offsetForIcon = (m_IconWidth>>1) + spacing;
    52 
    53                     Rectangle rect = new Rectangle(
    54                         (int)projectedPoint.X + offsetForIcon, 
    55                         (int)(projectedPoint.Y - (drawArgs.defaultDrawingFont.Description.Height >> 1)),
    56                         labelWidth, 
    57                         drawArgs.screenHeight );
    58 
    59                     drawArgs.defaultDrawingFont.DrawText(m_Sprite, p.Tag.ToString(), rect, DrawTextFormat.WordBreak, m_ShapeTileArgs.LabelColor);
    60                 }
    61             }
    62         }        
    63         m_Sprite.End();
    64     }
    65 }

    有一个文字3D世界坐标点投影到屏幕的过程,在屏幕绘制。

  • 相关阅读:
    1360 奇怪的电梯(lift)
    1249 Lake Counting
    1330 【例8.3】最少步数
    1329 【例8.2】细胞
    1215 迷宫
    垃圾树
    vector
    1970:【15NOIP普及组】扫雷游戏
    1251:仙岛求药
    Python3+PCAN-USB基于PCAN-Basic二次开发实现上位机功能
  • 原文地址:https://www.cnblogs.com/yhlx125/p/3377460.html
Copyright © 2011-2022 走看看