Posts: 21
Threads: 7
Joined: Dec 2018
Reputation:
0
Hi
How to Hide/Unhide Models from the viewport?
Thanks
Posts: 744
Threads: 8
Joined: Sep 2009
Reputation:
45
When using WPF 3D rendering (Ab3d.PowerToys without Ab3d.DXEngine), then to hide a model, you need to remove it from the hierarchy of objects.
For objects that are derived from BaseVisual3D (all Visual3D objects from Ab3d.PowerToys, for example: BoxVisual3D, SphereVisual3D, etc) this can be simply done by setting the IsVisible property to false.
The IsVisible property can be also used on ContentVisual3D objects. This object can be used to show / hide Model3D object (GeometryModel3D or Model3DGroup) that is assigned to ContentVisual3D.Content property or to show / hide all Visual3D objects that are added to ContentVisual3D.Children property.
This is also demonstrated in the "Standard 3D objects / Hierarchy with ContentVisual3D" sample that comes with Ab3d.PowerToys samples.
As said before, when using WPF 3D rendering and changing the value of IsVisible property, the ContentVisual3D and other Visual3D objects from Ab3d.PowerToys remove the 3D models / visual3D from the hierarchy of objects. In this case this is just a convenient way of showing / hiding the objects.
But when using Ab3d.DXEngine then using IsVisible adds another big advantage - in case the objects are hidden with IsVisible then the DirectX resources that are created for the models are preserved. So when the object is shown again this can happen immediately without the need to recreate the DirectX resources. In case when the objects are removed from the hierarchy of objects then the DirectX resources are disposed (if the object is not added back to the hierarchy within the same frame).
This is demonstrated in the "Other Ab3d.PowerToys samples / ContentVisual3D sample".
Andrej Benedik