可渲染对象是整个场景绘制的核心,包含大量类,其中以World类为顶层,它包含了场景中所有参与渲染的对象,如图像ImageLayer对象,瓦片集QuadTileSet对象等。 所有渲染类关系图:
1、RenderableObject类
RenderableObject类是所有可渲染对象的基类,它代表场景中一个可以绘制的对象,是一个虚类,不能实例化。主要属性包括,初始化标志,是否可以选中,名字、描述、位置、图层图标、父节点、地球对象、渲染优先级(渲染顺序)等。
/// <summary>
/// True when object is ready to be rendered.
/// </summary>
public bool isInitialized;
/// <summary>
/// True for objects the user can interact with.
/// </summary>
public bool isSelectable;
public RenderableObjectList ParentList; //父节点
public string dbfPath = "";
public bool dbfIsInZip = false;
protected string name;
protected string m_description = null;
protected Hashtable _metaData = new Hashtable();
protected Vector3 position; //位置
protected Quaternion orientation; //旋转量
protected bool isOn = true;
protected byte m_opacity = 255;
protected RenderPriority m_renderPriority = RenderPriority.SurfaceImages;
protected Form m_propertyBrowser;
protected Image m_thumbnailImage;
protected string m_iconImagePath;
protected Image m_iconImage;
protected World m_world;
string m_thumbnail;
主要函数:
纯虚函数
public abstract void Initialize(DrawArgs drawArgs); //初始化
public abstract void Update(DrawArgs drawArgs); //更新状态
public abstract void Render(DrawArgs drawArgs); //渲染
/// <summary>
/// Called when object is disabled.
/// </summary>
public abstract void Dispose();
/// <summary>
/// User interaction (mouse click)
/// </summary>
public abstract bool PerformSelectionAction(DrawArgs drawArgs); //响应用户的选中操作
1、public virtual void Delete() 从父节点将该图层删除,如果是插件图层,则显示警告信息。
2、public virtual void BuildContextMenu(ContextMenu menu) 创建图层对应的右键菜单。
2、RenderableObjectList类
RenderableObjectList类是一个可渲染对象列表类,自身也是RenderableObject类的子类。每个RendrableObject类都含有一个指向RenderableObjectList 类的对象,是他的父节点。
protected ArrayList m_children = new ArrayList(); //子节点链表
string m_DataSource = null;
TimeSpan m_RefreshInterval = TimeSpan.MaxValue;
World m_ParentWorld = null;
Cache m_Cache = null;
System.Timers.Timer m_RefreshTimer = null; //自动刷新计时器
public bool ShowOnlyOneLayer;
private bool m_disableExpansion = false;
public void StartRefreshTimer() 启动刷新定时器
public virtual RenderableObject GetObject(string name) 根据名字,从子节点获取对象。
public virtual bool Enable(string name) 根据名字,从子节点开启对象。
public virtual void TurnOffAllChildren() 关闭所有子节点
public virtual void Add(RenderableObject ro) 添加子节点
public virtual void Remove(string objectName) 根据名字删除子节点
public virtual void Remove(RenderableObject layer) 根据对象删除字节
public virtual void RemoveAll() 删除所有子节点
public virtual void SortChildren() 根据渲染优先级对子节点进行排序
private void m_RefreshTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) 刷新定时器操作
private void compareRefreshLists(RenderableObjectList newList, RenderableObjectList curList)
private void UpdateRenderable(RenderableObject oldRenderable, RenderableObject newRenderable)
public override void Initialize(DrawArgs drawArgs)对所有开启的子节点进行初始化操作。
public override void Update(DrawArgs drawArgs) 更新所有开启的子节点,如果没有初始化,则先进行初始化。
public override void Render(DrawArgs drawArgs) 对所有开启的子节点进行渲染操作。
public override bool PerformSelectionAction(DrawArgs drawArgs) 对所有可选中的子节点进行选中操作。
public override void Dispose() 销毁所有子节点对象。
3、World类
是一个球体类,也是可渲染对象,主要用于管理。自身不参与渲染。
主要属性:
double equatorialRadius;
// TODO: Add ellipsoid parameters to world.
const double flattening = 6378.135;
const double SemiMajorAxis = 6378137.0;
const double SemiMinorAxis = 6356752.31425;
TerrainAccessor _terrainAccessor;
RenderableObjectList _renderableObjects;
private System.Collections.IList onScreenMessages;
private DateTime lastElevationUpdate = System.DateTime.Now;
WorldSurfaceRenderer m_WorldSurfaceRenderer = null;
ProjectedVectorRenderer m_projectedVectorRenderer = null;
public AtmosphericScatteringSphere m_outerSphere = null;
int m_sunWidth = 72;
int m_sunHeight = 72;
Sprite m_sprite = null;
Texture m_sunTexture = null;
SurfaceDescription m_sunSurfaceDescription;
主要函数:
1、构造函数:
public World(string name, Vector3 position, Quaternion orientation,
double equatorialRadius, string cacheDirectory,
TerrainAccessor terrainAccessor) : base(name, position, orientation)
2、
private void setLayerOpacity(RenderableObject ro, string category, string name, float opacity)
3、
private static string getRenderablePathString(RenderableObject renderable)
4、加载地球配置
public static void LoadSettings()
public static void LoadSettings(string directory)
5、
private void DrawAxis(DrawArgs drawArgs)
private void RenderSun(DrawArgs drawArgs)
private void RenderStars(DrawArgs drawArgs, WorldWind.Renderable.RenderableObject renderable)
private void Render(WorldWind.Renderable.RenderableObject renderable, WorldWind.Renderable.RenderPriority priority, DrawArgs drawArgs)
private void saveRenderableState(RenderableObject ro)
private void saveRenderableStates(RenderableObjectList rol)
public static Angle ApproxAngularDistance(Angle latA, Angle lonA, Angle latB, Angle lonB)
public double ApproxDistance(Angle latA, Angle lonA, Angle latB, Angle lonB)
public static void IntermediateGCPoint(float f, Angle lat1, Angle lon1, Angle lat2, Angle lon2,
Angle d, out Angle lat, out Angle lon)
public Vector3 IntermediateGCPoint(float f, Angle lat1, Angle lon1, Angle lat2, Angle lon2, Angle d)
重载函数:
public override void Initialize(DrawArgs drawArgs)对所有开启的子节点进行初始化操作。
public override void Update(DrawArgs drawArgs) 更新所有开启的子节点,如果没有初始化,则先进行初始化。
public override void Render(DrawArgs drawArgs) 对所有开启的子节点进行渲染操作。
public override bool PerformSelectionAction(DrawArgs drawArgs) 对所有可选中的子节点进行选中操作。
public override void Dispose() 销毁所有子节点对象。
4、LatLongGrid 经纬网类
主要函数是 public override void Render(DrawArgs drawArgs),根据当前的视场,绘制地球的经纬网。首先,调用ComputeGridValues计算经纬网间隔,然后,计算各个顶点并绘制经纬网,最后调用RenderTropicLines绘制南北回归线和南极、北极圈。