SciChart WPF 3D Charts > 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:

<s3D:SciChart3DSurface x:Name="sciChart" WorldDimensions="200,100,200" BorderThickness="0">
    <s3D:SciChart3DSurface.Camera>
        <s3D:Camera3D ZoomToFitOnAttach="True"/>
    </s3D:SciChart3DSurface.Camera>
    <s3D:SciChart3DSurface.RenderableSeries>
        <s3D:SurfaceMeshRenderableSeries3D x:Name="surfaceMeshRenderableSeries"
                                        DrawMeshAs="SolidWireFrame"
                                        Stroke="#77228B22"
                                        ContourStroke="#77228B22"
                                        StrokeThickness="2.0"
                                        DrawSkirt="False"
                                        Opacity="0.9">
           <s3D:SurfaceMeshRenderableSeries.MeshColorPalette>
              <s3D:GradientColorPalette>
                  <s3D:GradientColorPalette.GradientStops>
                     <GradientStop Offset="1" Color="DarkRed"/>
                     <GradientStop Offset="0.9" Color="Red"/>
                     <GradientStop Offset="0.7" Color="Yellow"/>
                     <GradientStop Offset="0.5" Color="GreenYellow"/>
                     <GradientStop Offset="0.3" Color="Cyan"/>
                     <GradientStop Offset="0.1" Color="Blue"/>
                     <GradientStop Offset="0.0" Color="#1D2C6B"/>
                  </s3D:GradientColorPalette.GradientStops>
              </s3D:GradientColorPalette>
           </s3D:SurfaceMeshRenderableSeries.MeshColorPalette>
        </s3D:SurfaceMeshRenderableSeries3D>
    </s3D:SciChart3DSurface.RenderableSeries>
    <s3D:SciChart3DSurface.XAxis>
        <s3D:NumericAxis3D />
    </s3D:SciChart3DSurface.XAxis>
    <s3D:SciChart3DSurface.YAxis>
        <s3D:NumericAxis3D VisibleRange="0,0.3"/>
    </s3D:SciChart3DSurface.YAxis>
    <s3D:SciChart3DSurface.ZAxis>
        <s3D:NumericAxis3D />
    </s3D:SciChart3DSurface.ZAxis>
</s3D:SciChart3DSurface>
int xSize = 25;
int zSize = 25;
var meshDataSeries = new UniformGridDataSeries3D<double>(xSize, zSize)
{
    StartX = 0,
    StepX = 1,
    StartZ = 0,
    StepZ = 1,
    SeriesName = "Uniform Surface Mesh",
};
for (int x = 0; x < xSize; x++)
{
    for (int z = 0; z < zSize; z++)
    {
        double xVal = ( double )x / ( double )xSize * 25.0;
        double zVal = ( double )z / ( double )zSize * 25.0;
        double y = Math.Sin(xVal * 0.2) / ((zVal+1) * 2);
        meshDataSeries[z, x] = y;
    }
}
surfaceMeshRenderableSeries.DataSeries = meshDataSeries;

 

Data is stored in the UniformGridDataSeries3D Type. This represents a 2-dimensional array of arrays (or 2D Jagged array) typically of type Double (but can be defined with generics).

 

Some important points to note:

  • The double values stored in the UniformGridDataSeries3D correspond to the heights on the chart (the Y-Axis). They are transformed into chart World Coordinates via the SciChart3DSurface.YAxis.
  • The Z and X Data-Value is defined by the StartX, StepX, StartZ and StepZ properties on UniformGridDataSeries3D. These are also transformed into World Coordinates via the SciChart3DSurface.ZAxis and XAxis respectively.
  • The Colours on the SurfaceMesh are defined by the MeshColorPalette. More on this in the following sections.

 

 

 

See Also