Reader3dsIsTransparencySortingEnabled Property |
Namespace: Ab3d
WPF 3D can show transparent 3D objects. But to show them correctly, the transparent objects need to be defined after all the objects that are visible through them. This does not mean their position in 3D space but their index in the object's hierarchy (index in the parent's Children collection). The objects that are defined after the transparent objects cannot be seen through the transparent objects.
3D objects that are defined in 3ds files can be defined in any order. This means that transparent objects in 3ds files can be defined before non-transparent objects. In case when the 3ds file contains transparent objects, they need to be sorted.
Ab3d.Reader3ds support simple transparency sorting - the transparent objects are simply moved after non-transparent objects. This can be controlled with IsTransparencySortingEnabled property. Its default value is true.
For cases when the number of transparent objects is not big and if the transparent objects are not positioned in 3D space one after another, the simple transparency sorting is usually enough to produce correct rendering in WPF 3D.
But simply moving transparent objects after non-transparent objects is not always enough. For example if transparent object A is visible through transparent object B, than B must be defined after A. The correct way to solve this problem is to first move transparent objects after non-transparent objects and than sort transparent objects by their distance to the camera.
But this means that when the camera is moved, we need to sort the objects again. This technique is not supported by Ab3d.Reader3ds. But it is supported by Ab3d.PowerToys library and its TransparencySorter class (in Ab3d.Utilities namespace).
After reading the 3ds file it is possible to get the number of transparent objects with TransparentObjectsCount property.