超图中基于绝对高度的模型的正视侧视俯视仰视如何实现

0 投票

使用产品: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();

        }

7月 9, 2018 分类:  517次浏览 | 用户: ww84856982 才疏学浅 (11 分)

1个回答

0 投票
您好!您可以将您的场景相机赋给第一人称相机试试 sceneControl.Scene.FirstPersonCamera = sceneCamera;
7月 9, 2018 用户: 胡延南 名扬四海 (2,918 分)
已经确认没有效果,更改camera.Tilt = 90,视角跑到其他地方去了.麻烦给出其他解决方案

您好!我在我场景中用了如下代码实现不同方位展示的,也许会对您有所帮助。

方位1:

 Camera camera = new Camera();
                    camera.Tilt = 90;
                    camera.Altitude = 51;
                    camera.Heading = 0;
                    camera.Longitude = recordset.Bounds.Center.X;
                    camera.Latitude = recordset.Bounds.Center.Y - recordset.Bounds.Width;
                    sceneControl.Scene.FirstPersonCamera = camera;

方位2:

Camera camera = new Camera();

                    camera.Tilt = 90;
                    camera.Altitude = 51;
                    camera.Heading = 90;
                    camera.Longitude = recordset.Bounds.Center.X - recordset.Bounds.Width;
                    camera.Latitude = recordset.Bounds.Center.Y;
                    sceneControl.Scene.FirstPersonCamera = camera;

感谢,我发现我加了个_sceneForm.SceneControl.Scene.Fly(camera, 2000);造成视角飞跑的问题.请问下按照您的代码,视角是直接切过去的,有没有办法增加飞行的动画效果?

也就是飞到指定视角.
...