Material |
public class MaterialTypeConverter : TypeConverter
The MaterialTypeConverter type exposes the following members.
Name | Description | |
---|---|---|
MaterialTypeConverter | Initializes a new instance of the MaterialTypeConverter class |
Name | Description | |
---|---|---|
CanConvertFrom |
Returns whether this converter can convert an object of the given type to the type of this converter.
(Overrides TypeConverterCanConvertFrom(ITypeDescriptorContext, Type)) | |
CanConvertTo |
Returns whether this converter can convert the object to the specified type.
(Overrides TypeConverterCanConvertTo(ITypeDescriptorContext, Type)) | |
ConvertFrom |
Converts the given value to the type of this converter.
(Overrides TypeConverterConvertFrom(ITypeDescriptorContext, CultureInfo, Object)) | |
ConvertTo |
Converts the given value object to the specified type, using the arguments.
(Overrides TypeConverterConvertTo(ITypeDescriptorContext, CultureInfo, Object, Type)) |
Name | Description | |
---|---|---|
ImmediatelyLoadTextureFiles | ImmediatelyLoadTextureFiles specifies if image files are immediately loaded with using file stream. This prevents locking the file after it was loaded. This is the default value. When false, the file is created with OnDemand CacheOption. This is set as default value when used inside DXEngine - this prevents loading image as WPF Bitmap and allows loading texture directly into DirectX buffer. |
The new MaterialTypeConverter can be used only on Material and BackMaterial properties on Abd3.Visuals (not on other WPF Visual3D objects - it is not possible to add TypeConverter attribute to existing properties).
The material type converter can be used to create:
example | |
---|---|
DiffuseMaterial with SolidColorBrush | Red Blue #FF5555 |
DiffuseMaterial with ImageBrush | /Resources/PowerToysTexture.png (for Resource and Content build action) c:\images\PowerToysTexture.png http://www.mysite.com/images/myImage.jpg |
EmissiveMaterial | e:Yellow emissive:Yellow |
Diffuse + Specular material | s:32;Blue (SpecularPower = 32; SpecularBrush = White; DiffuseMaterial = Blue) specular:64;PowerToysTexture.png (SpecularPower = 64; SpecularBrush = White; DiffuseMaterial = PowerToysTexture.png) |
When ImageBrush is created from file, its BitmapImage can be either immediately created or delayed created until it is used. This is controlled with ImmediatelyLoadTextureFiles static field.
The Brush used in SpecularMaterial is always White (used almost always and this keeps the syntax clear).
Emissive material is created with a group with black DiffuseMaterial and EmissiveMaterial with brush defined with used text.
Without MaterialTypeConverter the 3D Box visual can be defined with the following XAML:
<visuals:BoxVisual3D CenterPosition="0 5 -10" Size="10 10 10"> <visuals:BoxVisual3D.Material> <DiffuseMaterial Brush="LightGreen"/> </visuals:BoxVisual3D.Material> </visuals:BoxVisual3D>
With MaterialTypeConverter the same box can be defined in one XAML line:
<visuals:BoxVisual3D CenterPosition="0 5 -10" Size="10 10 10" Material="LightGreen"/>
The following example creates a DiffuseMaterial with ImageBrush from a PowerToysTexture.png that is stored under Resources folder (the image Build Action should be set to Resource):
<visuals:BoxVisual3D CenterPosition="0 5 -10" Size="10 10 10" Material="/Resources/PowerToysTexture.png"/>
The following example creates a DiffuseMaterial with Blue brush and SpecularMaterial with SpecularPower = 64:
<visuals:BoxVisual3D CenterPosition="0 5 -10" Size="10 10 10" Material="Specular:64;Blue"/>