Class MaterialHelper
- Namespace
- HelixToolkit.Wpf
- Assembly
- HelixToolkit.Wpf.dll
Provides methods that creates materials.
public static class MaterialHelper
- Inheritance
-
MaterialHelper
- Inherited Members
Methods
ChangeOpacity(Material, double)
Changes the opacity of a material.
public static void ChangeOpacity(Material material, double opacity)
Parameters
Remarks
The method will traverse children of MaterialGroup and change the opacity of all DiffuseMaterial objects. Remember that the material must not be frozen.
CreateEmissiveImageMaterial(string, Brush, UriKind, bool)
Creates an emissive image material.
public static Material? CreateEmissiveImageMaterial(string uri, Brush diffuseBrush, UriKind uriKind, bool freeze = true)
Parameters
uristringThe uri of the image.
diffuseBrushBrushThe diffuse brush.
uriKindUriKindKind of the
uri.freezeboolFreeze the material if set to
true.
Returns
- Material
The image material.
CreateEmissiveImageMaterial(BitmapImage, Brush, bool)
Creates an emissive material from the specified image.
public static Material CreateEmissiveImageMaterial(BitmapImage image, Brush diffuseBrush, bool freeze = true)
Parameters
imageBitmapImageThe image.
diffuseBrushBrushThe diffuse brush.
freezeboolFreeze the material if set to
true.
Returns
- Material
The image material
CreateImageMaterial(string, double, double, double, UriKind, bool)
Creates a scaled material version from the specified bitmap file.
public static Material CreateImageMaterial(string uri, double scaleW, double scaleH, double opacity = 1, UriKind uriKind = UriKind.RelativeOrAbsolute, bool freeze = true)
Parameters
uristringThe uri.
scaleWdoubleHorizontal image scale.
scaleHdoubleVertical image scale.
opacitydoubleThe opacity.
uriKindUriKindKind of the URI.
freezeboolFreeze the material if set to
true.
Returns
- Material
The image material (texture).
CreateImageMaterial(string, double, UriKind, bool)
Creates a material from the specified bitmap file.
public static Material CreateImageMaterial(string uri, double opacity = 1, UriKind uriKind = UriKind.RelativeOrAbsolute, bool freeze = true)
Parameters
uristringThe uri.
opacitydoubleThe opacity.
uriKindUriKindKind of the URI.
freezeboolFreeze the material if set to
true.
Returns
- Material
The image material (texture).
CreateImageMaterial(BitmapImage, double, bool)
Creates a material from the specified image.
public static Material CreateImageMaterial(BitmapImage image, double opacity, bool freeze = true)
Parameters
imageBitmapImageThe image.
opacitydoubleThe opacity value.
freezeboolFreeze the material if set to
true.
Returns
- Material
The image material.
CreateMaterial(Brush, double, byte, bool)
Creates a material with the specified brush as diffuse material. This method will also add a white specular material.
public static Material CreateMaterial(Brush brush, double specularPower = 100, byte ambient = 255, bool freeze = true)
Parameters
brushBrushThe brush.
specularPowerdoubleThe specular power.
ambientbyteThe ambient component.
freezeboolFreeze the material if set to
true.
Returns
- Material
The material.
CreateMaterial(Brush, double, double, byte, bool)
Creates a material with the specified brush as diffuse material. This method will also add a white specular material.
public static Material CreateMaterial(Brush brush, double specularBrightness, double specularPower = 100, byte ambient = 255, bool freeze = true)
Parameters
brushBrushThe brush of the diffuse material.
specularBrightnessdoubleThe brightness of the specular material.
specularPowerdoubleThe specular power.
ambientbyteThe ambient component.
freezeboolFreeze the material if set to
true.
Returns
- Material
The material.
CreateMaterial(Brush?, Brush?, Brush?, double, double, bool)
Creates a material with the specified diffuse, emissive and specular brushes.
public static Material CreateMaterial(Brush? diffuse, Brush? emissive, Brush? specular = null, double opacity = 1, double specularPower = 85, bool freeze = true)
Parameters
diffuseBrushThe diffuse color.
emissiveBrushThe emissive color.
specularBrushThe specular color.
opacitydoubleThe opacity.
specularPowerdoubleThe specular power.
freezeboolFreeze the material if set to
true.
Returns
- Material
The material.
CreateMaterial(Color)
Creates a material for the specified color.
public static Material CreateMaterial(Color color)
Parameters
colorColorThe color.
Returns
- Material
The material.
CreateMaterial(Color, double)
Creates a material for the specified color and opacity.
public static Material CreateMaterial(Color color, double opacity)
Parameters
Returns
- Material
The material.
CreateTiledImageMaterial(BitmapImage, double, double, double, bool)
Creates a tiled material from the specified image.
public static Material CreateTiledImageMaterial(BitmapImage image, double opacity, double scaleW, double scaleH, bool freeze = true)
Parameters
imageBitmapImageThe image.
opacitydoubleThe opacity value.
scaleWdoubleHorizontal image scale.
scaleHdoubleVertical image scale.
freezeboolFreeze the material if set to
true.
Returns
- Material
The image material.
GetFirst<T>(Material)
Gets the first material of the specified type.
public static T? GetFirst<T>(Material material) where T : Material
Parameters
materialMaterialThe source material.
Returns
- T
The first material of the specified type.
Type Parameters
TType of material