AXSceneControl汽车沿着pollyline行驶

                   
           axSceneControl汽车沿着pollyline行驶

ILayer layer = axSceneControl1.SceneGraph.Scene.get_Layer(5);
            IFeatureLayer featurelayer = (IFeatureLayer)layer;
            IFeatureClass featureclass = featurelayer.FeatureClass;
            IFeature feature = featureclass.GetFeature(0);
            IPolyline polyline = (IPolyline )feature.Shape;
            double d = polyline.Length;
            IPoint point1 = new PointClass();
            IPoint point2 = new PointClass();
            for (int i = 2; i <= (int)d;i++ )
            {
                polyline.QueryPoint(esriSegmentExtension.esriNoExtension, i, false, point1);
                polyline.QueryPoint(esriSegmentExtension.esriExtendAtFrom , i-150, false, point2);
                point2 .Z =13;
                point2.X= point2.X +-50;
                ICamera camera = axSceneControl1.SceneViewer.Camera;
                IPoint point3=new PointClass ();
                point3.X = point1.X;
                point3.Y = point1.Y;
                point3.Z =13;
                camera.Target = point3;
                camera.Observer = point2;
                IScene pscene = axSceneControl1.SceneGraph.Scene;
                IMarker3DSymbol pmark3dsymbol = new Marker3DSymbolClass();
                pmark3dsymbol.CreateFromFile("E:\\3dmax\\汽车.3DS");
                IMarkerSymbol marksy = (IMarkerSymbol)pmark3dsymbol;
                marksy.Size = 20;
                marksy.Angle = 90;
                IElement pelement = new MarkerElementClass();
                IMarkerElement pmarkelement = (IMarkerElement)pelement;
                pmarkelement.Symbol = (IMarkerSymbol)marksy;
                pelement.Geometry = point1;
                IGraphicsLayer player = axSceneControl1.SceneGraph.Scene.BasicGraphicsLayer;
                IGraphicsContainer3D pgraphiccontainer3d = (IGraphicsContainer3D)player;
                pgraphiccontainer3d.DeleteAllElements();
                pgraphiccontainer3d.AddElement((IElement)pmarkelement);
                axSceneControl1.SceneGraph.RefreshViewers();
            }
用3DS文件填充点,移动点,使汽车行驶,并改变camera.

你可能感兴趣的:(in)