Click or drag to resize
AB4D logo

ModelDecoratorVisual3D Class

ModelDecoratorVisual3D is a Visual3D that can be used to show bounding box, normals and triangles for the specified TargetModel3D.
Inheritance Hierarchy

Namespace: Ab3d.Visuals
Assembly: Ab3d.PowerToys (in Ab3d.PowerToys.dll) Version: 11.0.8746.1045
Syntax
C#
public class ModelDecoratorVisual3D : BaseVisual3D

The ModelDecoratorVisual3D type exposes the following members.

Constructors
 NameDescription
Public methodModelDecoratorVisual3D Constructor
Public methodModelDecoratorVisual3D(String) Constructor
Top
Properties
 NameDescription
Public propertyBoundingBoxLineColor Gets or sets the color of the lines that show the bounding box. Default values is Red.
Public propertyBoundingBoxLineThickness Gets or sets the thickness of the lines that show the bounding box. Default values is 2.
Public propertyCalculateBoundingBoxFromPositions Gets or sets a boolean that specifies if bounding box is calculated from transforming all the positions in the TargetModel3D so that the bounding box will exactly fit the model even when it is rotated (when value is true). When CalculateBoundingBoxFromPositions is false, then bounding box is calculated by transforming the Model3D bounding box. This is much faster, but not as accurate (bounding box can be bigger than the actually transformed model). Default value is false.
Public propertyNormalsLineColor Gets or sets the color of the lines that show the normals. Default values is Green.
Public propertyNormalsLineLength Gets or sets the length of the normal lines. When set to NaN (by default) the normals length is calculated from the size of the TargetModel3D.
Public propertyNormalsLineThickness Gets or sets the thickness of the lines that show the model normals. Default values is 1.
Public propertyRootModelVisual3D Gets or sets a ModelVisual3D that is a parent ModelVisual3D for TargetModel3D.
Public propertyShowBoundingBox Gets or sets a boolean that specifies if a wire box that encloses the TargetModel3D is shown.
Public propertyShowNormalLineArrow Gets or sets a nullable Boolean that specifies if normal lines are shown with arrows. If this property is set to null (by default), then arrows are shown when mesh has less then 1000 positions. When using Ab3d.DXEngine and this class is used on a model with a lot of triangles then showing arrows may be very slow (lines with arrows are not hardware accelerated).
Public propertyShowNormals Gets or sets a boolean that specifies if normals of the TargetModel3D are shown. The TargetModel3D must be GeometryModel3D and not Model3DGroup.
Public propertyShowTriangles Gets or sets a boolean that specifies if triangles of the TargetModel3D are shown. The TargetModel3D must be GeometryModel3D and not Model3DGroup.
Public propertyTargetModel3D Gets or sets Model3D for witch bounding box, normals or triangles will be shown with this ModelDecoratorVisual3D.
Public propertyTrianglesLineColor Gets or sets the color of the lines that show the triangles. Default values is Blue.
Public propertyTrianglesLineThickness Gets or sets the thickness of the lines that show the triangles. Default values is 1.
Top
Methods
 NameDescription
Protected methodCreateModel CreateModel creates the Model3D objects and sets them to Content property.
(Overrides BaseVisual3DCreateModel)
Protected methodStatic memberOnBoundingBoxPropertyChanged OnBoundingBoxPropertyChanged
Protected methodStatic memberOnCalculateBoundingBoxFromPositionsPropertyChanged OnCalculateBoundingBoxFromPositionsPropertyChanged
Protected methodStatic memberOnNormalsPropertyChanged OnNormalsPropertyChanged
Protected methodStatic memberOnTargetModel3DPropertyChanged OnTargetModel3DPropertyChanged
Protected methodStatic memberOnTrianglesPropertyChanged OnTrianglesPropertyChanged
Public methodRefresh Recreates the shown lines. Can be called when the TargetModel3D has been moved.
Top
Fields
 NameDescription
Public fieldStatic memberBoundingBoxLineColorsProperty BoundingBoxLineColorsProperty
Public fieldStatic memberBoundingBoxLineThicknessProperty BoundingBoxLineThicknessProperty
Public fieldStatic memberCalculateBoundingBoxFromPositionsProperty CalculateBoundingBoxFromPositionsProperty
Public fieldStatic memberNormalsLineColorProperty NormalsLineColorProperty
Public fieldStatic memberNormalsLineLengthProperty NormalsLineLengthProperty
Public fieldStatic memberNormalsLineThicknessProperty NormalsLineThicknessProperty
Public fieldStatic memberRootModelVisual3DProperty RootModelVisual3DProperty
Public fieldStatic memberShowBoundingBoxProperty ShowBoundingBoxProperty
Public fieldStatic memberShowNormalLineArrowProperty ShowNormalsLineArrowProperty
Public fieldStatic memberShowNormalsProperty ShowNormalsProperty
Public fieldStatic memberShowTrianglesProperty ShowTrianglesProperty
Public fieldStatic memberTargetModel3DProperty TargetModel3DProperty
Public fieldStatic memberTrianglesLineColorProperty TrianglesLineColorProperty
Public fieldStatic memberTrianglesLineThicknessProperty TrianglesLineThicknessProperty
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

ModelDecoratorVisual3D is a Visual3D that can be used to show bounding box, normals and triangles for the specified TargetModel3D.

The TargetModel3D property should be set to the Model3D that will be "decorated" with bounding box, triangles or normals. It is also recommended to set the RootModelVisual3D that specifies a parent ModelVisual3D for TargetModel3D. This way ModelDecoratorVisual3D can take into account any transformations that are used on parent Visual3D objects.

When showing bounding box, you can set the CalculateBoundingBoxFromPositions to calculate the bounding box from all positions. This will produce a bounding box that will exactly fit the model even when it is rotated. But when the model is complex, it can take a few moments to calculate the exact bounding box. When the CalculateBoundingBoxFromPositions is set to false (by default), the shown bounding box will be calculated by transforming the model's bounds. This is much faster but can show a bounding box that is bigger then the rotated model.

By default it calculates the shown bounding box with transforming the

Example

The following XAML shows how a ModelDecoratorVisual3D can be used (it should be defined inside Viewport3D):

C#
<visuals1:ModelDecoratorVisual3D x:Name="SelectedModelDecorator" 
                                ShowBoundingBox="False" BoundingBoxLineColor="Red" BoundingBoxLineThickness="2"
                                ShowNormals="True" NormalsLineColor="Blue" NormalsLineThickness="1"
                                ShowTriangles="True" TrianglesLineColor="Green" TrianglesLineThickness="1"
                                TargetModel3D="{Binding ElementName=MyModel3D}" />
See Also