已打开一个场景,想向场景中添加一个构造好的geobox对象,无法实现。代码如下,哪位大神看看毛病出在哪?
private void button1_Click(object sender, EventArgs e)
{
AddGeoBox();
}
public void AddGeoBox()
{
// 构造 GeoBox 对象
GeoBox geoBox = new GeoBox();
// 设置长方体的底面大小
geoBox.BottomSize = new Size2D(200, 100);
// 设置长方体的高度
geoBox.Height = 200;
// 设置长方体所在的位置
geoBox.Position = new Point3D(116.3871597841252, 39.99008027631623, 100);
// 获取按 GeoModel 的方式重新构建的模型对象
GeoModel geoModel = geoBox.GetGeoModel(100, 100);
// 向跟踪图层上添加长方体
m_sceneControl.Scene.TrackingLayer.Add(geoModel, "GeoBox");
// 飞行定位到该长方体对象
//m_sceneControl.Scene.Fly(geoModel, FlyingMode.FlyingTo);
FlyToTarget();
}
public void FlyToTarget()
{
#region 创建相机
Camera camera = new Camera();
camera.Latitude = 115.5000232195;
camera.Longitude = 39.49997640163;
camera.Altitude = 3.25;
camera.AltitudeMode = AltitudeMode.ClampToGround;
camera.Heading = 34.847028793470777;
camera.Tilt = 76.822802220392148;
#endregion
m_sceneControl.Scene.Fly(camera, 10);
m_sceneControl.Scene.Refresh();
}