Table of Contents

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

material Material

The material.

opacity double

The new opacity.

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

uri string

The uri of the image.

diffuseBrush Brush

The diffuse brush.

uriKind UriKind

Kind of the uri.

freeze bool

Freeze 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

image BitmapImage

The image.

diffuseBrush Brush

The diffuse brush.

freeze bool

Freeze 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

uri string

The uri.

scaleW double

Horizontal image scale.

scaleH double

Vertical image scale.

opacity double

The opacity.

uriKind UriKind

Kind of the URI.

freeze bool

Freeze 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

uri string

The uri.

opacity double

The opacity.

uriKind UriKind

Kind of the URI.

freeze bool

Freeze 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

image BitmapImage

The image.

opacity double

The opacity value.

freeze bool

Freeze 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

brush Brush

The brush.

specularPower double

The specular power.

ambient byte

The ambient component.

freeze bool

Freeze 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

brush Brush

The brush of the diffuse material.

specularBrightness double

The brightness of the specular material.

specularPower double

The specular power.

ambient byte

The ambient component.

freeze bool

Freeze 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

diffuse Brush

The diffuse color.

emissive Brush

The emissive color.

specular Brush

The specular color.

opacity double

The opacity.

specularPower double

The specular power.

freeze bool

Freeze 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

color Color

The 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

color Color

The color.

opacity double

The opacity.

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

image BitmapImage

The image.

opacity double

The opacity value.

scaleW double

Horizontal image scale.

scaleH double

Vertical image scale.

freeze bool

Freeze 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

material Material

The source material.

Returns

T

The first material of the specified type.

Type Parameters

T

Type of material