Click or drag to resize
AB4D logo

HeightMapVisual3D Class

HeightMapVisual3D class is used to create Visual3D that represents a 3D height map.
Inheritance Hierarchy

Namespace: Ab3d.Visuals
Assembly: Ab3d.PowerToys (in Ab3d.PowerToys.dll) Version: 11.1.8864.1045
Syntax
C#
public class HeightMapVisual3D : BaseModelVisual3D

The HeightMapVisual3D type exposes the following members.

Constructors
 NameDescription
Public methodHeightMapVisual3D Constructor
Public methodHeightMapVisual3D(String) Constructor
Top
Properties
 NameDescription
Public propertyCenterPosition Gets or sets the plane center position
Public propertyGradientColorsCount Gets or sets the number of individual colors that are created from the gradient. Default value is 256. This value need to be changed before the CreateHeightTextureFromGradient(LinearGradientBrush) method is called.
Public propertyHeightData Gets or sets a two dimensional array of double that defines the height of each point in height map.
Public propertyIsSolidSurfaceShown Gets or set a boolean that specifies if the HeightMapVisual3D shows solid surface for the height map. Default value is true.
Public propertyIsWireframeShown Gets or set a boolean that specifies if the HeightMapVisual3D shows wireframe for the height map. Default value is false.
Public propertyMaxValue Gets or sets the maximum value of the HeightData. When the value is not manually set, then the maximum value from the HeightData is get. When manually setting the value, this must be done before the geometry or the texture is created.
Public propertyMinValue Gets or sets the minimum value of the HeightData. When the value is not manually set, then the minimum value from the HeightData is get. When manually setting the value, this must be done before the geometry or the texture is created.
Public propertySize Gets or sets the size of the HeightMap. Note that the Size.Y defines the scale that is used to multiply each height data value with.
Public propertyUseHeightValuesAsTextureCoordinates When UseHeightValuesAsTextureCoordinates is true, then height values are used for texture coordinates - texture coordinate (0, 0.5) is set the minimum height value and texture coordinate (1, 0.5) is set to the maximum height value. This requires a one dimensional gradient texture and usually produces more accurate results than when UseHeightValuesAsTextureCoordinates is false. When false (by default) then texture coordinates are generated as fraction of x and y position - texture coordinate (0, 0) is used for the first position and (1, 1) for the last position. This requires a two dimensional texture where each pixel in the texture represents the color for the point in the height map. Because pixels are actually squares this does not interpolate the colors as good as when UseHeightValuesAsTextureCoordinates is true. In another worlds: when true, then height values are interpolated between height map positions, when false colors from height values are interpolated between height map positions. When using a custom texture (for example a satellite image) then this property must be set to false.
Public propertyWireframeColor Gets or sets the color of the wireframe lines.
Public propertyWireframeDistance Gets or sets a double that specifies the distance between wireframe and solid model. Default value is 0.001.
Public propertyWireframeThickness Gets or sets the thickness of the wireframe lines.
Top
Methods
 NameDescription
Public methodCreateContourLinePositions CreateContourLinePositions creates positions for all contour lines (also known as isolines) and returns them in one Point3DCollection. The line positions are scaled by the size of this HeightMapVisual3D. The lines can be offset on top of the solid geometry by setting the yOffset value. To generate positions for individual contour lines call CreateMultiContourLinePositions(Double, Double) method.
Public methodCreateHeightTextureFromGradient This methods created a height texture from the height data and specified gradient and set it as the HeightMap Material property. When is true, then one dimensional gradient texture is created; when false then two dimensional texture with color for each data value is created.
Public methodCreateMultiContourLinePositions CreateContourLinePositions creates positions for individual contour lines (also known as isolines) and returns them in an array of Point3DCollection (each element in the array represents positions for contour lines each value in contourLineValues). The line positions are scaled by the size of this HeightMapVisual3D. The lines can be offset on top of the solid geometry by setting the yOffset value. To generate all contour positions in one Point3DCollection use CreateContourLinePositions(Double, Double) method.
Public methodGetHeightTextureColor Returns a color from the height texture for the specified value. The CreateHeightTextureFromGradient(LinearGradientBrush) method must be called before calling this method to crate the height colors array from the gradient.
Public methodGetPositionValues GetPositionValues returns a List of double values (get from HeightData) that represents values for each position that is used for the MeshGeometry3D that shows this height map (position value at index 0 represents the value from HeightData that is used to show first position in MeshGeometry3D).
Protected methodStatic memberOnWireframeColorPropertyChanged OnColorPropertyChanged
Protected methodRefreshGeometry Recreates the Visual3D geometry
(Overrides BaseModelVisual3DRefreshGeometry)
Protected methodRefreshMaterial Resets the Content's material
(Overrides BaseModelVisual3DRefreshMaterial)
Public methodUpdateContent UpdateContent updates the height map 3D mesh. The method can be called after the data in the HeightData array are changed.
Protected methodStatic memberValidateWireframeThicknessPropertyValue Returns true if line thickness is valid double and bigger or equal to 0
Top
Fields
 NameDescription
Public fieldStatic memberCenterPositionProperty CenterPositionProperty
Public fieldStatic memberHeightDataProperty HeightDataProperty
Public fieldStatic memberIsSolidSurfaceShownProperty IsSolidSurfaceShownProperty
Public fieldStatic memberIsWireframeShownProperty IsWireframeShownProperty
Public fieldStatic memberSizeProperty SizeProperty
Public fieldStatic memberUseHeightValuesAsTextureCoordinatesProperty UseHeightValuesAsTextureCoordinatesProperty
Public fieldStatic memberWireframeColorProperty WireframeColorProperty
Public fieldStatic memberWireframeThicknessProperty WireframeThicknessProperty
Top
Extension Methods
 NameDescription
Public Extension MethodDumpHierarchy Display details about the hierarchy of Visual3D children to Debug console (for example to Visual Studio's Immediate window).
(Defined by Extensions)
Public Extension MethodForEachGeometryModel3D Performs the specified action on each GeometryModel3D inside the rootModelVisual3D.
(Defined by Extensions)
Public Extension MethodForEachVisual3D Performs the specified action on each ModelVisual3D inside the rootModelVisual3D.
(Defined by Extensions)
Public Extension MethodGetName Gets name of the Visual3D that was previously set by SetName extension method.
(Defined by Extensions)
Public Extension MethodSetName Sets Name property to Visual3D. Note that if name is not correct for WPF, it can be corrected (name must start with a letter or the underscore character (_), and must contain only letters, digits, or underscores). In this case the SetName method will set the corrected name to the object and return false (in this case you can call GetName to get the corrected name). True is returned when the original name is set to the object.
(Defined by Extensions)
Top
Remarks

HeightMapVisual3D class is used to create Visual3D that represents a 3D height map.

The height map is similar to 3D Plane. The difference is that each position in a height map can have its height defined - the distance from the plane. The position heights are defined with the HeightData property. The height data are defined as two dimensional array of double values. The dimensions of the array also define the number of position used for the height map - one position of one array element.

The position and the size of the height map can be set with CenterPosition and Size properties.

The y value (height) of each 3D position is calculated with the following: yPos = CenterPosition.Y + heightDataValue * Size.Y.

This means that CenterPosition.Y value defines the Y value of the 0 data value. Size.Y value defines the scale factor for all data values.

The color or texture used to display the height map can be set with Material and BackMaterial properties. When BackMaterial property is not set the height map will not be visible from below.

The CreateHeightTextureFromGradient(LinearGradientBrush) method can automatically create a texture for the height data from the specified LinearGradientBrush.

By default the height map is shown as solid surface. It is also possible to show wireframe for the height map. Wireframe is controlled by IsWireframeShown, WireframeThickness and WireframeColor properties. If only wireframe should be shown, than it is possible to set the IsSolidSurfaceShown properties to false.

NOTE:
Showing wireframe for bigger height maps (for example more than 100 x 100) can be very slow. The reason for that is that WPF 3D does not support hardware accelerated 3D lines. Therefore showing wireframe should be used only when using smaller array dimensions.

See Also