SciChart Android 3D Charts API > 3D Chart Types > The SurfaceMesh 3D Chart Type
The SurfaceMesh 3D Chart Type

The surface mesh renders a two-dimensional array as a heightmap. The SurfaceMeshRenderableSeries3D type provides a number of configurable chart types in SciChart 3D, including:

  • Dynamic, updating Surfaces (terrains or height maps)
  • Texturing of surfaces or terrains or height maps
  • Non-uniform or uniform grid spacing
  • Contour mapping or wireframe on terrain or height maps

 

Declaring a Surface Mesh with Uniform Data

To declare a Surface Mesh with uniform data, use the following code:

Uniform SurfaceMesh 3D
Copy Code
final Camera3D camera = sciChart3DBuilder.newCamera3D().build();
final NumericAxis3D xAxis = sciChart3DBuilder.newNumericAxis3D().withGrowBy(.1, .1).build();
final NumericAxis3D yAxis = sciChart3DBuilder.newNumericAxis3D().withVisibleRange(0, .3).withGrowBy(.1, .1).build();
final NumericAxis3D zAxis = sciChart3DBuilder.newNumericAxis3D().withGrowBy(.1, .1).build();
final int xSize = 25;
final int zSize = 25;
final UniformGridDataSeries3D<Double, Double, Double> ds = new UniformGridDataSeries3D<>(Double.class, Double.class, Double.class, xSize, zSize);
for (int x = 0; x < xSize; x++) {
    for (int z = 0; z < zSize; z++) {
        final double xVal = 25.0 * x / xSize;
        final double zVal = 25.0 * z / zSize;
        final double y = Math.sin(xVal * .2) / ((zVal+1) * 2);
        ds.updateYAt(x, z, y);
    }
}
final int[] colors = new int[]{0xFF1D2C6B, Blue, Cyan, GreenYellow, Yellow, Red, DarkRed};
final float[] stops = {0, .1f, .3f, .5f, .7f, .9f, 1};
final int stroke = 0x77228B22;
final SurfaceMeshRenderableSeries3D rs = sciChart3DBuilder.newSurfaceMeshSeries3D()
        .withDataSeries(ds)
        .withDrawMeshAs(DrawMeshAs.SolidWireframe)
        .withStroke(stroke)
        .withContourStroke(stroke)
        .withStrokeThicknes(1f)
        .withDrawSkirt(false)
        .withMeshColorPalette(new GradientColorPalette(colors, stops))
        .build();
UpdateSuspender.using(surface3d, new Runnable() {
    @Override
    public void run() {
        surface3d.setCamera(camera);
        surface3d.setXAxis(xAxis);
        surface3d.setYAxis(yAxis);
        surface3d.setZAxis(zAxis);
        surface3d.getRenderableSeries().add(rs);
        surface3d.getChartModifiers().add(sciChart3DBuilder.newModifierGroupWithDefaultModifiers().build());
    }
});

Data is stored in the UniformGridDataSeries3D Type. This represents a 2-dimensional grid, typically of type Double (but can be defined with generics).

Some important points to note: