Click or drag to resize
AB4D logo

ModelOptimizer Class

ModelOptimizer can be used to optimize the Model3D or Visual3D so it can be drawn faster by WPF 3D.
Inheritance Hierarchy
SystemObject
  Ab3d.UtilitiesModelOptimizer

Namespace: Ab3d.Utilities
Assembly: Ab3d.PowerToys (in Ab3d.PowerToys.dll) Version: 11.1.8864.1045
Syntax
C#
public class ModelOptimizer

The ModelOptimizer type exposes the following members.

Constructors
 NameDescription
Public methodModelOptimizer Constructor
Top
Properties
 NameDescription
Public propertyCombineModelsWithSameMaterial If true than GeometryModel3D with the same material are combined into one GeometryModel3D. This reduces number of required GPU draw calls and can significantly improve performance. Default value is true.
Public propertyCompareMaterialsByHash If true than special 64 bit hash code is calculated from each material and it is used to compare if two materials are the same (this combines difference instances of same material). If false than material references are compared. Default value is true.
Public propertyFreezeAll Gets or sets a boolean that specifies if whole Model3D objects are frozen. Freezing Model3D objects can improve performance and allow Model3D objects to be user on different thread that the thread where they were created. Setting this property to true will also set FreezeMaterials and FreezeMeshGeometries to true. Default value is true.
Public propertyFreezeMaterials Gets or sets a boolean that specifies if Materials are frozen. Freezing materials can improve performance and allow material objects to be user on different thread that the thread where they were created. A drawback is that when materials are frozen, they cannot be changed any more (but if GeometryModel3D is not frozen, the material can be still replaced by some other material). Default value is true.
Public propertyFreezeMeshGeometries Gets or sets a boolean that specifies if MeshGeometries3D objects are frozen. Freezing MeshGeometries3D objects can improve performance and allow MeshGeometries3D objects to be user on different thread that the thread where they were created. A drawback is that when MeshGeometries3D objects are frozen, they cannot be changed any more - you cannot change individual positions or triangle indices (but if GeometryModel3D is not frozen, the value of Geometry property can be changed with some other Geometry). Default value is true.
Top
Methods
 NameDescription
Public methodStatic memberFreeze Freeze can freeze meshes, materials or whole Model3D.
Public methodOptimize(Model3D) Optimize method optimized the model3D and returns a new optimized Model3D object. Optimizations are done based on the ModelOptimizer settings.
Public methodOptimize(ModelVisual3D) Optimizes the ModelVisual3D based on the ModelOptimizer settings. The method replaces the existing ModelVisual3D.Content with new Model3D object.
Public methodStatic memberOptimizeAll(Model3D) OptimizeAll method uses ModelOptimizer to optimizes the Model3D with using the full optimization options. To specify optimization options, create an instance of ModelOptimizer and set its properties before calling Optimize method.
Public methodStatic memberOptimizeAll(ModelVisual3D) OptimizeAll method uses ModelOptimizer to optimizes the ModelVisual3D with using the full optimization options. The method replaces the existing ModelVisual3D.Content with new Model3D object. To specify optimization options, create an instance of ModelOptimizer and set its properties before calling Optimize method.
Top
Remarks

ModelOptimizer can be used to optimize the Model3D or Visual3D so it can be drawn faster by WPF 3D.

ModelOptimizer reduces the number of objects with combining the objects that have the same material.

This can greatly improve performance, but prevents any further changed on the object.

When model is created from many small objects, this can significantly decrease the performance. The reason for that is that each object is rendered with its own DirectX draw call. When many draw calls (more than 1000) are executed, the DirectX and driver overhead can limits the performance.

Graphics card can render objects with many triangles very fast, but cannot render a lot of individual objects fast. Therefore the goal of the ModelOptimizer is to combine objects to reduce their number.

See Also