0

I want to draw 3d cube in SceneView by interactive operation.

The functions I hope to achieve are:

  1. Click multiple points (x1, y1,0), (x2, y2, 0), (x3, y3, 0), (x4, y4, 0) on SceneView through interaction.
  2. Enter the height h through the pop-up window.
  3. Draw a cube with these points: (x1,y1,0),(x2,y2,0),(x3,y3,0),(x4,y4,0),(x1,y1,h),(x2,y2,h),(x3 ,y3,h),(x4,y4,h)

I tried this:

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);

It works,but I can only get one point from Geometry. I want to get all vertices of my cube.

Then I tried to draw a polygon without Z , and set Renderer to display:

// 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;

In my featureLayer, it has a feature Z, so it works. But this does not meet my requirements, I want to draw the cube in real time instead of reading the data.

I don't know how to achieve... A .NET solution is the best, and other languages are also acceptable. Finally, please forgive my poor English :(

zLulus
  • 15
  • 1
  • 3

1 Answers1

0

Finally, I used Render to solve the problem, but I was not satisfied with this solution. This is my completed result: https://www.cnblogs.com/Lulus/p/13948464.html

zLulus
  • 15
  • 1
  • 3