0

我想通过交互操作在 SceneView 中绘制 3d 立方体。

我希望实现的功能是:

  1. 通过交互点击SceneView上的多个点(x1, y1,0), (x2, y2, 0), (x3, y3, 0), (x4, y4, 0)。
  2. h通过弹出窗口输入高度。
  3. 用这些点画一个立方体:(x1,y1,0),(x2,y2,0),(x3,y3,0),(x4,y4,0),(x1,y1,h),(x2, y2,h),(x3,y3,h),(x4,y4,h)

我试过这个:

var centerPoint = new MapPoint(vm.X, vm.Y, vm.Z, onMapLocation.SpatialReference);

SimpleMarkerSceneSymbol symbol = SimpleMarkerSceneSymbol.CreateCube(System.Drawing.Color.DarkSeaGreen, 1, SceneSymbolAnchorPosition.Center);
symbol.Heading = vm.Heading;
symbol.Height = vm.Height;
symbol.Width = vm.Width;
symbol.Depth = vm.Depth;
// Create the graphic from the geometry and the symbol.
Graphic item = new Graphic(centerPoint, symbol);

// Add the graphic to the overlay.
graphicOverlay.Graphics.Add(item);

它有效,但我只能从几何中得到一分。我想得到我的立方体的所有顶点。

然后我尝试绘制一个没有 Z 的多边形,并设置Renderer为显示:

// Create a new simple line symbol for the feature layer
SimpleLineSymbol mySimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.Black, 1);

// Create a new simple fill symbol for the feature layer 
SimpleFillSymbol mysimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, System.Drawing.Color.WhiteSmoke, mySimpleLineSymbol);

// Create a new simple renderer for the feature layer
SimpleRenderer mySimpleRenderer = new SimpleRenderer(mysimpleFillSymbol);

// Get the scene properties from the simple renderer
RendererSceneProperties myRendererSceneProperties = mySimpleRenderer.SceneProperties;

// Set the extrusion mode for the scene properties
myRendererSceneProperties.ExtrusionMode = ExtrusionMode.AbsoluteHeight;

// Set the initial extrusion expression
myRendererSceneProperties.ExtrusionExpression = "[Z]";

// Set the feature layer's renderer to the define simple renderer
featureLayer.Renderer = mySimpleRenderer;

在我的 featureLayer 中,它有一个 feature Z,所以它可以工作。但这不符合我的要求,我想实时绘制立方体而不是读取数据。

不知道怎么实现... .NET的方案是最好的,其他语言也可以。最后,请原谅我糟糕的英语:(

4

1 回答 1

0

最后,我用 Render 解决了这个问题,但我对这个解决方案并不满意。这是我完成的结果: https ://www.cnblogs.com/Lulus/p/13948464.html

于 2020-11-12T06:29:30.247 回答