使用产品:Idesktop 8c 810 操作系统:win10 x64
数据类型: 文件型
问题详细描述:我想在IDESKTOP中实现模型的正视/侧视/俯视/仰视. 如果基于绝对高度的摄像头,俯视还是能够做出来.但是正视仰视侧视会出现视角拉的很远的异常.
如下为我用贴地形的摄像头方式做的视角切换代码,目前不是很认可这种方案.需要切换成绝对高度的摄像头:
public void SetModelCenter(List<string> layerNameList, cameryview camview)
{
SetLayerVisiable(layerNameList);
cameraview = new Rectangle2D(0, 0, 0, 0);
int j = 0;
for (int k = 0; k < PublicValue.modelList.Count; k++)
{
for (int i = 0; i < layerNameList.Count; i++)
{
if (layerNameList[i] == PublicValue.modelList[k].sm_layer_name)
{
Layer3D layer3D = _sceneForm.SceneControl.Scene.Layers[PublicValue.modelList[k].sm_layer_name];
if (layer3D == null)
continue;
Rectangle2D modelview = layer3D.Bounds;
if (modelview == null)
continue;
if (j == 0)
{
cameraview = modelview;
}
else
{
cameraview.Union(modelview);
}
j++;
}
}
}
if (j == 0)
{
return;
}
camera = _sceneForm.SceneControl.Scene.Camera;
camera.AltitudeMode = AltitudeMode.RelativeToGround;
//camera.AltitudeMode = AltitudeMode.Absolute;
camera.Latitude = cameraview.Center.Y;
camera.Longitude = cameraview.Center.X;
switch (camview)
{
case cameryview.FRONT:
{
camera.Tilt = 90;
camera.Altitude = 0.01;
camera.Heading = 0;
break;
}
case cameryview.SIDE:
{
camera.Tilt = 90;
camera.Altitude = 0.02;
camera.Heading = 90;
break;
}
case cameryview.UPWARD:
{
camera.Tilt = 90;
camera.Altitude = 0;
camera.Heading = 90;
break;
}
case cameryview.VERTICAL:
{
double leftlong = (100000 * System.Math.Abs(cameraview.Right - cameraview.Left));
double toplong = (100000 * System.Math.Abs(cameraview.Top - cameraview.Bottom));
double totallong = 0;
if (leftlong >= toplong)
{
totallong = leftlong;
}
else
{
totallong = leftlong;
}
// camera.Altitude = totallong;
camera.Altitude = totallong+1000;
camera.Heading = 0;
camera.Tilt = 0;
break;
}
}
_sceneForm.SceneControl.Scene.Fly(camera, 2000);
camera.AltitudeMode = AltitudeMode.Absolute;
_sceneForm.SceneControl.Scene.Camera = camera;
_sceneForm.SceneControl.Scene.Refresh();
}